From 58b81195694208786f6801f685408f7ba3b34f39 Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 10 Oct 2023 19:21:34 +0300 Subject: [PATCH 1/2] calendar range days --- src/components/ProfileCalendar/ProfileCalendar.jsx | 7 +++++++ .../ProfileCalendar/ProfileCalendarComponent.jsx | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/ProfileCalendar/ProfileCalendar.jsx b/src/components/ProfileCalendar/ProfileCalendar.jsx index 52a863ad..446e721b 100644 --- a/src/components/ProfileCalendar/ProfileCalendar.jsx +++ b/src/components/ProfileCalendar/ProfileCalendar.jsx @@ -36,11 +36,16 @@ export const ProfileCalendar = () => { const [reports, setReports] = useState([]); const [totalHours, setTotalHours] = useState(0); const [loader, setLoader] = useState(true); + const [startRangeDays, setStartRangeDays] = useState(false); function setValueHandler(value) { setValue(value); } + function toggleStartRangeDays () { + setStartRangeDays(!startRangeDays) + } + useEffect(() => { dispatch(setRequestDate(getReports(moment()))); }, []); @@ -115,6 +120,8 @@ export const ProfileCalendar = () => { value={value} reports={reports} totalHours={totalHours} + startRangeDays={startRangeDays} + toggleRangeDays={toggleStartRangeDays} /> diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx index abdf03f2..b66295c9 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx @@ -31,7 +31,7 @@ import rectangle from "assets/images/rectangle__calendar.png"; // eslint-disable-next-line react/display-name export const ProfileCalendarComponent = React.memo( - ({ value, setValueHandler, reports, totalHours }) => { + ({ value, setValueHandler, reports, totalHours, startRangeDays, toggleRangeDays }) => { const dispatch = useDispatch(); const [currentDay] = useState(moment()); @@ -40,7 +40,6 @@ export const ProfileCalendarComponent = React.memo( const [shortReport, setShortReport] = useState(false); const [startDate, setStartDate] = useState(null); const [endDate, setEndDate] = useState(null); - const [startRangeDays, setStartRangeDays] = useState(false); const [totalRangeHours, setTotalRangeHours] = useState(0); const [selectedRangeDays, setSelectedRangeDays] = useState({}); @@ -269,7 +268,7 @@ export const ProfileCalendarComponent = React.memo( className="select" onClick={() => { if (startRangeDays) resetRangeDays(); - setStartRangeDays(!startRangeDays); + toggleRangeDays(); }} > {endDate From ff2bd020e8c5c41b794ac30249958f866f194c60 Mon Sep 17 00:00:00 2001 From: Mikola Date: Tue, 10 Oct 2023 19:21:46 +0300 Subject: [PATCH 2/2] calendar range days --- src/components/ProfileCalendar/ProfileCalendar.jsx | 4 ++-- .../ProfileCalendar/ProfileCalendarComponent.jsx | 11 +++++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/ProfileCalendar/ProfileCalendar.jsx b/src/components/ProfileCalendar/ProfileCalendar.jsx index 446e721b..e29d46c0 100644 --- a/src/components/ProfileCalendar/ProfileCalendar.jsx +++ b/src/components/ProfileCalendar/ProfileCalendar.jsx @@ -42,8 +42,8 @@ export const ProfileCalendar = () => { setValue(value); } - function toggleStartRangeDays () { - setStartRangeDays(!startRangeDays) + function toggleStartRangeDays() { + setStartRangeDays(!startRangeDays); } useEffect(() => { diff --git a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx index b66295c9..7d1b5229 100644 --- a/src/components/ProfileCalendar/ProfileCalendarComponent.jsx +++ b/src/components/ProfileCalendar/ProfileCalendarComponent.jsx @@ -31,7 +31,14 @@ import rectangle from "assets/images/rectangle__calendar.png"; // eslint-disable-next-line react/display-name export const ProfileCalendarComponent = React.memo( - ({ value, setValueHandler, reports, totalHours, startRangeDays, toggleRangeDays }) => { + ({ + value, + setValueHandler, + reports, + totalHours, + startRangeDays, + toggleRangeDays, + }) => { const dispatch = useDispatch(); const [currentDay] = useState(moment()); @@ -268,7 +275,7 @@ export const ProfileCalendarComponent = React.memo( className="select" onClick={() => { if (startRangeDays) resetRangeDays(); - toggleRangeDays(); + toggleRangeDays(); }} > {endDate