diff --git a/fe-admin/src/pages/office/ProposalCreatePage.tsx b/fe-admin/src/pages/office/ProposalCreatePage.tsx index 5528187..2f3fe24 100644 --- a/fe-admin/src/pages/office/ProposalCreatePage.tsx +++ b/fe-admin/src/pages/office/ProposalCreatePage.tsx @@ -25,6 +25,7 @@ interface WorkflowDto { id: string code: string name: string + isUserSelectable: boolean } function parseVnd(s: string): number { @@ -48,12 +49,19 @@ export function ProposalCreatePage() { queryFn: async () => (await api.get('/departments')).data, }) + // Endpoint trả AwAdminOverviewDto { types: [{ applicableType, history: [...] }] } — + // KHÔNG phải flat array. Mirror ContractCreatePage/WorkflowAppDetail: extract bucket + // theo applicableType=4 (Đề xuất) rồi filter isUserSelectable (admin ghim cho user pick). const workflows = useQuery({ queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }], - queryFn: async () => - (await api.get('/approval-workflows-v2', { - params: { applicableType: 4, isUserSelectable: true }, - })).data, + queryFn: async () => { + const res = await api.get<{ types: { applicableType: number; history: WorkflowDto[] }[] }>( + '/approval-workflows-v2', + { params: { applicableType: 4 } }, + ) + const bucket = res.data.types.find((t) => t.applicableType === 4) + return (bucket?.history ?? []).filter((w) => w.isUserSelectable) + }, }) const create = useMutation({ diff --git a/fe-user/src/pages/office/ProposalCreatePage.tsx b/fe-user/src/pages/office/ProposalCreatePage.tsx index 5528187..2f3fe24 100644 --- a/fe-user/src/pages/office/ProposalCreatePage.tsx +++ b/fe-user/src/pages/office/ProposalCreatePage.tsx @@ -25,6 +25,7 @@ interface WorkflowDto { id: string code: string name: string + isUserSelectable: boolean } function parseVnd(s: string): number { @@ -48,12 +49,19 @@ export function ProposalCreatePage() { queryFn: async () => (await api.get('/departments')).data, }) + // Endpoint trả AwAdminOverviewDto { types: [{ applicableType, history: [...] }] } — + // KHÔNG phải flat array. Mirror ContractCreatePage/WorkflowAppDetail: extract bucket + // theo applicableType=4 (Đề xuất) rồi filter isUserSelectable (admin ghim cho user pick). const workflows = useQuery({ queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }], - queryFn: async () => - (await api.get('/approval-workflows-v2', { - params: { applicableType: 4, isUserSelectable: true }, - })).data, + queryFn: async () => { + const res = await api.get<{ types: { applicableType: number; history: WorkflowDto[] }[] }>( + '/approval-workflows-v2', + { params: { applicableType: 4 } }, + ) + const bucket = res.data.types.find((t) => t.applicableType === 4) + return (bucket?.history ?? []).filter((w) => w.isUserSelectable) + }, }) const create = useMutation({