690328:1547 Fixing Refactor uuid by Kimi #10
CI / CD Pipeline / build (push) Successful in 6m16s
CI / CD Pipeline / deploy (push) Failing after 7m15s

This commit is contained in:
2026-03-28 15:47:07 +07:00
parent 3f78f0ec00
commit 57a3ed2d37
29 changed files with 162 additions and 143 deletions
@@ -64,7 +64,7 @@ export function OrganizationDialog({ open, onOpenChange, organization }: Organiz
reset({
organizationCode: organization.organizationCode,
organizationName: organization.organizationName,
roleId: organization.roleId?.toString() || '',
roleId: organization.publicId?.toString() || '',
isActive: organization.isActive,
});
} else {
@@ -80,7 +80,7 @@ export function OrganizationDialog({ open, onOpenChange, organization }: Organiz
const onSubmit = (data: OrganizationFormData) => {
const submitData = {
...data,
roleId: data.roleId ? Number(data.roleId) : undefined,
roleId: data.roleId ? String(data.roleId) : undefined,
};
if (organization) {
@@ -137,7 +137,7 @@ export function RbacMatrix() {
<TableRow>
<TableHead className="w-[300px]">Permission</TableHead>
{roleList.map((role) => (
<TableHead key={role.roleId} className="text-center min-w-[100px]">
<TableHead key={role.publicId} className="text-center min-w-[100px]">
{role.roleName}
</TableHead>
))}
@@ -153,14 +153,14 @@ export function RbacMatrix() {
{roleList.map((role) => {
// Assume role.permissions is populated
const currentRolePerms = role.permissions?.map((p) => p.permissionId) || [];
const activePerms = pendingChanges[role.roleId] || currentRolePerms;
const activePerms = pendingChanges[role.publicId] || currentRolePerms;
const isChecked = activePerms.includes(perm.permissionId);
return (
<TableCell key={`${role.roleId}-${perm.permissionId}`} className="text-center">
<TableCell key={`${role.publicId}-${perm.permissionId}`} className="text-center">
<Checkbox
checked={isChecked}
onCheckedChange={() => handleToggle(role.roleId, perm.permissionId, currentRolePerms)}
onCheckedChange={() => handleToggle(role.publicId, perm.permissionId, currentRolePerms)}
/>
</TableCell>
);
+8 -8
View File
@@ -108,7 +108,7 @@ export function UserDialog({ open, onOpenChange, user }: UserDialogProps) {
isActive: user.isActive,
lineId: user.lineId || '',
primaryOrganizationId: user.primaryOrganizationId?.toString() || ALL_ORGANIZATIONS_VALUE,
roleIds: user.roles?.map((r: { roleId: number }) => r.roleId) || [],
roleIds: user.roles?.map((r: { publicId: string }) => r.publicId) || [],
password: '',
confirmPassword: '',
});
@@ -297,26 +297,26 @@ export function UserDialog({ open, onOpenChange, user }: UserDialogProps) {
<p className="text-sm text-muted-foreground">Loading roles...</p>
)}
{Array.isArray(roles) &&
roles.map((role: { roleId: number; roleName: string; description?: string }) => (
<div key={role.roleId} className="flex items-start space-x-2">
roles.map((role: { publicId: string; roleName: string; description?: string }) => (
<div key={role.publicId} className="flex items-start space-x-2">
<Checkbox
id={`role-${role.roleId}`}
checked={selectedRoleIds.includes(role.roleId)}
id={`role-${role.publicId}`}
checked={selectedRoleIds.includes(role.publicId)}
onCheckedChange={(checked) => {
const current = selectedRoleIds;
if (checked) {
setValue('roleIds', [...current, role.roleId]);
setValue('roleIds', [...current, role.publicId]);
} else {
setValue(
'roleIds',
current.filter((id) => id !== role.roleId)
current.filter((id) => id !== role.publicId)
);
}
}}
/>
<div className="grid gap-1.5 leading-none">
<label
htmlFor={`role-${role.roleId}`}
htmlFor={`role-${role.publicId}`}
className="text-sm font-medium leading-none cursor-pointer"
>
{role.roleName}
@@ -30,14 +30,14 @@ export function TagManager({ uuid, canEdit }: TagManagerProps) {
const assigned: Tag[] = Array.isArray(assignedRaw) ? (assignedRaw as Tag[]) : [];
const allTags: Tag[] = Array.isArray(allTagsRaw) ? (allTagsRaw as Tag[]) : [];
const assignedIds = new Set(assigned.map((t) => t.id));
const available = allTags.filter((t) => !assignedIds.has(t.id));
const assignedIds = new Set(assigned.map((t) => t.publicId));
const available = allTags.filter((t) => !assignedIds.has(t.publicId));
const handleAdd = (tagId: number) => {
const handleAdd = (tagId: number | string) => {
addMutation.mutate({ uuid, tagId });
};
const handleRemove = (tagId: number) => {
const handleRemove = (tagId: number | string) => {
removeMutation.mutate({ uuid, tagId });
};
@@ -71,7 +71,7 @@ export function TagManager({ uuid, canEdit }: TagManagerProps) {
<div className="flex flex-wrap gap-1.5">
{assigned.map((tag) => (
<span
key={tag.id}
key={tag.publicId}
className="inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium border"
style={{
backgroundColor: `${getTagColor(tag.colorCode)}22`,
@@ -86,7 +86,7 @@ export function TagManager({ uuid, canEdit }: TagManagerProps) {
{tag.tagName}
{canEdit && (
<button
onClick={() => handleRemove(tag.id)}
onClick={() => handleRemove(tag.publicId)}
disabled={removeMutation.isPending}
className="ml-0.5 opacity-60 hover:opacity-100 transition-opacity"
>
@@ -110,9 +110,9 @@ export function TagManager({ uuid, canEdit }: TagManagerProps) {
) : (
available.map((tag) => (
<button
key={tag.id}
key={tag.publicId}
className="w-full flex items-center gap-2 p-2 text-xs hover:bg-muted/60 transition-colors text-left"
onClick={() => { handleAdd(tag.id); setIsOpen(false); }}
onClick={() => { handleAdd(tag.publicId); setIsOpen(false); }}
disabled={addMutation.isPending}
>
<span
@@ -14,7 +14,7 @@ export function RevisionHistory({ revisions }: { revisions: DrawingRevision[] })
<div className="space-y-3">
{revisions.map((rev) => (
<div key={rev.revisionId} className="flex items-center justify-between p-3 bg-muted/30 rounded-lg border">
<div key={rev.publicId} className="flex items-center justify-between p-3 bg-muted/30 rounded-lg border">
<div className="flex-1">
<div className="flex items-center gap-3 mb-1">
<Badge variant={rev.isCurrent ? 'default' : 'outline'}>Rev. {rev.revisionNumber}</Badge>
@@ -120,7 +120,7 @@ export function TemplateEditor({
<SelectItem value="__default__">Default (All Types)</SelectItem>
{correspondenceTypes.map((type) => {
return (
<SelectItem key={type.id} value={type.id.toString()}>
<SelectItem key={type.publicId} value={type.publicId.toString()}>
{type.typeCode} - {type.typeName}
</SelectItem>
);
@@ -142,7 +142,7 @@ export function TemplateEditor({
<SelectContent>
<SelectItem value="0">All Disciplines</SelectItem>
{disciplines.map((d) => (
<SelectItem key={d.id} value={d.id.toString()}>
<SelectItem key={d.publicId} value={d.publicId.toString()}>
{d.disciplineCode} - {d.codeNameEn || d.codeNameTh}
</SelectItem>
))}
@@ -158,7 +158,7 @@ export function TemplateTester({ open, onOpenChange, template }: TemplateTesterP
<SelectContent>
<SelectItem value="0">Default (All Types)</SelectItem>
{(correspondenceTypes as CorrespondenceType[])?.map((type) => (
<SelectItem key={type.id} value={type.id.toString()}>
<SelectItem key={type.publicId} value={type.publicId.toString()}>
{type.typeCode} - {type.typeName}
</SelectItem>
))}
@@ -179,7 +179,7 @@ export function TemplateTester({ open, onOpenChange, template }: TemplateTesterP
<SelectContent>
<SelectItem value="0">None</SelectItem>
{(disciplines as Discipline[])?.map((disc) => (
<SelectItem key={disc.id} value={disc.id.toString()}>
<SelectItem key={disc.publicId} value={disc.publicId.toString()}>
{disc.disciplineCode}
</SelectItem>
))}
+20 -18
View File
@@ -26,7 +26,7 @@ const rfaSchema = z.object({
projectId: z.string().min(1, 'Project is required'), // ADR-019: UUID
contractId: z.string().min(1, 'Contract is required'),
disciplineId: z.number({ message: 'Discipline is required' }).min(1, 'Discipline is required'),
rfaTypeId: z.number().min(1, 'Type is required'),
rfaTypeId: z.string().min(1, 'Type is required'), // ADR-019: UUID
subject: z.string().min(5, 'Subject must be at least 5 characters'),
description: z.string().optional(),
body: z.string().optional(),
@@ -53,14 +53,16 @@ type ContractOption = {
};
type DisciplineOption = {
id: number;
publicId: string; // ADR-019: public identifier
id?: number; // Internal INT
disciplineCode: string;
codeNameEn?: string;
codeNameTh?: string;
};
type RfaTypeOption = {
id: number;
publicId: string; // ADR-019: public identifier
id?: number; // Internal INT
typeCode?: string;
typeName?: string;
typeNameEn?: string;
@@ -68,7 +70,7 @@ type RfaTypeOption = {
};
type CorrespondenceTypeOption = {
id: number;
publicId: string; // ADR-019: public identifier
typeCode?: string;
typeName?: string;
};
@@ -164,7 +166,7 @@ export function RFAForm() {
projectId: '',
contractId: '',
disciplineId: 0,
rfaTypeId: 0,
rfaTypeId: '',
subject: '',
description: '',
body: '',
@@ -185,13 +187,13 @@ export function RFAForm() {
const selectedContractId = watch('contractId');
const { data: disciplinesData, isLoading: isLoadingDisciplines } = useDisciplines(selectedContractId);
const disciplines = dedupeByKey(extractArrayData<DisciplineOption>(disciplinesData), (discipline) => discipline.id);
const disciplines = dedupeByKey(extractArrayData<DisciplineOption>(disciplinesData), (discipline) => discipline.publicId);
const { data: rfaTypesData, isLoading: isLoadingRfaTypes } = useRfaTypes(selectedContractId);
const rfaTypes = dedupeByKey(extractArrayData<RfaTypeOption>(rfaTypesData), (rfaType) => rfaType.id);
const rfaTypes = dedupeByKey(extractArrayData<RfaTypeOption>(rfaTypesData), (rfaType) => rfaType.publicId);
const [shopDrawingSearch, setShopDrawingSearch] = useState('');
const [shopDrawingPage, setShopDrawingPage] = useState(1);
const { data: shopDrawingsData, isLoading: isLoadingShopDrawings } = useDrawings('SHOP', {
projectPublicId: selectedProjectId || '',
projectUuid: selectedProjectId || '',
search: shopDrawingSearch,
page: shopDrawingPage,
limit: 10,
@@ -204,7 +206,7 @@ export function RFAForm() {
const [asBuiltDrawingSearch, setAsBuiltDrawingSearch] = useState('');
const [asBuiltDrawingPage, setAsBuiltDrawingPage] = useState(1);
const { data: asBuiltDrawingsData, isLoading: isLoadingAsBuiltDrawings } = useDrawings('AS_BUILT', {
projectPublicId: selectedProjectId || '',
projectUuid: selectedProjectId || '',
search: asBuiltDrawingSearch,
page: asBuiltDrawingPage,
limit: 10,
@@ -220,7 +222,7 @@ export function RFAForm() {
const toOrganizationId = watch('toOrganizationId');
const selectedShopDrawingRevisionIds = watch('shopDrawingRevisionIds') ?? [];
const selectedAsBuiltDrawingRevisionIds = watch('asBuiltDrawingRevisionIds') ?? [];
const selectedRfaType = rfaTypes.find((rfaType) => rfaType.id === rfaTypeId);
const selectedRfaType = rfaTypes.find((rfaType) => rfaType.publicId === rfaTypeId);
const selectedRfaTypeCode = selectedRfaType?.typeCode?.toUpperCase();
const requiresShopDrawings = selectedRfaTypeCode === 'DDW' || selectedRfaTypeCode === 'SDW';
const requiresAsBuiltDrawings = selectedRfaTypeCode === 'ADW';
@@ -254,7 +256,7 @@ export function RFAForm() {
const [preview, setPreview] = useState<{ number: string; isDefaultTemplate: boolean } | null>(null);
useEffect(() => {
if (!selectedProjectId || !rfaCorrespondenceType?.id || !rfaTypeId || !disciplineId || !toOrganizationId) {
if (!selectedProjectId || !rfaCorrespondenceType?.publicId || !rfaTypeId || !disciplineId || !toOrganizationId) {
setPreview(null);
return;
}
@@ -263,7 +265,7 @@ export function RFAForm() {
try {
const res = await correspondenceService.previewNumber({
projectId: selectedProjectId,
typeId: rfaCorrespondenceType.id,
typeId: rfaCorrespondenceType.publicId,
disciplineId,
recipients: [{ organizationId: toOrganizationId, type: 'TO' }],
subject: watch('subject') || 'Preview Subject',
@@ -276,7 +278,7 @@ export function RFAForm() {
const timer = setTimeout(fetchPreview, 500);
return () => clearTimeout(timer);
}, [rfaTypeId, disciplineId, toOrganizationId, selectedProjectId, rfaCorrespondenceType?.id, watch]);
}, [rfaTypeId, disciplineId, toOrganizationId, selectedProjectId, rfaCorrespondenceType?.publicId, watch]);
const onSubmit = (data: RFAFormData) => {
if (requiresShopDrawings && data.shopDrawingRevisionIds?.length === 0) {
@@ -365,7 +367,7 @@ export function RFAForm() {
setValue('projectId', val);
setValue('contractId', '');
setValue('disciplineId', 0);
setValue('rfaTypeId', 0);
setValue('rfaTypeId', '');
setValue('shopDrawingRevisionIds', []);
setValue('asBuiltDrawingRevisionIds', []);
}}
@@ -441,7 +443,7 @@ export function RFAForm() {
</SelectTrigger>
<SelectContent>
{disciplines.map((d) => (
<SelectItem key={d.id} value={String(d.id)}>
<SelectItem key={d.publicId} value={String(d.publicId)}>
{`${d.codeNameEn || d.codeNameTh || d.disciplineCode} (${d.disciplineCode})`}
</SelectItem>
))}
@@ -460,9 +462,9 @@ export function RFAForm() {
<div>
<Label>RFA Type *</Label>
<Select
value={rfaTypeId > 0 ? String(rfaTypeId) : undefined}
value={rfaTypeId || undefined}
onValueChange={(val) => {
setValue('rfaTypeId', Number(val));
setValue('rfaTypeId', val);
setValue('shopDrawingRevisionIds', []);
setValue('asBuiltDrawingRevisionIds', []);
}}
@@ -473,7 +475,7 @@ export function RFAForm() {
</SelectTrigger>
<SelectContent>
{rfaTypes.map((rfaType) => (
<SelectItem key={rfaType.id} value={String(rfaType.id)}>
<SelectItem key={rfaType.publicId} value={String(rfaType.publicId)}>
{`${rfaType.typeCode || 'RFA'} - ${rfaType.typeName || rfaType.typeNameEn || rfaType.typeNameTh || 'Unnamed Type'}`}
</SelectItem>
))}