251212:1650 Frontend: refactor Document Numbering)
Some checks failed
Spec Validation / validate-markdown (push) Has been cancelled
Spec Validation / validate-diagrams (push) Has been cancelled
Spec Validation / check-todos (push) Has been cancelled

This commit is contained in:
admin
2025-12-12 16:50:52 +07:00
parent 2473c4c474
commit d964546c8d
16 changed files with 233 additions and 14925 deletions

View File

@@ -33,6 +33,7 @@
"alefragnani.bookmarks",
"pkief.material-icon-theme",
"github.copilot",
"bierner.markdown-mermaid"
"bierner.markdown-mermaid",
"vitest.explorer"
]
}

View File

@@ -0,0 +1 @@

9656
backend/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -121,12 +121,18 @@ export class CorrespondenceService {
try {
const orgCode = 'ORG'; // TODO: Fetch real ORG Code from Organization Entity
// Extract recipient organization from details
const recipientOrganizationId = createDto.details?.to_organization_id as
| number
| undefined;
const docNumber = await this.numberingService.generateNextNumber({
projectId: createDto.projectId,
originatorId: userOrgId,
typeId: createDto.typeId,
disciplineId: createDto.disciplineId,
subTypeId: createDto.subTypeId,
recipientOrganizationId, // [v1.5.1] Pass recipient for document number format
year: new Date().getFullYear(),
customTokens: {
TYPE_CODE: type.typeCode,

View File

@@ -298,7 +298,7 @@ export class DocumentNumberingService implements OnModuleInit, OnModuleDestroy {
where: { projectId, correspondenceTypeId: typeId },
});
// Default Fallback Format (ตาม Req 2.1)
return format ? format.formatTemplate : '{ORG}-{ORG}-{SEQ:4}-{YEAR}';
return format ? format.formatTemplate : '{ORG}-{RECIPIENT}-{SEQ:4}-{YEAR}';
}
/**

View File

@@ -19,13 +19,16 @@ import { useRouter } from "next/navigation";
import { Loader2 } from "lucide-react";
import { useCreateCorrespondence, useUpdateCorrespondence } from "@/hooks/use-correspondence";
import { Organization } from "@/types/organization";
import { useOrganizations } from "@/hooks/use-master-data";
import { useOrganizations, useProjects, useCorrespondenceTypes, useDisciplines } from "@/hooks/use-master-data";
import { CreateCorrespondenceDto } from "@/types/dto/correspondence/create-correspondence.dto";
// Updated Zod Schema with all required fields
const correspondenceSchema = z.object({
projectId: z.number().min(1, "Please select a Project"),
documentTypeId: z.number().min(1, "Please select a Document Type"),
disciplineId: z.number().optional(),
subject: z.string().min(5, "Subject must be at least 5 characters"),
description: z.string().optional(),
documentTypeId: z.number(),
fromOrganizationId: z.number().min(1, "Please select From Organization"),
toOrganizationId: z.number().min(1, "Please select To Organization"),
importance: z.enum(["NORMAL", "HIGH", "URGENT"]),
@@ -37,15 +40,22 @@ type FormData = z.infer<typeof correspondenceSchema>;
export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?: number }) {
const router = useRouter();
const createMutation = useCreateCorrespondence();
const updateMutation = useUpdateCorrespondence(); // Add this hook
const updateMutation = useUpdateCorrespondence();
// Fetch master data for dropdowns
const { data: projects, isLoading: isLoadingProjects } = useProjects();
const { data: organizations, isLoading: isLoadingOrgs } = useOrganizations();
const { data: correspondenceTypes, isLoading: isLoadingTypes } = useCorrespondenceTypes();
const { data: disciplines, isLoading: isLoadingDisciplines } = useDisciplines();
// Extract initial values if editing
const currentRev = initialData?.revisions?.find((r: any) => r.isCurrent) || initialData?.revisions?.[0];
const defaultValues: Partial<FormData> = {
projectId: initialData?.projectId || undefined,
documentTypeId: initialData?.correspondenceTypeId || undefined,
disciplineId: initialData?.disciplineId || undefined,
subject: currentRev?.title || "",
description: currentRev?.description || "",
documentTypeId: initialData?.correspondenceTypeId || 1,
fromOrganizationId: initialData?.originatorId || undefined,
toOrganizationId: currentRev?.details?.to_organization_id || undefined,
importance: currentRev?.details?.importance || "NORMAL",
@@ -55,21 +65,25 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
register,
handleSubmit,
setValue,
watch, // Watch values to control Select value props if needed, or rely on RHF
watch,
formState: { errors },
} = useForm<FormData>({
resolver: zodResolver(correspondenceSchema),
defaultValues: defaultValues as any,
});
// Watch for controlled inputs to set value in Select components if needed for better UX
// Watch for controlled inputs
const projectId = watch("projectId");
const documentTypeId = watch("documentTypeId");
const disciplineId = watch("disciplineId");
const fromOrgId = watch("fromOrganizationId");
const toOrgId = watch("toOrganizationId");
const onSubmit = (data: FormData) => {
const payload: CreateCorrespondenceDto = {
projectId: 1,
projectId: data.projectId,
typeId: data.documentTypeId,
disciplineId: data.disciplineId,
title: data.subject,
description: data.description,
originatorId: data.fromOrganizationId,
@@ -96,6 +110,79 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
return (
<form onSubmit={handleSubmit(onSubmit)} className="max-w-3xl space-y-6">
{/* Document Metadata Section */}
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
{/* Project Dropdown */}
<div className="space-y-2">
<Label>Project *</Label>
<Select
onValueChange={(v) => setValue("projectId", parseInt(v))}
value={projectId ? String(projectId) : undefined}
disabled={isLoadingProjects}
>
<SelectTrigger>
<SelectValue placeholder={isLoadingProjects ? "Loading..." : "Select Project"} />
</SelectTrigger>
<SelectContent>
{(projects || []).map((p: any) => (
<SelectItem key={p.id} value={String(p.id)}>
{p.projectName} ({p.projectCode})
</SelectItem>
))}
</SelectContent>
</Select>
{errors.projectId && (
<p className="text-sm text-destructive">{errors.projectId.message}</p>
)}
</div>
{/* Document Type Dropdown */}
<div className="space-y-2">
<Label>Document Type *</Label>
<Select
onValueChange={(v) => setValue("documentTypeId", parseInt(v))}
value={documentTypeId ? String(documentTypeId) : undefined}
disabled={isLoadingTypes}
>
<SelectTrigger>
<SelectValue placeholder={isLoadingTypes ? "Loading..." : "Select Type"} />
</SelectTrigger>
<SelectContent>
{(correspondenceTypes || []).map((t: any) => (
<SelectItem key={t.id} value={String(t.id)}>
{t.typeName} ({t.typeCode})
</SelectItem>
))}
</SelectContent>
</Select>
{errors.documentTypeId && (
<p className="text-sm text-destructive">{errors.documentTypeId.message}</p>
)}
</div>
{/* Discipline Dropdown (Optional) */}
<div className="space-y-2">
<Label>Discipline</Label>
<Select
onValueChange={(v) => setValue("disciplineId", v ? parseInt(v) : undefined)}
value={disciplineId ? String(disciplineId) : undefined}
disabled={isLoadingDisciplines}
>
<SelectTrigger>
<SelectValue placeholder={isLoadingDisciplines ? "Loading..." : "Select Discipline (Optional)"} />
</SelectTrigger>
<SelectContent>
{(disciplines || []).map((d: any) => (
<SelectItem key={d.id} value={String(d.id)}>
{d.codeNameEn || d.disciplineCode}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
</div>
{/* Subject */}
<div className="space-y-2">
<Label htmlFor="subject">Subject *</Label>
<Input id="subject" {...register("subject")} placeholder="Enter subject" />
@@ -104,6 +191,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
)}
</div>
{/* Description */}
<div className="space-y-2">
<Label htmlFor="description">Description</Label>
<Textarea
@@ -114,6 +202,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
/>
</div>
{/* Organizations */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2">
<Label>From Organization *</Label>
@@ -126,7 +215,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
<SelectValue placeholder={isLoadingOrgs ? "Loading..." : "Select Organization"} />
</SelectTrigger>
<SelectContent>
{organizations?.map((org: Organization) => (
{(organizations || []).map((org: Organization) => (
<SelectItem key={org.id} value={String(org.id)}>
{org.organizationName} ({org.organizationCode})
</SelectItem>
@@ -149,7 +238,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
<SelectValue placeholder={isLoadingOrgs ? "Loading..." : "Select Organization"} />
</SelectTrigger>
<SelectContent>
{organizations?.map((org: Organization) => (
{(organizations || []).map((org: Organization) => (
<SelectItem key={org.id} value={String(org.id)}>
{org.organizationName} ({org.organizationCode})
</SelectItem>
@@ -162,6 +251,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
</div>
</div>
{/* Importance */}
<div className="space-y-2">
<Label>Importance</Label>
<div className="flex gap-6 mt-2">
@@ -195,6 +285,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
</div>
</div>
{/* Attachments (only for new documents) */}
{!initialData && (
<div className="space-y-2">
<Label>Attachments</Label>
@@ -206,6 +297,7 @@ export function CorrespondenceForm({ initialData, id }: { initialData?: any, id?
</div>
)}
{/* Actions */}
<div className="flex justify-end gap-4 pt-6 border-t">
<Button type="button" variant="outline" onClick={() => router.back()}>
Cancel

View File

@@ -39,10 +39,10 @@ export function CorrespondenceList({ data }: CorrespondenceListProps) {
),
},
{
accessorKey: "correspondence.originator.orgName",
accessorKey: "correspondence.originator.organizationCode",
header: "From",
cell: ({ row }) => (
<span>{row.original.correspondence?.originator?.orgName || '-'}</span>
<span className="font-medium">{row.original.correspondence?.originator?.organizationCode || '-'}</span>
),
},
{

View File

@@ -99,3 +99,9 @@ export function useContracts(projectId: number = 1) {
});
}
export function useCorrespondenceTypes() {
return useQuery({
queryKey: masterDataKeys.correspondenceTypes(),
queryFn: () => masterDataService.getCorrespondenceTypes(),
});
}

View File

@@ -1,53 +0,0 @@
import { Correspondence, CreateCorrespondenceDto } from "@/types/correspondence";
// Mock Data
const mockCorrespondences: Correspondence[] = [
{
correspondenceId: 1,
documentNumber: "PAT-CNPC-0001-2568",
subject: "Request for Additional Information",
description: "Please provide updated structural drawings for Phase 2",
status: "IN_REVIEW",
importance: "HIGH",
createdAt: new Date(Date.now() - 1000 * 60 * 60 * 24 * 2).toISOString(),
updatedAt: new Date(Date.now() - 1000 * 60 * 60).toISOString(),
fromOrganizationId: 1,
toOrganizationId: 2,
documentTypeId: 1,
fromOrganization: { id: 1, orgName: "PAT", orgCode: "PAT" },
toOrganization: { id: 2, orgName: "CNPC", orgCode: "CNPC" },
attachments: [],
},
];
export const correspondenceApi = {
getAll: async (): Promise<{ data: Correspondence[]; meta: { total: number } }> => {
await new Promise((resolve) => setTimeout(resolve, 500));
return { data: mockCorrespondences, meta: { total: mockCorrespondences.length } };
},
getById: async (id: number): Promise<Correspondence | undefined> => {
await new Promise((resolve) => setTimeout(resolve, 300));
return mockCorrespondences.find((c) => c.correspondenceId === id);
},
create: async (data: CreateCorrespondenceDto): Promise<Correspondence> => {
await new Promise((resolve) => setTimeout(resolve, 800));
const newCorrespondence: Correspondence = {
correspondenceId: Math.max(...mockCorrespondences.map((c) => c.correspondenceId)) + 1,
documentNumber: `PAT-CNPC-${String(mockCorrespondences.length + 1).padStart(4, "0")}-2568`,
subject: data.subject,
description: data.description,
status: "DRAFT",
importance: data.importance,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
fromOrganizationId: data.fromOrganizationId,
toOrganizationId: data.toOrganizationId,
documentTypeId: data.documentTypeId,
attachments: [],
};
mockCorrespondences.push(newCorrespondence);
return newCorrespondence;
},
};

View File

@@ -39,18 +39,19 @@ describe('correspondenceService', () => {
describe('getById', () => {
it('should call GET /correspondences/:id', async () => {
const mockResponse = { id: 1, title: 'Test' };
vi.mocked(apiClient.get).mockResolvedValue({ data: mockResponse });
const mockData = { id: 1, title: 'Test' };
// Service expects response.data.data (NestJS interceptor wrapper)
vi.mocked(apiClient.get).mockResolvedValue({ data: { data: mockData } });
const result = await correspondenceService.getById(1);
expect(apiClient.get).toHaveBeenCalledWith('/correspondences/1');
expect(result).toEqual(mockResponse);
expect(result).toEqual(mockData);
});
it('should work with string id', async () => {
const mockResponse = { id: 1 };
vi.mocked(apiClient.get).mockResolvedValue({ data: mockResponse });
const mockData = { id: 1 };
vi.mocked(apiClient.get).mockResolvedValue({ data: { data: mockData } });
await correspondenceService.getById('123');

View File

@@ -10,7 +10,8 @@
"format": "prettier --write .",
"test": "vitest",
"test:watch": "vitest --watch",
"test:coverage": "vitest run --coverage"
"test:coverage": "vitest run --coverage",
"test:debug": "vitest --inspect-brk --no-file-parallelism"
},
"dependencies": {
"@hookform/resolvers": "^5.2.2",

5076
frontend/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
export interface Organization {
id: number;
orgName: string;
orgCode: string;
organizationName: string;
organizationCode: string;
}
export interface Attachment {

View File

@@ -17,7 +17,9 @@
"editor.rulers": [80, 120],
"editor.minimap.enabled": true,
"editor.minimap.sectionHeaderFontSize": 14,
"editor.renderWhitespace": "boundary",
"editor.renderWhitespace": "selection",
// "editor.renderWhitespace": "boundary",
"editor.renderControlCharacters": true,
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": "active",
"editor.smoothScrolling": true,
@@ -71,7 +73,7 @@
"editor.defaultFormatter": "redhat.vscode-yaml"
},
"[dockerfile]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "ms-azuretools.vscode-containers"
},
"[sql]": {
"editor.defaultFormatter": "mtxr.sqltools",
@@ -168,7 +170,7 @@
"@/*": "${workspaceFolder:🎨 Frontend}/app/*",
"@app": "${workspaceFolder:🎨 Frontend}/app",
"@components": "${workspaceFolder:🎨 Frontend}/components",
"@config": "${workspaceFolder:🎨 Frontend}/config",
"@fe-config": "${workspaceFolder:🎨 Frontend}/config",
"@lib": "${workspaceFolder:🎨 Frontend}/lib",
"@hooks": "${workspaceFolder:🎨 Frontend}/app/hooks",
"@utils": "${workspaceFolder:🎨 Frontend}/utils",
@@ -377,10 +379,7 @@
"typescript.inlayHints.variableTypes.enabled": false,
"typescript.inlayHints.propertyDeclarationTypes.enabled": true,
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.tsdk": {
"backend": "backend/node_modules/typescript/lib",
"frontend": "frontend/node_modules/typescript/lib"
},
"typescript.tsdk": "node_modules/typescript/lib", // ✅ ใช้ relative path
// ========================================
// EMMET
// ========================================
@@ -400,6 +399,7 @@
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.encoding": "utf8",
"files.autoGuessEncoding": true,
"files.eol": "\n",
"files.associations": {
"*.css": "tailwindcss",
@@ -460,14 +460,15 @@
"terminal.integrated.smoothScrolling": true,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.fontFamily": "MesloLGS NF, Consolas, monospace",
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.tabs.defaultColor": "terminal.ansiBlue",
"terminal.integrated.defaultProfile.windows": "PowerShell-7",
"terminal.integrated.profiles.windows": {
"PowerShell-7": {
"path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
"icon": "terminal-powershell"
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell-7",
"terminal.integrated.cwd": "${workspaceFolder}",
// ========================================
// WORKBENCH
@@ -540,12 +541,7 @@
// กำหนด path ของ Jest ถ้าใช้ local install
"jest.pathToJest": "node_modules/.bin/jest",
// กำหนด config ของ Jest ถ้ามีไฟล์ jest.config.js
"jest.pathToConfig": {
"backend": "backend/jest.config.js",
"frontend": "frontend/jest.config.js"
},
"jest.disabledWorkspaceFolders": ["🎯 Root", "🗓️ docs", "🔗 specs"],
"jest.disabledWorkspaceFolders": ["🎯 Root", "🗓️ docs", "🔗 specs", "🎨 Frontend"],
// ========================================
// DOCKER
@@ -589,16 +585,6 @@
}
},
// ========================================
// CONSOLE NINJA
// ========================================
"console-ninja.featureSet": "Community",
"console-ninja.toolsToEnableSupportAutomaticallyFor": {
"live-server-extension": true,
"live-preview-extension": true
},
// ========================================
// MATERIAL ICON THEME
// ========================================
@@ -645,14 +631,14 @@
// DEBUGGING
// ========================================
"debug.console.fontSize": 13,
"debug.console.lineHeight": 1.2,
"debug.console.fontSize": 14,
"debug.console.fontFamily": "Consolas, 'Courier New', monospace",
"debug.console.lineHeight": 20,
"debug.console.wordWrap": false,
"debug.internalConsoleOptions": "openOnSessionStart",
"debug.openDebug": "openOnDebugBreak",
"debug.showBreakpointsInOverviewRuler": true,
"prettier.configPath": "./.prettierrc",
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.tabs.defaultColor": "terminal.ansiBlue",
"sqltools.connections": [
{
"mysqlOptions": {
@@ -667,13 +653,17 @@
"name": "lcbp3_dev",
"database": "lcbp3_dev",
"username": "root",
"password": "Center#2025"
"password": "",
"askForPassword": true // ✅ ปลอดภัยกว่า
}
],
"database-client.variableIndicator": [":", "$"],
"geminicodeassist.rules": "ใช้ภาษาไทยในการโต้ตอบ\n\n\n\n",
"geminicodeassist.verboseLogging": true,
"liveServer.settings.multiRootWorkspaceName": "🎯 Root"
"liveServer.settings.multiRootWorkspaceName": "🎯 Root",
"vitest.commandLine": "npm run test --",
"vitest.enable": true,
"yaml.maxItemsComputed": 6000
},
// ========================================
// LAUNCH CONFIGURATIONS
@@ -682,40 +672,42 @@
"version": "0.2.0",
"configurations": [
{
"name": "🔧 Debug Backend",
"name": "🔧 Debug Backend (NestJS)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "start:debug"],
"cwd": "${workspaceFolder:🔧 Backend}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
// "internalConsoleOptions": "neverOpen",
"skipFiles": ["<node_internals>/**"],
"sourceMaps": true,
"restart": true
},
{
"name": "🎨 Debug Frontend",
"type": "chrome",
"name": "🎨 Debug Frontend (Next.js)",
"type": "node",
"request": "launch",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder:🎨 Frontend}",
"sourceMapPathOverrides": {
"webpack:///./*": "${webRoot}/*"
"cwd": "${workspaceFolder:🎨 Frontend}",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "dev"],
"serverReadyAction": {
"pattern": "- Local:.+(https?://\\S+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
},
{
"name": "🧪 Debug Jest Tests (Backend)",
"name": "🧪 Debug Backend Tests (Jest)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": ["run", "test:debug"],
"cwd": "${workspaceFolder:🔧 Backend}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
"console": "integratedTerminal"
},
{
"name": "🧪 Debug Jest Tests (Frontend)",
"name": "🧪 Debug Frontend Tests (Vitest)",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
@@ -725,10 +717,11 @@
"internalConsoleOptions": "neverOpen"
}
],
"compounds": [
{
"name": "🚀 Debug Full Stack",
"configurations": ["🔧 Debug Backend", "🎨 Debug Frontend"],
"configurations": ["🔧 Debug Backend (NestJS)", "🎨 Debug Frontend (Next.js)"],
"stopAll": true
}
]
@@ -741,10 +734,13 @@
"tasks": [
{
"label": "🔧 Start Backend Dev",
"type": "npm",
"script": "start:dev",
"path": "backend/",
"type": "shell",
"command": "npm run start:dev",
"options": {
"cwd": "${workspaceFolder:🔧 Backend}"
},
"problemMatcher": [],
"isBackground": true,
"presentation": {
"reveal": "always",
"panel": "dedicated",
@@ -753,10 +749,13 @@
},
{
"label": "🎨 Start Frontend Dev",
"type": "npm",
"script": "dev",
"path": "frontend/",
"type": "shell",
"command": "npm run dev",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}"
},
"problemMatcher": [],
"isBackground": true,
"presentation": {
"reveal": "always",
"panel": "dedicated",
@@ -770,23 +769,49 @@
},
{
"label": "🧪 Run Backend Tests",
"type": "npm",
"script": "test",
"path": "backend/",
"type": "shell",
"command": "npm run test",
"options": {
"cwd": "${workspaceFolder:🔧 Backend}"
},
"problemMatcher": []
},
{
"label": "🧪 Run Frontend Tests",
"type": "npm",
"script": "test",
"path": "frontend/",
"type": "shell",
"command": "npm run test",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}"
},
"problemMatcher": []
},
{
"label": "🧪 Watch Backend Tests",
"type": "shell",
"command": "npm run test:watch",
"options": {
"cwd": "${workspaceFolder:🔧 Backend}"
},
"problemMatcher": [],
"isBackground": true
},
{
"label": "🧪 Watch Frontend Tests",
"type": "shell",
"command": "npm run test:watch",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}"
},
"problemMatcher": [],
"isBackground": true
},
{
"label": "🏗️ Build Backend",
"type": "npm",
"script": "build",
"path": "backend/",
"type": "shell",
"command": "npm run build",
"options": {
"cwd": "${workspaceFolder:🔧 Backend}"
},
"problemMatcher": ["$tsc"],
"group": {
"kind": "build",
@@ -795,9 +820,11 @@
},
{
"label": "🏗️ Build Frontend",
"type": "npm",
"script": "build",
"path": "frontend/",
"type": "shell",
"command": "npm run build",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}"
},
"problemMatcher": ["$tsc"],
"group": {
"kind": "build",
@@ -806,16 +833,20 @@
},
{
"label": "🔍 Lint Backend",
"type": "npm",
"script": "lint",
"path": "backend/",
"type": "shell",
"command": "npm run lint",
"options": {
"cwd": "${workspaceFolder:🔧 Backend}"
},
"problemMatcher": ["$eslint-stylish"]
},
{
"label": "🔍 Lint Frontend",
"type": "npm",
"script": "lint",
"path": "frontend/",
"type": "shell",
"command": "npm run lint",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}"
},
"problemMatcher": ["$eslint-stylish"]
},
{
@@ -829,52 +860,6 @@
"type": "shell",
"command": "docker-compose down",
"problemMatcher": []
},
// 1. Task หลักที่จะรันอัตโนมัติเมื่อเปิดโปรแกรม
{
"label": "🚀 Setup Workspace",
"dependsOn": ["🔧 PS: Backend", "🎨 PS: Frontend"], // สั่งให้รัน 2 task ย่อย
"runOptions": {
"runOn": "folderOpen" // <--- คำสั่งศักดิ์สิทธิ์: รันทันทีที่เปิด VS Code
},
"presentation": {
"reveal": "never" // ไม่ต้องโชว์หน้าต่างของตัวคุมหลัก
},
"problemMatcher": []
},
// 2. Task ย่อย: เปิด Terminal ที่ Backend
{
"label": "🔧 PS: Backend",
"type": "shell",
"command": "powershell", // สั่งเปิด PowerShell ค้างไว้
"options": {
"cwd": "${workspaceFolder:🔧 Backend}" // cd เข้า folder นี้
},
"isBackground": true, // บอก VS Code ว่าไม่ต้องรอให้จบ (รันค้างไว้เลย)
"problemMatcher": [],
"presentation": {
"group": "workspace-terminals", // จัดกลุ่มเดียวกัน
"reveal": "always",
"panel": "dedicated", // แยก Tab ให้ชัดเจน
"focus": false // ไม่ต้องแย่ง Focus ทันที
}
},
// 3. Task ย่อย: เปิด Terminal ที่ Frontend
{
"label": "🎨 PS: Frontend",
"type": "shell",
"command": "powershell",
"options": {
"cwd": "${workspaceFolder:🎨 Frontend}" // cd เข้า folder นี้
},
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "workspace-terminals",
"reveal": "always",
"panel": "dedicated",
"focus": true // ให้ Focus ที่อันนี้เป็นอันสุดท้าย (พร้อมพิมพ์)
}
}
]
}

View File

@@ -1,6 +1,6 @@
# Backend Progress Report
**Date:** 2025-12-10
**Date:** 2025-12-12
**Status:****Advanced / Nearly Complete (~95%)**
## 📊 Overview
@@ -10,7 +10,7 @@
| **TASK-BE-001** | Database Migrations | ✅ **Done** | 100% | Schema v1.5.1 active. TypeORM configured. |
| **TASK-BE-002** | Auth & RBAC | ✅ **Done** | 100% | JWT, Refresh Token, RBAC Guard, Permissions complete. |
| **TASK-BE-003** | File Storage | ✅ **Done** | 100% | MinIO/S3 strategies implemented (in `common`). |
| **TASK-BE-004** | Document Numbering | ✅ **Done** | 100% | **High Quality**: Redlock + Optimistic Locking logic. |
| **TASK-BE-004** | Document Numbering | ✅ **Done** | 100% | Redlock + Optimistic Lock. `{RECIPIENT}` token fix (2025-12-12). |
| **TASK-BE-005** | Correspondence Module | ✅ **Done** | 95% | CRUD, Workflow Submit, References, Audit Log complete. |
| **TASK-BE-006** | Workflow Engine | ✅ **Done** | 100% | DSL Evaluator, Versioning, Event Dispatching complete. |
| **TASK-BE-007** | RFA Module | ✅ **Done** | 95% | Full Swagger, Revision handling, Workflow integration. |

View File

@@ -1,6 +1,6 @@
# Frontend Progress Report
**Date:** 2025-12-11
**Date:** 2025-12-12
**Status:****Complete (~100%)**
## 📊 Overview
@@ -10,7 +10,7 @@
| **TASK-FE-001** | Frontend Setup | ✅ **Done** | 100% | Project structure, Tailwind, Shadcn/UI initialized. |
| **TASK-FE-002** | Auth UI | ✅ **Done** | 100% | Store, RBAC, Login UI, Refresh Token, Session Sync implemented. |
| **TASK-FE-003** | Layout & Navigation | ✅ **Done** | 100% | Sidebar, Header, Layouts are implemented. |
| **TASK-FE-004** | Correspondence UI | ✅ **Done** | 100% | Refactored to Revision-based List. Edit/View fully functional. |
| **TASK-FE-004** | Correspondence UI | ✅ **Done** | 100% | Form enhanced with Project/Type/Discipline dropdowns (2025-12-12). |
| **TASK-FE-005** | Common Components | ✅ **Done** | 100% | Data tables, File upload, etc. implemented. |
| **TASK-FE-006** | RFA UI | ✅ **Done** | 100% | Integrated with Backend (Workflow/Create/List). |
| **TASK-FE-007** | Drawing UI | ✅ **Done** | 100% | Drawings List & Upload integrated with Real API (Contract/Shop). |
@@ -44,7 +44,7 @@
### 3. Business Modules (✅ Completed)
- **Correspondences:** Refactored List to show "One Row per Revision". Detail and Edit pages fully integrated with Backend API.
- **Correspondences:** Form enhanced with Project/Type/Discipline dropdowns. `organizationCode` column fix. Document numbering `{RECIPIENT}` token fix (2025-12-12).
- **RFAs:** List and Form UI components integrated.
- **Drawings:** List and Upload integrated.
- **Integration:** All modules using `tanstack-query` and aligned with Backend DTOs.