Fix creating bookmarks
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
8b566d3bf7
commit
de1d147cbd
2 changed files with 3 additions and 3 deletions
|
@ -32,7 +32,7 @@ const useCreateEntity = <TEntity extends Entity = Entity, TTransformedEntity ext
|
|||
): Promise<void> => {
|
||||
const result = await setPromise(entityFn(data));
|
||||
const schema = opts.schema || z.custom<TEntity>();
|
||||
let entity: TEntity | TTransformedEntity = schema.parse(result.json);
|
||||
let entity: TEntity | TTransformedEntity = schema.parse(result);
|
||||
if (opts.transform) entity = opts.transform(entity);
|
||||
|
||||
// TODO: optimistic updating
|
||||
|
|
|
@ -36,10 +36,10 @@ const useEntityLookup = <TEntity extends Entity, TTransformedEntity extends Enti
|
|||
const fetchEntity = async () => {
|
||||
try {
|
||||
const response = await setPromise(entityFn());
|
||||
const entity = schema.parse(response.json);
|
||||
const entity = schema.parse(response);
|
||||
const transformedEntity = opts.transform ? opts.transform(entity) : entity;
|
||||
setFetchedEntity(transformedEntity as TTransformedEntity);
|
||||
dispatch(importEntities([entity], entityType));
|
||||
dispatch(importEntities([transformedEntity], entityType));
|
||||
} catch (e) {
|
||||
setError(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue