calendar range days
This commit is contained in:
parent
8b49a3a7c2
commit
95ba471e1f
@ -43,8 +43,8 @@ export const ProfileCalendar = () => {
|
|||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStartDateRange (date) {
|
function setStartDateRange(date) {
|
||||||
setStartDate(date)
|
setStartDate(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleStartRangeDays() {
|
function toggleStartRangeDays() {
|
||||||
|
@ -39,7 +39,7 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
startRangeDays,
|
startRangeDays,
|
||||||
toggleRangeDays,
|
toggleRangeDays,
|
||||||
startDate,
|
startDate,
|
||||||
setStartDateRange
|
setStartDateRange,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
if (endDate) {
|
if (endDate) {
|
||||||
resetRangeDays()
|
resetRangeDays();
|
||||||
}
|
}
|
||||||
}, [value]);
|
}, [value]);
|
||||||
|
|
||||||
@ -117,11 +117,14 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
}
|
}
|
||||||
|
|
||||||
function reportsByDate(endDay) {
|
function reportsByDate(endDay) {
|
||||||
const requestDates = startDate < endDay ? `fromDate=${getCorrectYYMMDD(
|
const requestDates =
|
||||||
startDate._d
|
startDate < endDay
|
||||||
)}&toDate=${getCorrectYYMMDD(endDay._d)}` : `fromDate=${getCorrectYYMMDD(
|
? `fromDate=${getCorrectYYMMDD(
|
||||||
endDay._d
|
startDate._d
|
||||||
)}&toDate=${getCorrectYYMMDD(startDate._d)}`;
|
)}&toDate=${getCorrectYYMMDD(endDay._d)}`
|
||||||
|
: `fromDate=${getCorrectYYMMDD(endDay._d)}&toDate=${getCorrectYYMMDD(
|
||||||
|
startDate._d
|
||||||
|
)}`;
|
||||||
apiRequest(
|
apiRequest(
|
||||||
`/reports/reports-by-date?${requestDates}&user_card_id=${localStorage.getItem(
|
`/reports/reports-by-date?${requestDates}&user_card_id=${localStorage.getItem(
|
||||||
"cardId"
|
"cardId"
|
||||||
@ -153,24 +156,22 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
for (let curDay in selectedRangeDays) {
|
for (let curDay in selectedRangeDays) {
|
||||||
if (day > startDate) {
|
if (day > startDate) {
|
||||||
if (
|
if (
|
||||||
day > startDate &&
|
day > startDate &&
|
||||||
new Date(curDay) > startDate &&
|
new Date(curDay) > startDate &&
|
||||||
new Date(curDay) < day
|
new Date(curDay) < day
|
||||||
) {
|
) {
|
||||||
selectRange[curDay] = true;
|
selectRange[curDay] = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
selectRange[curDay] = false;
|
selectRange[curDay] = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (
|
if (
|
||||||
day < startDate &&
|
day < startDate &&
|
||||||
new Date(curDay) < startDate &&
|
new Date(curDay) < startDate &&
|
||||||
new Date(curDay) > day
|
new Date(curDay) > day
|
||||||
) {
|
) {
|
||||||
selectRange[curDay] = true;
|
selectRange[curDay] = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
selectRange[curDay] = false;
|
selectRange[curDay] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -266,7 +267,8 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
className={
|
className={
|
||||||
startRangeDays
|
startRangeDays
|
||||||
? `selectDays ${
|
? `selectDays ${
|
||||||
String(startDate?._d) === String(day._d) || endDate === day
|
String(startDate?._d) === String(day._d) ||
|
||||||
|
endDate === day
|
||||||
? "selectedDay"
|
? "selectedDay"
|
||||||
: ""
|
: ""
|
||||||
} ${endDate ? "disable" : ""} ${
|
} ${endDate ? "disable" : ""} ${
|
||||||
@ -299,7 +301,9 @@ export const ProfileCalendarComponent = React.memo(
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{endDate
|
{endDate
|
||||||
? startDate < endDate ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
|
? startDate < endDate
|
||||||
|
? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}`
|
||||||
|
: `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}`
|
||||||
: "Выбрать диапазон"}
|
: "Выбрать диапазон"}
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
Reference in New Issue
Block a user