Fix View button
This commit is contained in:
parent
89e96672bf
commit
a3d75bb081
@ -40,12 +40,24 @@ const Dashboard = () => {
|
|||||||
page: pagination.page,
|
page: pagination.page,
|
||||||
page_size: 30,
|
page_size: 30,
|
||||||
});
|
});
|
||||||
const handleSubmit = (values: ReportFormValues) => {
|
const get30dDateRangeDayJS = () => {
|
||||||
console.log('check values >>>', values);
|
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({
|
setFormData({
|
||||||
start_date: values.dateRange[0].format('YYYY-MM-DDTHH:mm:ssZ'),
|
start_date: formatDate(dateRange[0]),
|
||||||
end_date: values.dateRange[1].format('YYYY-MM-DDTHH:mm:ssZ'),
|
end_date: formatDate(dateRange[1]),
|
||||||
subsidiary: values.subsidiary,
|
subsidiary: subsidiary,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +76,6 @@ const Dashboard = () => {
|
|||||||
document.body.removeChild(anchorElement);
|
document.body.removeChild(anchorElement);
|
||||||
URL.revokeObjectURL(anchorElement.href);
|
URL.revokeObjectURL(anchorElement.href);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SbtPageHeader
|
<SbtPageHeader
|
||||||
@ -85,25 +96,7 @@ const Dashboard = () => {
|
|||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
style={{ display: 'flex', flexDirection: 'row', gap: 10 }}
|
style={{ display: 'flex', flexDirection: 'row', gap: 10 }}
|
||||||
onFinish={handleSubmit}
|
|
||||||
>
|
>
|
||||||
{/* TODO: Remove this when the Dashboard page is refactored */}
|
|
||||||
<Form.Item
|
|
||||||
name='dateRange'
|
|
||||||
label={t`Date`}
|
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: 'Please select a date range',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
style={{
|
|
||||||
display: 'none'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<DatePicker.RangePicker />
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t`Duration`}
|
label={t`Duration`}
|
||||||
rules={[
|
rules={[
|
||||||
@ -130,13 +123,6 @@ const Dashboard = () => {
|
|||||||
<Form.Item
|
<Form.Item
|
||||||
name='subsidiary'
|
name='subsidiary'
|
||||||
label={t`Subsidiary`}
|
label={t`Subsidiary`}
|
||||||
rules={[
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: 'Please select a subsidiary',
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
required
|
|
||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
placeholder='Select a subsidiary'
|
placeholder='Select a subsidiary'
|
||||||
@ -154,7 +140,9 @@ const Dashboard = () => {
|
|||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item>
|
<Form.Item>
|
||||||
<Button type='primary' htmlType='submit' style={{ height: 38 }}>
|
<Button type='primary' style={{ height: 38 }}
|
||||||
|
onClick={changeView}
|
||||||
|
>
|
||||||
View
|
View
|
||||||
</Button>
|
</Button>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
Loading…
Reference in New Issue
Block a user