blocker phase 6, catalog admin
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { catalogApi } from '../apis';
|
||||
import { catalogKeys } from '../keys';
|
||||
import type { UpdateOptionValueInput } from '../types';
|
||||
|
||||
/**
|
||||
* Edits a value's labels/order and activates/deactivates it (never a hard delete — re-parenting to a
|
||||
* different group is not supported). Invalidates every cached category's option-groups.
|
||||
*/
|
||||
export function useUpdateOptionValue() {
|
||||
const queryClient = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: ({ id, input }: { id: number; input: UpdateOptionValueInput }) => catalogApi.updateOptionValue(id, input),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: catalogKeys.adminOptionGroupsAll() });
|
||||
queryClient.invalidateQueries({ queryKey: catalogKeys.categoryOptionGroupsAll() });
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user