mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 08:46:22 +02:00
Issues Fixed - Missing pagination fields in API response schemas (page, page_size, has_more) - NOTE enum missing from frontend Zod schema - Missing fields in DocumentRead response construction (content_hash, updated_at) - BlockNote slash menu clipped by overflow-hidden CSS - Sidebar click conflicts - hidden action buttons intercepting clicks - Rewrote All Notes sidebar - replaced fragile custom portal with shadcn Sheet - Missing translation keys for new UI strings - Missing NOTE retrieval logic in researcher agent - Added search to All Notes sidebar - Removed frontend logging - was causing toasters on every page refresh - Added backend logging to document reindex Celery task
70 lines
2 KiB
TypeScript
70 lines
2 KiB
TypeScript
import { atomWithMutation } from "jotai-tanstack-query";
|
|
import { toast } from "sonner";
|
|
import type {
|
|
CreateRoleRequest,
|
|
CreateRoleResponse,
|
|
DeleteRoleRequest,
|
|
DeleteRoleResponse,
|
|
UpdateRoleRequest,
|
|
UpdateRoleResponse,
|
|
} from "@/contracts/types/roles.types";
|
|
import { rolesApiService } from "@/lib/apis/roles-api.service";
|
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
|
import { queryClient } from "@/lib/query-client/client";
|
|
|
|
export const createRoleMutationAtom = atomWithMutation(() => {
|
|
return {
|
|
mutationFn: async (request: CreateRoleRequest) => {
|
|
return rolesApiService.createRole(request);
|
|
},
|
|
onSuccess: (_: CreateRoleResponse, request: CreateRoleRequest) => {
|
|
toast.success("Role created successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.roles.all(request.search_space_id.toString()),
|
|
});
|
|
},
|
|
onError: () => {
|
|
toast.error("Failed to create role");
|
|
},
|
|
};
|
|
});
|
|
|
|
export const updateRoleMutationAtom = atomWithMutation(() => {
|
|
return {
|
|
mutationFn: async (request: UpdateRoleRequest) => {
|
|
return rolesApiService.updateRole(request);
|
|
},
|
|
onSuccess: (_: UpdateRoleResponse, request: UpdateRoleRequest) => {
|
|
toast.success("Role updated successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.roles.all(request.search_space_id.toString()),
|
|
});
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.roles.byId(
|
|
request.search_space_id.toString(),
|
|
request.role_id.toString()
|
|
),
|
|
});
|
|
},
|
|
onError: () => {
|
|
toast.error("Failed to update role");
|
|
},
|
|
};
|
|
});
|
|
|
|
export const deleteRoleMutationAtom = atomWithMutation(() => {
|
|
return {
|
|
mutationFn: async (request: DeleteRoleRequest) => {
|
|
return rolesApiService.deleteRole(request);
|
|
},
|
|
onSuccess: (_: DeleteRoleResponse, request: DeleteRoleRequest) => {
|
|
toast.success("Role deleted successfully");
|
|
queryClient.invalidateQueries({
|
|
queryKey: cacheKeys.roles.all(request.search_space_id.toString()),
|
|
});
|
|
},
|
|
onError: () => {
|
|
toast.error("Failed to delete role");
|
|
},
|
|
};
|
|
});
|