Skip to content

Commit

Permalink
wip fix RegularSchedulePicker for all timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung committed Dec 19, 2024
1 parent c745c1b commit cf443bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
calculateWeeklyHoursFromSchedule,
regularTimePeriods,
selectedDaysFromComplexSchedule,
convertLocaleDateToUtcTimezoneDate,
} from "shared";
import { useStyles } from "tss-react/dsfr";
import { HourPicker } from "./HourPicker";
Expand All @@ -40,6 +41,7 @@ export const RegularSchedulePicker = (props: RegularSchedulePickerProps) => {
const selectedHours = regularTimePeriods(
values.schedule.complexSchedule[0]?.timePeriods,
);
console.log({ complexeSchedule: values.schedule.complexSchedule });

return (
<>
Expand Down Expand Up @@ -122,8 +124,10 @@ export const RegularSchedulePicker = (props: RegularSchedulePickerProps) => {
<WeeksHoursIndicator
schedule={values.schedule}
interval={{
start: new Date(values.dateStart),
end: new Date(values.dateEnd),
start: convertLocaleDateToUtcTimezoneDate(
new Date(values.dateStart),
),
end: convertLocaleDateToUtcTimezoneDate(new Date(values.dateEnd)),
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
frenchDayMapping,
maximumCalendarDayByInternshipKind,
removeAtIndex,
convertLocaleDateToUtcTimezoneDate,
} from "shared";
import { useStyles } from "tss-react/dsfr";
import { DayCircle } from "./DayCircle";
Expand All @@ -34,6 +35,7 @@ export const WeekdayPicker = ({
}: WeekdayPickerProps) => {
const { cx } = useStyles();
const onDayClick = (day: WeekdayNumber) => {
console.log({ selectedDays, day });
const newDaysSelected = selectedDays.includes(day)
? removeAtIndex(selectedDays, selectedDays.indexOf(day))
: [...selectedDays, day];
Expand All @@ -49,8 +51,12 @@ export const WeekdayPicker = ({
const uniqueWeekDaysOnInterval = uniq(
arrayFromNumber(startEndDiff + 1).map(
(dayIndex) =>
frenchDayMapping(addDays(new Date(start), dayIndex).toISOString())
.frenchDay,
frenchDayMapping(
addDays(
convertLocaleDateToUtcTimezoneDate(new Date(start)),
dayIndex,
).toISOString(),
).frenchDay,
),
);
return !uniqueWeekDaysOnInterval.includes(day);
Expand Down

0 comments on commit cf443bd

Please sign in to comment.