function RouteComponent() {
const { id } = Route.useRouteContext();
const { data: category, isPending: isCategoryPending } = useCategory(id);
const { mutate: updateCategory } = useUpdateCategory();
const navigate = useNavigate();
const form = useAppForm({
defaultValues: {
name: category?.name ?? '',
nodeId: category?.nodeId ?? '',
} as CreateCategory,
validators: {
onChange: createCategorySchema,
},
onSubmit: ({ value }) => {
updateCategory(
{ data: value, id },
{
onSuccess: () => {
// NOT TRIGGERED ON SUCCESS
navigate({ to: '/admin/categories' });
},
},
);
},
});
return (
<AdminCategoryForm
form={form}
isPending={isCategoryPending}
isEditing
/>
);
}
function RouteComponent() {
const { id } = Route.useRouteContext();
const { data: category, isPending: isCategoryPending } = useCategory(id);
const { mutate: updateCategory } = useUpdateCategory();
const navigate = useNavigate();
const form = useAppForm({
defaultValues: {
name: category?.name ?? '',
nodeId: category?.nodeId ?? '',
} as CreateCategory,
validators: {
onChange: createCategorySchema,
},
onSubmit: ({ value }) => {
updateCategory(
{ data: value, id },
{
onSuccess: () => {
// NOT TRIGGERED ON SUCCESS
navigate({ to: '/admin/categories' });
},
},
);
},
});
return (
<AdminCategoryForm
form={form}
isPending={isCategoryPending}
isEditing
/>
);
}