Merge pull request #138 from apuc/fixed-pages

fixed calendar periods
This commit is contained in:
MaxOvs19 2023-10-24 19:59:56 +03:00 committed by GitHub
commit c3d5e7f5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 7 deletions

View File

@ -287,7 +287,7 @@
.selectDateRange { .selectDateRange {
display: flex; display: flex;
align-items: center; align-items: center;
column-gap: 8px; column-gap: 16px;
font-size: 16px; font-size: 16px;
font-weight: 500; font-weight: 500;
position: relative; position: relative;

View File

@ -22,11 +22,12 @@ import {
getReports, getReports,
hourOfNum, hourOfNum,
} from "@components/Calendar/calendarHelper"; } from "@components/Calendar/calendarHelper";
import BaseButton from "@components/Common/BaseButton/BaseButton";
import ShortReport from "@components/ShortReport/ShortReport"; import ShortReport from "@components/ShortReport/ShortReport";
import arrow from "assets/icons/arrows/arrowCalendar.png"; import arrow from "assets/icons/arrows/arrowCalendar.png";
import calendarIcon from "assets/icons/calendar.svg"; import calendarIcon from "assets/icons/calendar.svg";
import close from "assets/icons/closeProjectPersons.svg"; // import close from "assets/icons/closeProjectPersons.svg";
import rectangle from "assets/images/rectangle__calendar.png"; import rectangle from "assets/images/rectangle__calendar.png";
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
@ -50,6 +51,7 @@ export const ProfileCalendarComponent = React.memo(
const [endDate, setEndDate] = useState(null); const [endDate, setEndDate] = useState(null);
const [totalRangeHours, setTotalRangeHours] = useState(0); const [totalRangeHours, setTotalRangeHours] = useState(0);
const [selectedRangeDays, setSelectedRangeDays] = useState({}); const [selectedRangeDays, setSelectedRangeDays] = useState({});
const [activePeriod, setActivePeriod] = useState(false);
useEffect(() => { useEffect(() => {
setCalendar(calendarHelper(value)); setCalendar(calendarHelper(value));
@ -142,6 +144,14 @@ export const ProfileCalendarComponent = React.memo(
}); });
} }
function toggleActivePeriod() {
if (!activePeriod) {
setActivePeriod(true);
} else {
setActivePeriod(false);
}
}
function rangeDays(day) { function rangeDays(day) {
if (!startDate) { if (!startDate) {
setStartDateRange(day); setStartDateRange(day);
@ -298,12 +308,15 @@ export const ProfileCalendarComponent = React.memo(
onClick={() => { onClick={() => {
if (startRangeDays) resetRangeDays(); if (startRangeDays) resetRangeDays();
toggleRangeDays(); toggleRangeDays();
toggleActivePeriod();
}} }}
> >
{endDate {endDate
? startDate < endDate ? startDate < endDate
? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}`
: `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
: activePeriod
? "Выберите начало диапазона"
: "Выбрать диапазон"} : "Выбрать диапазон"}
</span> </span>
<span> <span>
@ -312,14 +325,14 @@ export const ProfileCalendarComponent = React.memo(
: "0 часов"} : "0 часов"}
</span> </span>
{endDate && ( {endDate && (
<img <BaseButton
className="close" styles={"clear-days"}
src={close}
alt="close"
onClick={() => { onClick={() => {
resetRangeDays(); resetRangeDays();
}} }}
/> >
Сбросить
</BaseButton>
)} )}
</div> </div>
{shortReport && <ShortReport />} {shortReport && <ShortReport />}

View File

@ -90,3 +90,12 @@
} }
} }
} }
.clear-days {
background: red;
padding: 5px 20px;
font-size: 14px;
&:hover {
background: rgba(255, 0, 0, 0.637);
}
}