diff --git a/src/components/DashboardPage/DashboardPage.tsx b/src/components/DashboardPage/DashboardPage.tsx index ed96321..a143102 100644 --- a/src/components/DashboardPage/DashboardPage.tsx +++ b/src/components/DashboardPage/DashboardPage.tsx @@ -29,7 +29,11 @@ const DashboardPage: React.FC = ({ const { t } = useTranslation("dashboard"); const router = useRouter(); - const [escLog, setEscLog] = useState([]) + const [escLog, setEscLog] = useState([]); + + const getPendingLog = () => { + return escLog.filter(esc => esc.status == "pending"); + }; useEffect(() => { setEscLog(escalationLogs); @@ -39,7 +43,11 @@ const DashboardPage: React.FC = ({ - + 0 ? getPendingLog().length : t("No")})`} + // defaultOpen={getPendingLog().length > 0} // TODO Fix default not opening + > diff --git a/src/components/PoDetail/EscalationComponent.tsx b/src/components/PoDetail/EscalationComponent.tsx index f363dbf..30e215c 100644 --- a/src/components/PoDetail/EscalationComponent.tsx +++ b/src/components/PoDetail/EscalationComponent.tsx @@ -71,15 +71,6 @@ const EscalationComponent: React.FC = ({ fetchData(); }, []) - const nameOptions: NameOption[] = [ - { value: '', label: '請選擇姓名...' }, - { value: 'john', label: '張大明' }, - { value: 'jane', label: '李小美' }, - { value: 'mike', label: '王志強' }, - { value: 'sarah', label: '陳淑華' }, - { value: 'david', label: '林建國' }, - ]; - const { register, formState: { errors, defaultValues, touchedFields }, @@ -232,7 +223,7 @@ const EscalationComponent: React.FC = ({ id="reason" // name="reason" {...register("escalationLog.reason", { - required: "reason required!", + required: "請輸入上報原因", })} label="上報原因" multiline @@ -240,6 +231,8 @@ const EscalationComponent: React.FC = ({ // value={formData.reason} onChange={handleInputChange} placeholder="請輸入上報原因" + error={Boolean(errors.escalationLog?.reason)} + helperText={errors.escalationLog?.reason?.message} /> {/* diff --git a/src/components/PoDetail/QcStockInModalVer2.tsx b/src/components/PoDetail/QcStockInModalVer2.tsx index 145cc89..0b29914 100644 --- a/src/components/PoDetail/QcStockInModalVer2.tsx +++ b/src/components/PoDetail/QcStockInModalVer2.tsx @@ -301,15 +301,19 @@ const [qcItems, setQcItems] = useState(dummyQCData) console.log("QC Data for submission:", qcData); if (data.qcDecision == 3) { // Escalate + if (data.escalationLog?.handlerId == undefined) { alert("請選擇上報負責同事!"); return; } + else if (data.escalationLog?.handlerId < 1) { alert("上報負責同事資料有誤"); return; } + const escalationLog = { type : "qc", status : "pending", // TODO: update with supervisor decision reason : data.escalationLog?.reason, recordDate : dayjsToInputDateString(dayjs()), - handlerId : Number(session?.id), + handlerId : data.escalationLog?.handlerId, } console.log("Escalation Data for submission", escalationLog); await postStockInLine({...qcData, escalationLog}); + } else { await postStockInLine(qcData); } diff --git a/src/i18n/zh/dashboard.json b/src/i18n/zh/dashboard.json index 472d2f4..6ff0ad2 100644 --- a/src/i18n/zh/dashboard.json +++ b/src/i18n/zh/dashboard.json @@ -52,5 +52,7 @@ "QC Fail-Total Count": "品檢不合格/總數", "escalationStatus": "上報狀態", "escalated datetime": "上報時間", - "escalateFrom": "上報同事" + "escalateFrom": "上報同事", + "No": "無", + "Responsible Escalation List": "負責的上報列表" }