pl-fe: wow it compiles
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -147,7 +147,6 @@
|
||||
"vite-plugin-require": "^1.2.14",
|
||||
"vite-plugin-static-copy": "^1.0.6",
|
||||
"wicg-inert": "^3.1.3",
|
||||
"zod": "^3.23.8",
|
||||
"zustand": "^5.0.0-rc.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useEffect } from 'react';
|
||||
import { z } from 'zod';
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { useAppDispatch } from 'pl-fe/hooks/useAppDispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/useAppSelector';
|
||||
@ -29,7 +29,7 @@ const useBatchedEntities = <TEntity extends Entity>(
|
||||
const getState = useGetState();
|
||||
const dispatch = useAppDispatch();
|
||||
const { entityType, listKey, path } = parseEntitiesPath(expandedPath);
|
||||
const schema = opts.schema || z.custom<TEntity>();
|
||||
const schema = opts.schema || v.custom<TEntity>(() => true);
|
||||
|
||||
const isEnabled = opts.enabled ?? true;
|
||||
const isFetching = useListState(path, 'fetching');
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { z } from 'zod';
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { useAppDispatch } from 'pl-fe/hooks/useAppDispatch';
|
||||
import { useLoading } from 'pl-fe/hooks/useLoading';
|
||||
@ -31,7 +31,7 @@ const useCreateEntity = <TEntity extends Entity = Entity, TTransformedEntity ext
|
||||
callbacks: EntityCallbacks<TTransformedEntity, { response?: PlfeResponse }> = {},
|
||||
): Promise<void> => {
|
||||
const result = await setPromise(entityFn(data));
|
||||
const schema = opts.schema || z.custom<TEntity>();
|
||||
const schema = opts.schema || v.custom<TEntity>(() => true);
|
||||
let entity: TEntity | TTransformedEntity = v.parse(schema, result);
|
||||
if (opts.transform) entity = opts.transform(entity);
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ const useEntities = <TEntity extends Entity, TTransformedEntity extends Entity =
|
||||
|
||||
const { entityType, listKey, path } = parseEntitiesPath(expandedPath);
|
||||
const entities = useAppSelector(state => selectEntities<TTransformedEntity>(state, path));
|
||||
const schema = opts.schema || z.custom<TEntity>();
|
||||
const schema = opts.schema || v.custom<TEntity>(() => true);
|
||||
|
||||
const isEnabled = opts.enabled ?? true;
|
||||
const isFetching = useListState(path, 'fetching');
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import z from 'zod';
|
||||
import * as v from 'valibot';
|
||||
|
||||
import { useAppDispatch } from 'pl-fe/hooks/useAppDispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/useAppSelector';
|
||||
@ -35,7 +35,7 @@ const useEntity = <TEntity extends Entity, TTransformedEntity extends Entity = T
|
||||
|
||||
const [entityType, entityId] = path;
|
||||
|
||||
const defaultSchema = z.custom<TEntity>();
|
||||
const defaultSchema = v.custom<TEntity>(() => true);
|
||||
const schema = opts.schema || defaultSchema;
|
||||
|
||||
const entity = useAppSelector(state => selectEntity<TTransformedEntity>(state, entityType, entityId));
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import * as v from 'valibot';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { useAppDispatch } from 'pl-fe/hooks/useAppDispatch';
|
||||
import { useAppSelector } from 'pl-fe/hooks/useAppSelector';
|
||||
@ -23,7 +22,7 @@ const useEntityLookup = <TEntity extends Entity, TTransformedEntity extends Enti
|
||||
entityFn: EntityFn<void>,
|
||||
opts: UseEntityOpts<TEntity, TTransformedEntity> = {},
|
||||
) => {
|
||||
const { schema = z.custom<TEntity>() } = opts;
|
||||
const { schema = v.custom<TEntity>(() => true) } = opts;
|
||||
|
||||
const dispatch = useAppDispatch();
|
||||
const [fetchedEntity, setFetchedEntity] = useState<TTransformedEntity | undefined>();
|
||||
|
||||
Reference in New Issue
Block a user