Fix View button
This commit is contained in:
parent
89e96672bf
commit
a3d75bb081
@ -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 (
|
||||
<>
|
||||
<SbtPageHeader
|
||||
@ -85,25 +96,7 @@ const Dashboard = () => {
|
||||
<Form
|
||||
form={form}
|
||||
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
|
||||
label={t`Duration`}
|
||||
rules={[
|
||||
@ -130,13 +123,6 @@ const Dashboard = () => {
|
||||
<Form.Item
|
||||
name='subsidiary'
|
||||
label={t`Subsidiary`}
|
||||
rules={[
|
||||
{
|
||||
required: true,
|
||||
message: 'Please select a subsidiary',
|
||||
},
|
||||
]}
|
||||
required
|
||||
>
|
||||
<Select
|
||||
placeholder='Select a subsidiary'
|
||||
@ -154,7 +140,9 @@ const Dashboard = () => {
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type='primary' htmlType='submit' style={{ height: 38 }}>
|
||||
<Button type='primary' style={{ height: 38 }}
|
||||
onClick={changeView}
|
||||
>
|
||||
View
|
||||
</Button>
|
||||
</Form.Item>
|
||||
|
Loading…
Reference in New Issue
Block a user