260320:1131 Refactor Overrall #01
Build and Deploy / deploy (push) Has been cancelled

This commit is contained in:
admin
2026-03-20 11:31:27 +07:00
parent f1b81a7d0d
commit 1d3479770b
147 changed files with 1745 additions and 1567 deletions
@@ -32,7 +32,7 @@ export default function MigrationErrorsPage() {
const res = await migrationService.getErrors({ limit: 100 });
setItems(res.items);
} catch (error) {
console.error("Failed to fetch errors", error);
// Failed to fetch errors - loading state handles display
} finally {
setLoading(false);
}
@@ -13,6 +13,7 @@ import {
} from "@/components/ui/table";
import { Checkbox } from "@/components/ui/checkbox";
import { Badge } from "@/components/ui/badge";
import { toast } from "sonner";
import { Button } from "@/components/ui/button";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
import { format } from "date-fns";
@@ -41,7 +42,7 @@ export default function MigrationReviewQueuePage() {
setItems(res.items);
setSelectedIds([]); // reset selection on fetch
} catch (error) {
console.error("Failed to fetch queue", error);
// Failed to fetch queue - loading state handles display
} finally {
setLoading(false);
}
@@ -56,7 +57,7 @@ export default function MigrationReviewQueuePage() {
};
const handleToggleSelect = (id: number) => {
setSelectedIds((prev) =>
setSelectedIds((prev) =>
prev.includes(id) ? prev.filter((i) => i !== id) : [...prev, id]
);
};
@@ -65,7 +66,7 @@ export default function MigrationReviewQueuePage() {
if (selectedIds.length === 0) return;
try {
setSubmitting(true);
const batchItems = items
.filter((i) => selectedIds.includes(i.id))
.map((item) => ({
@@ -94,11 +95,10 @@ export default function MigrationReviewQueuePage() {
{ items: batchItems, batchId },
batchId
);
fetchData();
} catch (error) {
console.error("Batch commit failed", error);
alert("Batch commit failed. See console for details.");
toast.error("Batch commit failed.");
} finally {
setSubmitting(false);
}
@@ -115,12 +115,12 @@ export default function MigrationReviewQueuePage() {
</div>
<div className="flex items-center gap-4">
{selectedIds.length > 0 && (
<Button
variant="default"
onClick={handleBatchApprove}
<Button
variant="default"
onClick={handleBatchApprove}
disabled={submitting}
>
<CheckSquareIcon className="mr-2 h-4 w-4" />
<CheckSquareIcon className="mr-2 h-4 w-4" />
{submitting ? "Processing..." : `Batch Approve (${selectedIds.length})`}
</Button>
)}
@@ -158,7 +158,7 @@ export default function MigrationReviewQueuePage() {
<TableHeader>
<TableRow>
<TableHead className="w-[50px]">
<Checkbox
<Checkbox
checked={items.length > 0 && selectedIds.length === items.length}
onCheckedChange={handleToggleSelectAll}
aria-label="Select all"
@@ -176,7 +176,7 @@ export default function MigrationReviewQueuePage() {
{items.map((item) => (
<TableRow key={item.id}>
<TableCell>
<Checkbox
<Checkbox
checked={selectedIds.includes(item.id)}
onCheckedChange={() => handleToggleSelect(item.id)}
aria-label={`Select item ${item.id}`}
@@ -185,14 +185,14 @@ export default function MigrationReviewQueuePage() {
<TableCell className="font-medium">{item.documentNumber}</TableCell>
<TableCell>{item.aiSuggestedCategory || "Unknown"}</TableCell>
<TableCell>
<Badge
<Badge
variant={
!item.aiConfidence
? "destructive"
: item.aiConfidence > 0.8
? "default"
: item.aiConfidence > 0.5
? "secondary"
!item.aiConfidence
? "destructive"
: item.aiConfidence > 0.8
? "default"
: item.aiConfidence > 0.5
? "secondary"
: "destructive"
}
>
@@ -87,7 +87,6 @@ export default function MigrationReviewPage() {
});
}
} catch (error) {
console.error("Failed to load queue item", error);
toast.error("Failed to load queue item");
} finally {
setLoading(false);
@@ -100,7 +99,7 @@ export default function MigrationReviewPage() {
try {
setSubmitting(true);
const issues = item.aiIssues || {};
const payload = {
document_number: values.document_number,
subject: values.subject,
@@ -123,12 +122,12 @@ export default function MigrationReviewPage() {
// Mock idempotency key based on timestamp to ensure uniqueness per approval retry
const idempotencyKey = `review-${item.id}-${Date.now()}`;
await migrationService.approveQueueItem(item.id, payload, idempotencyKey);
toast.success("Document approved and imported successfully");
router.push("/admin/migration");
} catch (error: any) {
console.error("Failed to approve item", error);
toast.error(error?.response?.data?.message || "Failed to approve and import");
} catch (error: unknown) {
const err = error as { response?: { data?: { message?: string } } };
toast.error(err?.response?.data?.message || "Failed to approve and import");
} finally {
setSubmitting(false);
}
@@ -142,8 +141,7 @@ export default function MigrationReviewPage() {
await migrationService.rejectQueueItem(item.id);
toast.success("Document rejected");
router.push("/admin/migration");
} catch (error: any) {
console.error("Failed to reject item", error);
} catch (error: unknown) {
toast.error("Failed to reject document");
} finally {
setSubmitting(false);
@@ -158,7 +156,7 @@ export default function MigrationReviewPage() {
return <div className="py-10 text-center text-red-500">Document not found</div>;
}
const pdfUrl = item.aiIssues?.source_file_path
const pdfUrl = item.aiIssues?.source_file_path
? migrationService.getStagingFileUrl(item.aiIssues.source_file_path)
: null;
@@ -240,7 +238,7 @@ export default function MigrationReviewPage() {
</FormItem>
)}
/>
<div className="grid grid-cols-2 gap-4">
<FormField
control={form.control}
@@ -343,9 +341,9 @@ export default function MigrationReviewPage() {
<XCircleIcon className="w-4 h-4 mr-2" />
Reject
</Button>
<Button
type="submit"
className="flex-1 bg-green-600 hover:bg-green-700 text-white"
<Button
type="submit"
className="flex-1 bg-green-600 hover:bg-green-700 text-white"
disabled={submitting || item.status !== 'PENDING'}
>
<CheckCircleIcon className="w-4 h-4 mr-2" />
@@ -43,6 +43,12 @@ import Link from "next/link";
import { toast } from "sonner";
import { cn } from "@/lib/utils";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
// Form validation schema
const formSchema = z.object({
correspondenceId: z.string().min(1, "Please select a document"),
@@ -1,5 +1,11 @@
import { CorrespondenceForm } from "@/components/correspondences/form";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
export default function NewCorrespondencePage() {
return (
<div className="max-w-4xl mx-auto py-6">
@@ -1,5 +1,11 @@
import { DrawingUploadForm } from "@/components/drawings/upload-form";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
export default function DrawingUploadPage() {
return (
<div className="max-w-4xl mx-auto py-6">
+1 -1
View File
@@ -69,7 +69,7 @@ export default function ProfilePage() {
reset();
} catch (error) {
toast.error('ไม่สามารถเปลี่ยนรหัสผ่านได้: รหัสผ่านปัจจุบันไม่ถูกต้อง');
console.error('[ProfilePage] onPasswordSubmit:', error);
// Password change failed - toast shown
} finally {
setIsLoading(false);
}
@@ -29,6 +29,12 @@ import {
} from "@/components/ui/card";
import { toast } from "sonner";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
// 1. กำหนด Schema สำหรับตรวจสอบข้อมูล (Validation)
// อ้างอิงจาก Data Dictionary ตาราง projects
const projectSchema = z.object({
@@ -74,7 +80,6 @@ export default function CreateProjectPage() {
try {
// เรียก API สร้างโครงการ (Mockup URL)
// ใน Phase หลัง Backend จะเตรียม Endpoint POST /projects ไว้ให้
console.log("Submitting project data:", data);
// จำลองการส่งข้อมูล (Artificial Delay)
await new Promise((resolve) => setTimeout(resolve, 1000));
@@ -86,7 +91,7 @@ export default function CreateProjectPage() {
router.refresh();
} catch (error) {
toast.error('เกิดข้อผิดพลาดในการสร้างโครงการ');
console.error('[CreateProjectPage]', error);
// Project creation failed - toast shown
} finally {
setIsLoading(false);
}
@@ -1,5 +1,11 @@
import { RFAForm } from "@/components/rfas/form";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
export default function NewRFAPage() {
return (
<div className="max-w-4xl mx-auto py-6">
@@ -8,6 +8,9 @@ import { TransmittalForm } from "@/components/transmittal/transmittal-form";
// Force dynamic rendering to prevent build-time prerendering issues
export const dynamic = 'force-dynamic';
// Ensure this page is never statically generated
export const fetchCache = 'force-no-store';
export default function CreateTransmittalPage() {
return (
<section className="space-y-6 max-w-4xl">