Skip to content

Commit 798d95c

Browse files
date range component impl on irrigation report page (#7)
1 parent 3e88646 commit 798d95c

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

src/pages/dashboard/services/FarmCalendar/ReportingService/IrrigationOperations.tsx

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import { EventClickArg, EventInput } from "@fullcalendar/core/index.js";
88
import useDialog from "@hooks/useDialog";
99
import useFetch from "@hooks/useFetch";
1010
import useSnackbar from "@hooks/useSnackbar";
11-
import { Box, Button, Typography } from "@mui/material";
11+
import { Box, Button, Card, CardContent, Typography } from "@mui/material";
1212
import { useEffect, useMemo, useState } from "react";
1313
import InsertDriveFileIcon from '@mui/icons-material/InsertDriveFile';
1414
import dayjs, { Dayjs } from "dayjs";
1515
import { IrrigationOperationModel } from "@models/IrrigationOperation";
16+
import DateRangeSelect from "@components/shared/DateRangeSelect/DateRangeSelect";
1617

1718
interface ReportHelper {
1819
reportType: string;
@@ -142,8 +143,6 @@ const IrrigationOperationsReportPage = () => {
142143

143144
const handleCloseDialog = () => {
144145
dialogProps.onClose();
145-
setFromDate(null)
146-
setToDate(null)
147146
setActiveEventInfo(null);
148147
};
149148

@@ -152,6 +151,35 @@ const IrrigationOperationsReportPage = () => {
152151
<ParcelSelectionModule></ParcelSelectionModule>
153152
<ContentGuard condition={session?.farm_parcel}>
154153
<Box display={'flex'} flexDirection={'column'} gap={2}>
154+
<Card variant="outlined">
155+
<CardContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>
156+
<Typography variant="body1">
157+
Select a date range and press the button to generate a report or interact with the calendar to create a date range
158+
</Typography>
159+
<DateRangeSelect
160+
fromDate={fromDate}
161+
setFromDate={setFromDate}
162+
toDate={toDate}
163+
setToDate={setToDate}>
164+
</DateRangeSelect>
165+
<Button
166+
loading={loadingReport}
167+
loadingPosition="start"
168+
onClick={
169+
() => handleGenerateReport(
170+
{
171+
reportType: 'irrigation-report',
172+
irrigationOperationID: activeEventInfo?.event.id.split(':')[3],
173+
fromDate: fromDate?.format('YYYY-MM-DD'),
174+
toDate: toDate?.format('YYYY-MM-DD')
175+
})
176+
}
177+
disabled={!fromDate || !toDate}
178+
variant="contained">
179+
Generate report
180+
</Button>
181+
</CardContent>
182+
</Card>
155183
<StyledFullCalendar
156184
events={calendarEvents}
157185
eventClick={

0 commit comments

Comments
 (0)