diff --git a/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx b/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx index f11eaf4..f42518e 100644 --- a/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx +++ b/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx @@ -6,10 +6,9 @@ // // Pattern user 2026-05-07: "Thêm mới list ra hết trường dữ liệu giống chỉnh // sửa nhưng trống, mở rộng từng phần. Save header xong mới cho nhập chi tiết." -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' -import { Lock } from 'lucide-react' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Label } from '@/components/ui/Label' @@ -103,6 +102,15 @@ export function PeWorkspaceCreateView({ }, }) + // [D5 anh Kiệt FDC] Auto-chọn quy trình khi danh sách chỉ có 1 lựa chọn → hết nhầm + // "chưa chọn quy trình" (chỉ set khi user chưa tự chọn, giữ lựa chọn thủ công nếu có). + useEffect(() => { + const list = approvalWorkflows.data + if (list && list.length === 1 && !form.approvalWorkflowId) { + setForm(f => ({ ...f, approvalWorkflowId: list[0].id })) + } + }, [approvalWorkflows.data, form.approvalWorkflowId]) + const budgetPayload = { budgetPeriodAmount: form.budgetPeriodAmount > 0 ? form.budgetPeriodAmount : null, } @@ -242,11 +250,6 @@ export function PeWorkspaceCreateView({ {/* Section 2 — Chọn NCC/TP (chỉ Ngân sách editable, còn lại sẽ unlock sau create) */}
- — (sau khi thêm NCC tham gia + chốt winner)} - /> - {/* [S61 Mig 50] b. Ngân sách kỳ này — ô đơn thay picker Budget cũ + toggle nhập tay (module Budget xóa hẳn). Số phân bổ cho RIÊNG phiếu này (row 3 bảng "Tổng hợp ngân sách trình ký"). */} @@ -290,22 +293,9 @@ export function PeWorkspaceCreateView({
- {/* Section 3 — NCC tham gia (locked) */} -
- -
- - {/* Section 4 — Hạng mục + Báo giá (locked) */} -
- -
- - {/* Section 5 — Ý kiến 4 phòng ban (locked + amber hint per Q5 user) */} -
-
- Ý kiến + chữ ký nhập khi duyệt phiếu — vào menu “Duyệt” để ký. -
-
+ {/* [D1 anh Kiệt FDC] Mục 3 (NCC tham gia) / 4 (Hạng mục + Báo giá) / 5 (Ý kiến) ẨN + khỏi form TẠO — chỉ là placeholder "Lưu phiếu trước", gây rối. Mở khóa đầy đủ + ở Detail tabs sau khi tạo phiếu. */} {/* Action bar */} @@ -334,21 +324,3 @@ function Section({ title, children }: { title: string; children: React.ReactNode ) } - -function FormRow({ label, value }: { label: string; value: React.ReactNode }) { - return ( -
- {label} -
{value}
-
- ) -} - -function LockedHint({ text }: { text: string }) { - return ( -
- - {text} -
- ) -} diff --git a/fe-user/src/components/pe/PeWorkspaceCreateView.tsx b/fe-user/src/components/pe/PeWorkspaceCreateView.tsx index f11eaf4..f42518e 100644 --- a/fe-user/src/components/pe/PeWorkspaceCreateView.tsx +++ b/fe-user/src/components/pe/PeWorkspaceCreateView.tsx @@ -6,10 +6,9 @@ // // Pattern user 2026-05-07: "Thêm mới list ra hết trường dữ liệu giống chỉnh // sửa nhưng trống, mở rộng từng phần. Save header xong mới cho nhập chi tiết." -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' -import { Lock } from 'lucide-react' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Label } from '@/components/ui/Label' @@ -103,6 +102,15 @@ export function PeWorkspaceCreateView({ }, }) + // [D5 anh Kiệt FDC] Auto-chọn quy trình khi danh sách chỉ có 1 lựa chọn → hết nhầm + // "chưa chọn quy trình" (chỉ set khi user chưa tự chọn, giữ lựa chọn thủ công nếu có). + useEffect(() => { + const list = approvalWorkflows.data + if (list && list.length === 1 && !form.approvalWorkflowId) { + setForm(f => ({ ...f, approvalWorkflowId: list[0].id })) + } + }, [approvalWorkflows.data, form.approvalWorkflowId]) + const budgetPayload = { budgetPeriodAmount: form.budgetPeriodAmount > 0 ? form.budgetPeriodAmount : null, } @@ -242,11 +250,6 @@ export function PeWorkspaceCreateView({ {/* Section 2 — Chọn NCC/TP (chỉ Ngân sách editable, còn lại sẽ unlock sau create) */}
- — (sau khi thêm NCC tham gia + chốt winner)} - /> - {/* [S61 Mig 50] b. Ngân sách kỳ này — ô đơn thay picker Budget cũ + toggle nhập tay (module Budget xóa hẳn). Số phân bổ cho RIÊNG phiếu này (row 3 bảng "Tổng hợp ngân sách trình ký"). */} @@ -290,22 +293,9 @@ export function PeWorkspaceCreateView({
- {/* Section 3 — NCC tham gia (locked) */} -
- -
- - {/* Section 4 — Hạng mục + Báo giá (locked) */} -
- -
- - {/* Section 5 — Ý kiến 4 phòng ban (locked + amber hint per Q5 user) */} -
-
- Ý kiến + chữ ký nhập khi duyệt phiếu — vào menu “Duyệt” để ký. -
-
+ {/* [D1 anh Kiệt FDC] Mục 3 (NCC tham gia) / 4 (Hạng mục + Báo giá) / 5 (Ý kiến) ẨN + khỏi form TẠO — chỉ là placeholder "Lưu phiếu trước", gây rối. Mở khóa đầy đủ + ở Detail tabs sau khi tạo phiếu. */} {/* Action bar */} @@ -334,21 +324,3 @@ function Section({ title, children }: { title: string; children: React.ReactNode ) } - -function FormRow({ label, value }: { label: string; value: React.ReactNode }) { - return ( -
- {label} -
{value}
-
- ) -} - -function LockedHint({ text }: { text: string }) { - return ( -
- - {text} -
- ) -}