Skip to content

Commit

Permalink
fix/added default shed filling (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardZaydler authored Sep 26, 2024
1 parent 4cdc8bd commit 971eea1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
4 changes: 4 additions & 0 deletions src/Components/DateAndTimeMenu/DateAndTimeMenu.less
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@
cursor: pointer;
}
}

.input-container {
display: inline-flex;
}
28 changes: 16 additions & 12 deletions src/Components/DateAndTimeMenu/DateAndTimeMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ interface IDateAndTimeMenuProps {
validateDateAndTime?: (inputValue: string) => Nullable<ValidationInfo>;
}

const dateInputMask = "9999/99/99 99:99:99";

export const DateAndTimeMenu: FC<IDateAndTimeMenuProps> = ({
date,
setDate,
Expand Down Expand Up @@ -54,18 +56,20 @@ export const DateAndTimeMenu: FC<IDateAndTimeMenuProps> = ({
return (
<RenderLayer onClickOutside={closeMenu} onFocusOutside={closeMenu} active={isMenuOpen}>
<div ref={containerEl}>
<ValidationWrapperV1
validationInfo={validateDateAndTime && validateDateAndTime(inputValue)}
>
<Input
width={160}
mask={"9999/99/99 99:99:99"}
onFocus={closeMenu}
value={inputValue}
onValueChange={handleValueChange}
/>
</ValidationWrapperV1>
<CalendarIcon className={cn("calendar-icon")} onClick={openMenu} />
<div className={cn("input-container")}>
<ValidationWrapperV1
validationInfo={validateDateAndTime && validateDateAndTime(inputValue)}
>
<Input
width={160}
mask={dateInputMask}
onFocus={closeMenu}
value={inputValue}
onValueChange={handleValueChange}
/>
</ValidationWrapperV1>
<CalendarIcon className={cn("calendar-icon")} onClick={openMenu} />
</div>
{isMenuOpen && (
<DropdownContainer
offsetY={5}
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Tabs/Tabs.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import '~styles/variables.less';
@import '~styles/mixins.less';
@import "~styles/variables.less";
@import "~styles/mixins.less";

.header {
margin-top: -9px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const EventListTab: FC<IEventListTabProps> = ({ triggerName }) => {
<div style={{ paddingTop: 20 }}>
<Paging
caption="Next page"
activePage={page}
activePage={+page}
pagesCount={pageCount}
onPageChange={setPage}
withoutNavigationHint
Expand Down
5 changes: 3 additions & 2 deletions src/Components/TriggerInfo/Components/ScheduleView.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from "react";
import { Schedule } from "../../../Domain/Schedule";
import { defaultSchedule, Schedule } from "../../../Domain/Schedule";
import { format, addMinutes, startOfDay } from "date-fns";
import { getUTCDate } from "../../../helpers/DateUtil";

export function ScheduleView(props: { data: Schedule }): React.ReactElement {
const { data } = props;
const { days, startOffset, endOffset, tzOffset } = data;
const { startOffset, endOffset, tzOffset } = data;
const { days } = defaultSchedule(data);

const startTime = format(addMinutes(startOfDay(getUTCDate()), startOffset), "HH:mm");

Expand Down
13 changes: 9 additions & 4 deletions src/Domain/Schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ export function createSchedule(days: DaysOfWeek[]): Schedule {
};
}

export const defaultSchedule = (schedule: Schedule | undefined) => {
export const defaultSchedule = (schedule?: Schedule): Schedule => {
const existingDays = schedule?.days?.map((day) => day.name) || [];

return {
startOffset: schedule?.startOffset || 0,
endOffset: schedule?.endOffset || 1439,
tzOffset: schedule?.tzOffset || new Date().getTimezoneOffset(),
days:
schedule?.days ||
Object.values(DaysOfWeek).map((day) => ({ name: day, enabled: false })),
days: WholeWeek.map((day) => ({
name: day,
enabled:
(schedule?.days.find((d) => d.name === day)?.enabled ?? false) &&
existingDays.includes(day),
})),
};
};

0 comments on commit 971eea1

Please sign in to comment.