Skip to content

Commit 9412f31

Browse files
Copilottyler-daneCopilot
authored
feat(web): restrict someday event recurrence to weekly/monthly only (#1017)
* Initial plan * feat(web): add SomedayRecurrenceSection with restricted frequency options Co-authored-by: tyler-dane <30163055+tyler-dane@users.noreply.github.com> * refactor(web): replace ConditionalRender with conditional rendering in RecurrenceSection components * refactor(web): remove unused ConditionalRender component * refactor(web): remove end date controls from SomedayRecurrenceSection * refactor(web): modularize recurrence code * test(web): add category prop to EventForm tests for better event categorization * refactor(web): modularize RecurrenceSection children * refactor(web): enhance SomedayRecurrenceSection with improved select handling and styling * refactor(web): update SomedayRecurrenceSection to use role-based queries for better accessibility * refactor(web): implement cancel edit functionality in SomedayRecurrenceSection * refactor(web): improve event handling in SomedayEventForm and add combobox interaction checks * style(web): update font size and text case in SomedayRecurrenceSection components * style(web): adjust overflow handling in SomedayRecurrenceSelect component * Update packages/web/src/views/Forms/EventForm/DateControlsSection/RecurrenceSection/useRecurrence/useRecurrence.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: tyler-dane <30163055+tyler-dane@users.noreply.github.com> Co-authored-by: Tyler Dane <tyler@switchback.tech> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 3fdfe4b commit 9412f31

File tree

21 files changed

+1038
-275
lines changed

21 files changed

+1038
-275
lines changed

packages/web/src/components/ConditionalRender/conditional-render.tsx

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/web/src/views/Forms/EventForm/DateControlsSection/index.tsx renamed to packages/web/src/views/Forms/EventForm/DateControlsSection/DateControlsSection/DateControlsSection.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Categories_Event } from "@core/types/event.types";
33
import {
44
DateTimeSection,
55
Props as DateTimeSectionProps,
6-
} from "./DateTimeSection/DateTimeSection";
6+
} from "../DateTimeSection/DateTimeSection";
77
import { StyledControlsSection } from "./styled";
88

99
interface Props {

packages/web/src/views/Forms/EventForm/DateControlsSection/styled.ts renamed to packages/web/src/views/Forms/EventForm/DateControlsSection/DateControlsSection/styled.ts

File renamed without changes.

packages/web/src/views/Forms/EventForm/DateControlsSection/RecurrenceSection/RecurrenceSection.tsx

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { brighten, darken } from "@core/util/color.utils";
88
import { parseCompassEventDate } from "@core/util/event/event.util";
99
import { theme } from "@web/common/styles/theme";
1010
import { hoverColorByPriority } from "@web/common/styles/theme.util";
11-
import { ConditionalRender } from "@web/components/ConditionalRender/conditional-render";
1211
import { DatePicker } from "@web/components/DatePicker/DatePicker";
1312
import { Flex } from "@web/components/Flex";
1413
import { RepeatIcon } from "@web/components/Icons/Repeat";
@@ -24,13 +23,13 @@ import {
2423
StyledRepeatTextContainer,
2524
StyledWeekDay,
2625
} from "@web/views/Forms/EventForm/DateControlsSection/RecurrenceSection/styled";
26+
import { useRecurrence } from "@web/views/Forms/EventForm/DateControlsSection/RecurrenceSection/useRecurrence/useRecurrence";
2727
import {
2828
FREQUENCY_MAP,
2929
FREQUENCY_OPTIONS,
3030
FrequencyValues,
3131
WEEKDAYS,
32-
useRecurrence,
33-
} from "@web/views/Forms/EventForm/DateControlsSection/RecurrenceSection/utils";
32+
} from "./constants/recurrence.constants";
3433

3534
export interface RecurrenceSectionProps {
3635
bgColor: string;
@@ -66,22 +65,20 @@ const RecurrenceToggle = ({
6665
}) => {
6766
return (
6867
<StyledRepeatRow>
69-
<ConditionalRender condition={!hasRecurrence}>
68+
{!hasRecurrence ? (
7069
<StyledRepeatContainer onClick={toggleRecurrence}>
7170
<StyledRepeatText hasRepeat={hasRecurrence} tabIndex={0}>
7271
Does not repeat
7372
</StyledRepeatText>
7473
</StyledRepeatContainer>
75-
</ConditionalRender>
76-
77-
<ConditionalRender condition={hasRecurrence}>
74+
) : (
7875
<StyledRepeatTextContainer onClick={toggleRecurrence}>
7976
<RepeatIcon />
8077
<StyledRepeatText hasRepeat={hasRecurrence}>
8178
Repeats every
8279
</StyledRepeatText>
8380
</StyledRepeatTextContainer>
84-
</ConditionalRender>
81+
)}
8582
</StyledRepeatRow>
8683
);
8784
};
@@ -382,43 +379,45 @@ export const RecurrenceSection = ({
382379
marginBottom: 10,
383380
}}
384381
>
385-
<ConditionalRender condition={hasRecurrence}>
382+
{hasRecurrence && (
386383
<EditRecurrence
387384
open={showForm}
388385
onClick={() => setShowForm((value) => !value)}
389386
/>
390-
</ConditionalRender>
387+
)}
391388

392-
<ConditionalRender condition={hasRecurrence ? showForm : true}>
389+
{(!hasRecurrence || showForm) && (
393390
<RecurrenceToggle
394391
hasRecurrence={hasRecurrence}
395392
toggleRecurrence={toggleRecurrence}
396393
/>
397-
</ConditionalRender>
394+
)}
398395

399-
<ConditionalRender condition={hasRecurrence && showForm}>
400-
<RecurrenceIntervalSelect
401-
bgColor={bgColor}
402-
initialValue={interval}
403-
frequency={freq}
404-
onChange={setInterval}
405-
onFreqSelect={setFreq}
406-
min={1}
407-
max={12}
408-
/>
396+
{hasRecurrence && showForm && (
397+
<>
398+
<RecurrenceIntervalSelect
399+
bgColor={bgColor}
400+
initialValue={interval}
401+
frequency={freq}
402+
onChange={setInterval}
403+
onFreqSelect={setFreq}
404+
min={1}
405+
max={12}
406+
/>
409407

410-
<WeekDays bgColor={bgColor} value={weekDays} onChange={setWeekDays} />
408+
<WeekDays bgColor={bgColor} value={weekDays} onChange={setWeekDays} />
411409

412-
<EndsOnDate
413-
bgColor={bgColor}
414-
inputColor={
415-
hoverColorByPriority[event.priority ?? Priorities.UNASSIGNED]
416-
}
417-
until={until}
418-
minDate={event.endDate}
419-
setUntil={setUntil}
420-
/>
421-
</ConditionalRender>
410+
<EndsOnDate
411+
bgColor={bgColor}
412+
inputColor={
413+
hoverColorByPriority[event.priority ?? Priorities.UNASSIGNED]
414+
}
415+
until={until}
416+
minDate={event.endDate}
417+
setUntil={setUntil}
418+
/>
419+
</>
420+
)}
422421
</StyledRepeatRow>
423422
);
424423
};

0 commit comments

Comments
 (0)