Skip to content

Commit 049520d

Browse files
committed
refactor(web): replace ConditionalRender with conditional rendering in RecurrenceSection components
1 parent bf20695 commit 049520d

File tree

2 files changed

+55
-57
lines changed

2 files changed

+55
-57
lines changed

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

Lines changed: 30 additions & 31 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";
@@ -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
};

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

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { brighten, darken } from "@core/util/color.utils";
77
import { parseCompassEventDate } from "@core/util/event/event.util";
88
import { theme } from "@web/common/styles/theme";
99
import { hoverColorByPriority } from "@web/common/styles/theme.util";
10-
import { ConditionalRender } from "@web/components/ConditionalRender/conditional-render";
1110
import { DatePicker } from "@web/components/DatePicker/DatePicker";
1211
import { Flex } from "@web/components/Flex";
1312
import { RepeatIcon } from "@web/components/Icons/Repeat";
@@ -59,22 +58,20 @@ const RecurrenceToggle = ({
5958
}) => {
6059
return (
6160
<StyledRepeatRow>
62-
<ConditionalRender condition={!hasRecurrence}>
61+
{!hasRecurrence ? (
6362
<StyledRepeatContainer onClick={toggleRecurrence}>
6463
<StyledRepeatText hasRepeat={hasRecurrence} tabIndex={0}>
6564
Does not repeat
6665
</StyledRepeatText>
6766
</StyledRepeatContainer>
68-
</ConditionalRender>
69-
70-
<ConditionalRender condition={hasRecurrence}>
67+
) : (
7168
<StyledRepeatTextContainer onClick={toggleRecurrence}>
7269
<RepeatIcon />
7370
<StyledRepeatText hasRepeat={hasRecurrence}>
7471
Repeats every
7572
</StyledRepeatText>
7673
</StyledRepeatTextContainer>
77-
</ConditionalRender>
74+
)}
7875
</StyledRepeatRow>
7976
);
8077
};
@@ -236,37 +233,39 @@ export const SomedayRecurrenceSection = ({
236233
marginBottom: 10,
237234
}}
238235
>
239-
<ConditionalRender condition={hasRecurrence}>
236+
{hasRecurrence && (
240237
<EditRecurrence
241238
open={showForm}
242239
onClick={() => setShowForm((value) => !value)}
243240
/>
244-
</ConditionalRender>
241+
)}
245242

246-
<ConditionalRender condition={hasRecurrence ? showForm : true}>
243+
{(!hasRecurrence || showForm) && (
247244
<RecurrenceToggle
248245
hasRecurrence={hasRecurrence}
249246
toggleRecurrence={toggleRecurrence}
250247
/>
251-
</ConditionalRender>
248+
)}
252249

253-
<ConditionalRender condition={hasRecurrence && showForm}>
254-
<SomedayFreqSelect
255-
bgColor={bgColor}
256-
value={freq}
257-
onFreqSelect={setFreq}
258-
/>
250+
{hasRecurrence && showForm && (
251+
<>
252+
<SomedayFreqSelect
253+
bgColor={bgColor}
254+
value={freq}
255+
onFreqSelect={setFreq}
256+
/>
259257

260-
<EndsOnDate
261-
bgColor={bgColor}
262-
inputColor={
263-
hoverColorByPriority[event.priority ?? Priorities.UNASSIGNED]
264-
}
265-
until={until}
266-
minDate={event.endDate}
267-
setUntil={setUntil}
268-
/>
269-
</ConditionalRender>
258+
<EndsOnDate
259+
bgColor={bgColor}
260+
inputColor={
261+
hoverColorByPriority[event.priority ?? Priorities.UNASSIGNED]
262+
}
263+
until={until}
264+
minDate={event.endDate}
265+
setUntil={setUntil}
266+
/>
267+
</>
268+
)}
270269
</StyledRepeatRow>
271270
);
272271
};

0 commit comments

Comments
 (0)