Files
lcbp3/frontend/hooks/use-response-codes.ts
T
Nattanin ef20839f99 feat(rfa): complete RFA Approval Refactor - all 9 phases (T001-T080)
Phase 1-2: Setup, SQL schema, enums, queue constants, base entities
Phase 3 (US1): ReviewTeam, ReviewTeamMember, ReviewTask, TaskCreationService
Phase 4 (US2): ResponseCode, ResponseCodeRule, ImplicationsService, NotificationTriggerService
Phase 5 (US3): Delegation entity, CircularDetectionService, DelegationService/Controller/Module
Phase 6 (US4): ReminderRule, SchedulerService, EscalationService, ReminderProcessor, ReminderModule
Phase 7 (US5): DistributionMatrix, DistributionRecipient, ApprovalListenerService (Strangler),
               TransmittalCreatorService, DistributionProcessor, DistributionModule
Phase 8 (US6): MatrixManagementService, InheritanceService (global→project override)
Phase 9 (Polish): AggregateStatusService, ConsensusService, VetoOverrideService,
                  ParallelGatewayHandler, review-validators, optimistic locking in completeReview,
                  test stubs (unit/integration/e2e), jest.config.js updated for tests/ directory

Frontend: ReviewTaskInbox, ParallelProgress, VetoOverrideDialog, DelegationForm,
          DelegatedBadge, MatrixEditor, ProjectOverrideManager, DistributionStatus,
          ReminderHistory, ResponseCodeSelector, CodeImplications, CompleteReviewForm,
          ReviewTeamForm, ReviewTeamSelector, TeamMemberManager

Closes #1
2026-05-12 16:17:27 +07:00

46 lines
1.5 KiB
TypeScript

// File: hooks/use-response-codes.ts
import { useQuery } from '@tanstack/react-query';
import apiClient from '@/lib/api/client';
import { ResponseCode, ResponseCodeCategory } from '@/types/review-team';
export const responseCodeKeys = {
all: ['responseCodes'] as const,
byCategory: (cat: ResponseCodeCategory) => [...responseCodeKeys.all, 'category', cat] as const,
byDocType: (docTypeId: number, projectId?: number) =>
[...responseCodeKeys.all, 'docType', docTypeId, projectId] as const,
};
export function useResponseCodes() {
return useQuery({
queryKey: responseCodeKeys.all,
queryFn: async (): Promise<ResponseCode[]> => {
const res = await apiClient.get('/response-codes');
return res.data;
},
});
}
export function useResponseCodesByCategory(category: ResponseCodeCategory) {
return useQuery({
queryKey: responseCodeKeys.byCategory(category),
queryFn: async (): Promise<ResponseCode[]> => {
const res = await apiClient.get(`/response-codes/category/${category}`);
return res.data;
},
enabled: !!category,
});
}
export function useResponseCodesByDocType(documentTypeId: number, projectId?: number) {
return useQuery({
queryKey: responseCodeKeys.byDocType(documentTypeId, projectId),
queryFn: async (): Promise<ResponseCode[]> => {
const res = await apiClient.get(`/response-codes/document-type/${documentTypeId}`, {
params: projectId ? { projectId } : undefined,
});
return res.data;
},
enabled: !!documentTypeId,
});
}