[CLAUDE] FE-User: fix ProposalCreatePage workflow dropdown shape (latent S37 bug)
Follow-up cho bug flagged trong 75df04e. ProposalCreatePage (fe-admin + fe-user)
fetch /approval-workflows-v2 expect flat array, nhưng endpoint trả AwAdminOverviewDto
{types:[{applicableType, history:[...]}]} → workflows.data.map chạy .map trên object
→ TypeError/dropdown rỗng. Latent vì create-with-workflow chưa exercise UAT.
Fix: mirror pattern proven của ContractCreatePage + WorkflowAppDetailPage —
res.data.types.find(t=>t.applicableType===4)?.history.filter(isUserSelectable).
WorkflowDto +isUserSelectable. Render .map giữ nguyên (data giờ là array đúng).
Verify: tsc -b + vite build ×2 PASS (exit 0) · fe-admin/fe-user SHA256 identical
(91565D47...7697C771).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@ -25,6 +25,7 @@ interface WorkflowDto {
|
|||||||
id: string
|
id: string
|
||||||
code: string
|
code: string
|
||||||
name: string
|
name: string
|
||||||
|
isUserSelectable: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVnd(s: string): number {
|
function parseVnd(s: string): number {
|
||||||
@ -48,12 +49,19 @@ export function ProposalCreatePage() {
|
|||||||
queryFn: async () => (await api.get<DepartmentDto[]>('/departments')).data,
|
queryFn: async () => (await api.get<DepartmentDto[]>('/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({
|
const workflows = useQuery({
|
||||||
queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }],
|
queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }],
|
||||||
queryFn: async () =>
|
queryFn: async () => {
|
||||||
(await api.get<WorkflowDto[]>('/approval-workflows-v2', {
|
const res = await api.get<{ types: { applicableType: number; history: WorkflowDto[] }[] }>(
|
||||||
params: { applicableType: 4, isUserSelectable: true },
|
'/approval-workflows-v2',
|
||||||
})).data,
|
{ params: { applicableType: 4 } },
|
||||||
|
)
|
||||||
|
const bucket = res.data.types.find((t) => t.applicableType === 4)
|
||||||
|
return (bucket?.history ?? []).filter((w) => w.isUserSelectable)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const create = useMutation({
|
const create = useMutation({
|
||||||
|
|||||||
@ -25,6 +25,7 @@ interface WorkflowDto {
|
|||||||
id: string
|
id: string
|
||||||
code: string
|
code: string
|
||||||
name: string
|
name: string
|
||||||
|
isUserSelectable: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseVnd(s: string): number {
|
function parseVnd(s: string): number {
|
||||||
@ -48,12 +49,19 @@ export function ProposalCreatePage() {
|
|||||||
queryFn: async () => (await api.get<DepartmentDto[]>('/departments')).data,
|
queryFn: async () => (await api.get<DepartmentDto[]>('/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({
|
const workflows = useQuery({
|
||||||
queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }],
|
queryKey: ['approval-workflows-v2', { applicableType: 4, isUserSelectable: true }],
|
||||||
queryFn: async () =>
|
queryFn: async () => {
|
||||||
(await api.get<WorkflowDto[]>('/approval-workflows-v2', {
|
const res = await api.get<{ types: { applicableType: number; history: WorkflowDto[] }[] }>(
|
||||||
params: { applicableType: 4, isUserSelectable: true },
|
'/approval-workflows-v2',
|
||||||
})).data,
|
{ params: { applicableType: 4 } },
|
||||||
|
)
|
||||||
|
const bucket = res.data.types.find((t) => t.applicableType === 4)
|
||||||
|
return (bucket?.history ?? []).filter((w) => w.isUserSelectable)
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const create = useMutation({
|
const create = useMutation({
|
||||||
|
|||||||
Reference in New Issue
Block a user