From a3d75bb0816ed1153f070a7327e522f9034c7abe Mon Sep 17 00:00:00 2001 From: Viet Anh Nguyen Date: Mon, 5 Feb 2024 16:32:47 +0700 Subject: [PATCH] Fix View button --- cope2n-fe/src/pages/dashboard/index.tsx | 52 ++++++++++--------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/cope2n-fe/src/pages/dashboard/index.tsx b/cope2n-fe/src/pages/dashboard/index.tsx index 53d0f47..5697280 100644 --- a/cope2n-fe/src/pages/dashboard/index.tsx +++ b/cope2n-fe/src/pages/dashboard/index.tsx @@ -40,12 +40,24 @@ const Dashboard = () => { page: pagination.page, page_size: 30, }); - const handleSubmit = (values: ReportFormValues) => { - console.log('check values >>>', values); + const get30dDateRangeDayJS = () => { + const prev = new Date(); + prev.setDate(prev.getDate() - 30); + const today = new Date(); + return [prev, today]; + }; + const formatDate = (date: Date) => { + // YYYY-MM-DDTHH:mm:ssZ + const formated = date.toISOString().split('.')[0] + '+0000'; + console.log('formated >>>', formated); + return formated; + } + const changeView = () => { + const dateRange = get30dDateRangeDayJS(); setFormData({ - start_date: values.dateRange[0].format('YYYY-MM-DDTHH:mm:ssZ'), - end_date: values.dateRange[1].format('YYYY-MM-DDTHH:mm:ssZ'), - subsidiary: values.subsidiary, + start_date: formatDate(dateRange[0]), + end_date: formatDate(dateRange[1]), + subsidiary: subsidiary, }); }; @@ -64,7 +76,6 @@ const Dashboard = () => { document.body.removeChild(anchorElement); URL.revokeObjectURL(anchorElement.href); }; - return ( <> {
- {/* TODO: Remove this when the Dashboard page is refactored */} - - - - {