251209:1453 Frontend: progress nest = UAT & Bug Fixing
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
admin
2025-12-09 14:53:42 +07:00
parent 8aceced902
commit aa96cd90e3
125 changed files with 11052 additions and 785 deletions

View File

@@ -1,5 +1,6 @@
import { useQuery } from '@tanstack/react-query';
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { masterDataService } from '@/lib/services/master-data.service';
import { toast } from 'sonner';
export const masterDataKeys = {
all: ['masterData'] as const,
@@ -15,6 +16,54 @@ export function useOrganizations() {
});
}
export function useCreateOrganization() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (data: any) => masterDataService.createOrganization(data),
onSuccess: () => {
toast.success("Organization created successfully");
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
},
onError: (error: any) => {
toast.error("Failed to create organization", {
description: error.response?.data?.message || "Unknown error"
});
}
});
}
export function useUpdateOrganization() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number; data: any }) => masterDataService.updateOrganization(id, data),
onSuccess: () => {
toast.success("Organization updated successfully");
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
},
onError: (error: any) => {
toast.error("Failed to update organization", {
description: error.response?.data?.message || "Unknown error"
});
}
});
}
export function useDeleteOrganization() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number) => masterDataService.deleteOrganization(id),
onSuccess: () => {
toast.success("Organization deleted successfully");
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
},
onError: (error: any) => {
toast.error("Failed to delete organization", {
description: error.response?.data?.message || "Unknown error"
});
}
});
}
export function useDisciplines(contractId?: number) {
return useQuery({
queryKey: masterDataKeys.disciplines(contractId),