260316:1117 20260316:1100 Refactor UUID
Build and Deploy / deploy (push) Successful in 9m24s

This commit is contained in:
admin
2026-03-16 11:17:15 +07:00
parent b93cd91325
commit c5c3ed9016
92 changed files with 1726 additions and 620 deletions
+18 -18
View File
@@ -15,7 +15,7 @@ export const correspondenceKeys = {
lists: () => [...correspondenceKeys.all, 'list'] as const,
list: (params: SearchCorrespondenceDto) => [...correspondenceKeys.lists(), params] as const,
details: () => [...correspondenceKeys.all, 'detail'] as const,
detail: (id: number | string) => [...correspondenceKeys.details(), id] as const,
detail: (uuid: string) => [...correspondenceKeys.details(), uuid] as const,
};
// --- Queries ---
@@ -28,11 +28,11 @@ export function useCorrespondences(params: SearchCorrespondenceDto) {
});
}
export function useCorrespondence(id: number | string) {
export function useCorrespondence(uuid: string) {
return useQuery({
queryKey: correspondenceKeys.detail(id),
queryFn: () => correspondenceService.getById(id),
enabled: !!id,
queryKey: correspondenceKeys.detail(uuid),
queryFn: () => correspondenceService.getByUuid(uuid),
enabled: !!uuid,
});
}
@@ -59,11 +59,11 @@ export function useUpdateCorrespondence() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number | string; data: Partial<CreateCorrespondenceDto> }) =>
correspondenceService.update(id, data),
onSuccess: (_, { id }) => {
mutationFn: ({ uuid, data }: { uuid: string; data: Partial<CreateCorrespondenceDto> }) =>
correspondenceService.update(uuid, data),
onSuccess: (_, { uuid }) => {
toast.success('Correspondence updated successfully');
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(id) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(uuid) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.lists() });
},
onError: (error: ApiError) => {
@@ -78,7 +78,7 @@ export function useDeleteCorrespondence() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number | string) => correspondenceService.delete(id),
mutationFn: (uuid: string) => correspondenceService.delete(uuid),
onSuccess: () => {
toast.success('Correspondence deleted successfully');
queryClient.invalidateQueries({ queryKey: correspondenceKeys.lists() });
@@ -95,11 +95,11 @@ export function useSubmitCorrespondence() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number; data: SubmitCorrespondenceDto }) =>
correspondenceService.submit(id, data),
onSuccess: (_, { id }) => {
mutationFn: ({ uuid, data }: { uuid: string; data: SubmitCorrespondenceDto }) =>
correspondenceService.submit(uuid, data),
onSuccess: (_, { uuid }) => {
toast.success('Correspondence submitted successfully');
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(id) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(uuid) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.lists() });
},
onError: (error: ApiError) => {
@@ -114,11 +114,11 @@ export function useProcessWorkflow() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number | string; data: WorkflowActionDto }) =>
correspondenceService.processWorkflow(id, data),
onSuccess: (_, { id }) => {
mutationFn: ({ uuid, data }: { uuid: string; data: WorkflowActionDto }) =>
correspondenceService.processWorkflow(uuid, data),
onSuccess: (_, { uuid }) => {
toast.success('Action completed successfully');
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(id) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.detail(uuid) });
queryClient.invalidateQueries({ queryKey: correspondenceKeys.lists() });
},
onError: (error: ApiError) => {
+10 -10
View File
@@ -17,7 +17,7 @@ export const drawingKeys = {
lists: () => [...drawingKeys.all, 'list'] as const,
list: (type: DrawingType, params: DrawingSearchParams) => [...drawingKeys.lists(), type, params] as const,
details: () => [...drawingKeys.all, 'detail'] as const,
detail: (type: DrawingType, id: number | string) => [...drawingKeys.details(), type, id] as const,
detail: (type: DrawingType, uuid: string) => [...drawingKeys.details(), type, uuid] as const,
};
// --- Queries ---
@@ -33,7 +33,7 @@ export function useDrawings(type: DrawingType, params: DrawingSearchParams) {
if (response && response.data) {
const mappedData = response.data.map((d: ContractDrawing) => ({
...d,
drawingId: d.id,
uuid: d.uuid,
drawingNumber: d.contractDrawingNo,
type: 'CONTRACT',
}));
@@ -46,7 +46,7 @@ export function useDrawings(type: DrawingType, params: DrawingSearchParams) {
if (response && response.data) {
const mappedData = response.data.map((d: ShopDrawing) => ({
...d,
drawingId: d.id,
uuid: d.uuid,
type: 'SHOP',
title: d.currentRevision?.title || 'Untitled',
revision: d.currentRevision?.revisionNumber,
@@ -61,7 +61,7 @@ export function useDrawings(type: DrawingType, params: DrawingSearchParams) {
if (response && response.data) {
const mappedData = response.data.map((d: AsBuiltDrawing) => ({
...d,
drawingId: d.id,
uuid: d.uuid,
type: 'AS_BUILT',
title: d.currentRevision?.title || 'Untitled',
revision: d.currentRevision?.revisionNumber,
@@ -76,19 +76,19 @@ export function useDrawings(type: DrawingType, params: DrawingSearchParams) {
});
}
export function useDrawing(type: DrawingType, id: number | string) {
export function useDrawing(type: DrawingType, uuid: string) {
return useQuery({
queryKey: drawingKeys.detail(type, id),
queryKey: drawingKeys.detail(type, uuid),
queryFn: async () => {
if (type === 'CONTRACT') {
return contractDrawingService.getById(id);
return contractDrawingService.getByUuid(uuid);
} else if (type === 'SHOP') {
return shopDrawingService.getById(id);
return shopDrawingService.getByUuid(uuid);
} else {
return asBuiltDrawingService.getById(id);
return asBuiltDrawingService.getByUuid(uuid);
}
},
enabled: !!id,
enabled: !!uuid,
});
}
+3 -3
View File
@@ -44,8 +44,8 @@ export function useCreateOrganization() {
export function useUpdateOrganization() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number; data: UpdateOrganizationDto }) =>
masterDataService.updateOrganization(id, data),
mutationFn: ({ uuid, data }: { uuid: string; data: UpdateOrganizationDto }) =>
masterDataService.updateOrganization(uuid, data),
onSuccess: () => {
toast.success('Organization updated successfully');
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
@@ -61,7 +61,7 @@ export function useUpdateOrganization() {
export function useDeleteOrganization() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number) => masterDataService.deleteOrganization(id),
mutationFn: (uuid: string) => masterDataService.deleteOrganization(uuid),
onSuccess: () => {
toast.success('Organization deleted successfully');
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
+3 -3
View File
@@ -7,7 +7,7 @@ import { getApiErrorMessage } from '@/types/api-error';
export const projectKeys = {
all: ['projects'] as const,
list: (params: SearchProjectDto) => [...projectKeys.all, 'list', params] as const,
detail: (id: number) => [...projectKeys.all, 'detail', id] as const,
detail: (uuid: string) => [...projectKeys.all, 'detail', uuid] as const,
};
export function useProjects(params?: SearchProjectDto) {
@@ -36,7 +36,7 @@ export function useCreateProject() {
export function useUpdateProject() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number; data: UpdateProjectDto }) => projectService.update(id, data),
mutationFn: ({ uuid, data }: { uuid: string; data: UpdateProjectDto }) => projectService.update(uuid, data),
onSuccess: () => {
toast.success("Project updated successfully");
queryClient.invalidateQueries({ queryKey: projectKeys.all });
@@ -52,7 +52,7 @@ export function useUpdateProject() {
export function useDeleteProject() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number) => projectService.delete(id),
mutationFn: (uuid: string) => projectService.delete(uuid),
onSuccess: () => {
toast.success("Project deleted successfully");
queryClient.invalidateQueries({ queryKey: projectKeys.all });
+3 -3
View File
@@ -7,7 +7,7 @@ import { getApiErrorMessage } from '@/types/api-error';
export const userKeys = {
all: ['users'] as const,
list: (params?: SearchUserDto) => [...userKeys.all, 'list', params] as const,
detail: (id: number) => [...userKeys.all, 'detail', id] as const,
detail: (uuid: string) => [...userKeys.all, 'detail', uuid] as const,
};
export function useUsers(params?: SearchUserDto) {
@@ -43,7 +43,7 @@ export function useCreateUser() {
export function useUpdateUser() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: ({ id, data }: { id: number; data: UpdateUserDto }) => userService.update(id, data),
mutationFn: ({ uuid, data }: { uuid: string; data: UpdateUserDto }) => userService.update(uuid, data),
onSuccess: () => {
toast.success("User updated successfully");
queryClient.invalidateQueries({ queryKey: userKeys.all });
@@ -59,7 +59,7 @@ export function useUpdateUser() {
export function useDeleteUser() {
const queryClient = useQueryClient();
return useMutation({
mutationFn: (id: number) => userService.delete(id),
mutationFn: (uuid: string) => userService.delete(uuid),
onSuccess: () => {
toast.success("User deleted successfully");
queryClient.invalidateQueries({ queryKey: userKeys.all });