diff --git a/fe-admin/src/App.tsx b/fe-admin/src/App.tsx index 8e32666..0c6b345 100644 --- a/fe-admin/src/App.tsx +++ b/fe-admin/src/App.tsx @@ -32,6 +32,9 @@ import { HrmConfigsPage } from '@/pages/hrm/HrmConfigsPage' import { InternalDirectoryPage } from '@/pages/office/InternalDirectoryPage' import { MeetingCalendarPage } from '@/pages/office/MeetingCalendarPage' import { MeetingRoomsPage } from '@/pages/office/MeetingRoomsPage' +import { ProposalCreatePage } from '@/pages/office/ProposalCreatePage' +import { ProposalDetailPage } from '@/pages/office/ProposalDetailPage' +import { ProposalsListPage } from '@/pages/office/ProposalsListPage' function App() { return ( @@ -85,6 +88,9 @@ function App() { {/* Văn phòng số — Phòng họp Booking + Catalog (Phase 10.2 G-O2 — Mig 36 S36) */} } /> } /> + } /> + } /> + } /> } /> } /> 0 ? n.toLocaleString('vi-VN') : '' +} + +export function ProposalCreatePage() { + const navigate = useNavigate() + const [title, setTitle] = useState('') + const [description, setDescription] = useState('') + const [amountStr, setAmountStr] = useState('') + const [departmentId, setDepartmentId] = useState('') + const [approvalWorkflowId, setApprovalWorkflowId] = useState('') + + const departments = useQuery({ + queryKey: ['departments'], + queryFn: async () => (await api.get('/departments')).data, + }) + + 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, + }) + + const create = useMutation({ + mutationFn: async () => { + if (!title.trim()) throw new Error('Vui lòng nhập Tiêu đề') + const body: CreateProposalInput = { + title: title.trim(), + description: description.trim() || null, + amountEstimate: amountStr ? parseVnd(amountStr) : null, + departmentId: departmentId || null, + approvalWorkflowId: approvalWorkflowId || null, + } + const res = await api.post<{ id: string }>('/proposals', body) + return res.data.id + }, + onSuccess: (id) => { + toast.success('Tạo đề xuất thành công') + navigate(`/proposals/${id}`) + }, + onError: (e) => toast.error(getErrorMessage(e)), + }) + + const onSubmit = (e: FormEvent) => { + e.preventDefault() + create.mutate() + } + + return ( +
+ navigate('/proposals')}> + + Huỷ + + } + /> + +
+
+
+ + setTitle(e.target.value)} + maxLength={300} + placeholder="vd. Đề xuất mua sắm máy tính cho Phòng IT" + required + /> +
+ +
+ +