calendar range days

This commit is contained in:
Mikola 2023-10-10 19:21:34 +03:00
parent 644c89f376
commit 58b8119569
2 changed files with 9 additions and 3 deletions

View File

@ -36,11 +36,16 @@ export const ProfileCalendar = () => {
const [reports, setReports] = useState([]); const [reports, setReports] = useState([]);
const [totalHours, setTotalHours] = useState(0); const [totalHours, setTotalHours] = useState(0);
const [loader, setLoader] = useState(true); const [loader, setLoader] = useState(true);
const [startRangeDays, setStartRangeDays] = useState(false);
function setValueHandler(value) { function setValueHandler(value) {
setValue(value); setValue(value);
} }
function toggleStartRangeDays () {
setStartRangeDays(!startRangeDays)
}
useEffect(() => { useEffect(() => {
dispatch(setRequestDate(getReports(moment()))); dispatch(setRequestDate(getReports(moment())));
}, []); }, []);
@ -115,6 +120,8 @@ export const ProfileCalendar = () => {
value={value} value={value}
reports={reports} reports={reports}
totalHours={totalHours} totalHours={totalHours}
startRangeDays={startRangeDays}
toggleRangeDays={toggleStartRangeDays}
/> />
</div> </div>
</div> </div>

View File

@ -31,7 +31,7 @@ import rectangle from "assets/images/rectangle__calendar.png";
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
export const ProfileCalendarComponent = React.memo( export const ProfileCalendarComponent = React.memo(
({ value, setValueHandler, reports, totalHours }) => { ({ value, setValueHandler, reports, totalHours, startRangeDays, toggleRangeDays }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [currentDay] = useState(moment()); const [currentDay] = useState(moment());
@ -40,7 +40,6 @@ export const ProfileCalendarComponent = React.memo(
const [shortReport, setShortReport] = useState(false); const [shortReport, setShortReport] = useState(false);
const [startDate, setStartDate] = useState(null); const [startDate, setStartDate] = useState(null);
const [endDate, setEndDate] = useState(null); const [endDate, setEndDate] = useState(null);
const [startRangeDays, setStartRangeDays] = useState(false);
const [totalRangeHours, setTotalRangeHours] = useState(0); const [totalRangeHours, setTotalRangeHours] = useState(0);
const [selectedRangeDays, setSelectedRangeDays] = useState({}); const [selectedRangeDays, setSelectedRangeDays] = useState({});
@ -269,7 +268,7 @@ export const ProfileCalendarComponent = React.memo(
className="select" className="select"
onClick={() => { onClick={() => {
if (startRangeDays) resetRangeDays(); if (startRangeDays) resetRangeDays();
setStartRangeDays(!startRangeDays); toggleRangeDays();
}} }}
> >
{endDate {endDate