260219:1649 20260219 TASK-BEFE-001 Fixed Blank Admin Pages
All checks were successful
Build and Deploy / deploy (push) Successful in 2m41s
All checks were successful
Build and Deploy / deploy (push) Successful in 2m41s
This commit is contained in:
@@ -7,6 +7,9 @@ import {
|
||||
SearchOrganizationDto,
|
||||
} from '@/types/dto/organization/organization.dto';
|
||||
import { AxiosError } from 'axios';
|
||||
import { organizationService } from '@/lib/services/organization.service';
|
||||
import { projectService } from '@/lib/services/project.service';
|
||||
import { contractService } from '@/lib/services/contract.service';
|
||||
|
||||
export const masterDataKeys = {
|
||||
all: ['masterData'] as const,
|
||||
@@ -15,8 +18,6 @@ export const masterDataKeys = {
|
||||
disciplines: (contractId?: number) => [...masterDataKeys.all, 'disciplines', contractId] as const,
|
||||
};
|
||||
|
||||
import { organizationService } from '@/lib/services/organization.service';
|
||||
|
||||
export function useOrganizations(params?: SearchOrganizationDto) {
|
||||
return useQuery({
|
||||
queryKey: [...masterDataKeys.organizations(), params],
|
||||
@@ -29,30 +30,31 @@ export function useCreateOrganization() {
|
||||
return useMutation({
|
||||
mutationFn: (data: CreateOrganizationDto) => masterDataService.createOrganization(data),
|
||||
onSuccess: () => {
|
||||
toast.success("Organization created successfully");
|
||||
toast.success('Organization created successfully');
|
||||
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
|
||||
},
|
||||
onError: (error: AxiosError<{ message?: string }>) => {
|
||||
toast.error("Failed to create organization", {
|
||||
description: error.response?.data?.message || "Unknown error"
|
||||
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: UpdateOrganizationDto }) => masterDataService.updateOrganization(id, data),
|
||||
mutationFn: ({ id, data }: { id: number; data: UpdateOrganizationDto }) =>
|
||||
masterDataService.updateOrganization(id, data),
|
||||
onSuccess: () => {
|
||||
toast.success("Organization updated successfully");
|
||||
toast.success('Organization updated successfully');
|
||||
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
|
||||
},
|
||||
onError: (error: AxiosError<{ message?: string }>) => {
|
||||
toast.error("Failed to update organization", {
|
||||
description: error.response?.data?.message || "Unknown error"
|
||||
toast.error('Failed to update organization', {
|
||||
description: error.response?.data?.message || 'Unknown error',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,14 +63,14 @@ export function useDeleteOrganization() {
|
||||
return useMutation({
|
||||
mutationFn: (id: number) => masterDataService.deleteOrganization(id),
|
||||
onSuccess: () => {
|
||||
toast.success("Organization deleted successfully");
|
||||
toast.success('Organization deleted successfully');
|
||||
queryClient.invalidateQueries({ queryKey: masterDataKeys.organizations() });
|
||||
},
|
||||
onError: (error: AxiosError<{ message?: string }>) => {
|
||||
toast.error("Failed to delete organization", {
|
||||
description: error.response?.data?.message || "Unknown error"
|
||||
toast.error('Failed to delete organization', {
|
||||
description: error.response?.data?.message || 'Unknown error',
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -79,9 +81,6 @@ export function useDisciplines(contractId?: number) {
|
||||
});
|
||||
}
|
||||
|
||||
// Add useProjects hook
|
||||
import { projectService } from '@/lib/services/project.service';
|
||||
|
||||
export function useProjects(isActive: boolean = true) {
|
||||
return useQuery({
|
||||
queryKey: ['projects', { isActive }],
|
||||
@@ -89,9 +88,6 @@ export function useProjects(isActive: boolean = true) {
|
||||
});
|
||||
}
|
||||
|
||||
// Add useContracts hook
|
||||
import { contractService } from '@/lib/services/contract.service';
|
||||
|
||||
export function useContracts(projectId: number = 1) {
|
||||
return useQuery({
|
||||
queryKey: ['contracts', projectId],
|
||||
|
||||
Reference in New Issue
Block a user