690327:1118 Fixing Refactor ADR-019 Naming convention uuid #14
This commit is contained in:
@@ -12,6 +12,7 @@ import { Loader2 } from 'lucide-react';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useOrganizations, useCorrespondenceTypes, useDisciplines, useContracts } from '@/hooks/use-master-data';
|
||||
import { Organization } from '@/types/organization';
|
||||
import { Contract, getContractPublicId } from '@/types/contract';
|
||||
|
||||
// Local interfaces for Master Data since centralized ones are missing/fragmented
|
||||
interface CorrespondenceType {
|
||||
@@ -47,10 +48,11 @@ export function TemplateTester({ open, onOpenChange, template }: TemplateTesterP
|
||||
const projectId = templateWithProject?.project?.id ?? templateWithProject?.project?.uuid ?? template?.projectId ?? 1;
|
||||
const { data: organizations } = useOrganizations({ isActive: true });
|
||||
const { data: correspondenceTypes } = useCorrespondenceTypes();
|
||||
const { data: contracts } = useContracts(projectId);
|
||||
const { data: contractsData } = useContracts(projectId);
|
||||
const contracts = (Array.isArray(contractsData) ? contractsData : []) as Contract[];
|
||||
|
||||
// Use first contract ID for disciplines, fallback to 1 or undefined
|
||||
const contractId = contracts?.[0]?.id;
|
||||
const contractId = getContractPublicId(contracts[0]);
|
||||
const { data: disciplines } = useDisciplines(contractId);
|
||||
|
||||
const handleGenerate = async () => {
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useProjects } from '@/hooks/use-projects';
|
||||
import { CreateRfaDto } from '@/types/dto/rfa/rfa.dto';
|
||||
import { useState, useEffect, type FormEvent } from 'react';
|
||||
import { correspondenceService } from '@/lib/services/correspondence.service';
|
||||
import { Contract, getContractPublicId } from '@/types/contract';
|
||||
|
||||
const rfaSchema = z.object({
|
||||
projectId: z.string().min(1, 'Project is required'), // ADR-019: UUID
|
||||
@@ -47,8 +48,9 @@ type ProjectOption = {
|
||||
};
|
||||
|
||||
type ContractOption = {
|
||||
publicId?: string;
|
||||
uuid?: string;
|
||||
id?: number;
|
||||
id?: string;
|
||||
contractName?: string;
|
||||
name?: string;
|
||||
contractCode?: string;
|
||||
@@ -182,8 +184,8 @@ export function RFAForm() {
|
||||
const selectedProjectId = watch('projectId');
|
||||
const { data: contractsData, isLoading: isLoadingContracts } = useContracts(selectedProjectId);
|
||||
const contracts = dedupeByKey(
|
||||
extractArrayData<ContractOption>(contractsData),
|
||||
(contract) => contract.uuid ?? contract.id
|
||||
extractArrayData<ContractOption & Contract>(contractsData),
|
||||
(contract) => contract.publicId ?? contract.uuid ?? contract.id
|
||||
);
|
||||
|
||||
const selectedContractId = watch('contractId');
|
||||
@@ -415,7 +417,7 @@ export function RFAForm() {
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{contracts.map((c) => {
|
||||
const contractValue = getOptionValue(c.uuid ?? c.id);
|
||||
const contractValue = getOptionValue(getContractPublicId(c) || c.uuid);
|
||||
|
||||
if (!contractValue) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user