Skip to content

Commit

Permalink
Add error message and increase limit to 15 for repeated booking (#31)
Browse files Browse the repository at this point in the history
* Add error message, increase cap to 15 repeats

* Remove Popup import
  • Loading branch information
lynnetteeee authored Feb 27, 2024
1 parent aa81852 commit 8a150b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@
gap: 1rem;
text-align: center;
}

.errorMsg {
color: red;
margin-left: 0.5rem;
margin-top: 0.5rem;
margin-bottom: -0.8rem;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ import {
import styles from "./calendar-booking-repeat-modal.module.scss";
import { CalendarBooking } from "../booking-calendar";

const MAX_REPEAT_TIMES = 10;
const MAX_REPEAT_TIMES = 15;

type Props = {
event: CalendarBooking | null;
setEvent: React.Dispatch<React.SetStateAction<CalendarBooking | null>>;
} & Pick<ReturnType<typeof useBookingCreationCalendarState>, "onRepeatSlot">;

function CalendarBookingRepeatModal({ event, setEvent, onRepeatSlot }: Props) {
const [isError, setIsError] = useState(false);
const [occurrences, setOccurrences] = useState("1");

const repeatedTimeslots = useMemo(() => {
Expand Down Expand Up @@ -48,6 +49,9 @@ function CalendarBookingRepeatModal({ event, setEvent, onRepeatSlot }: Props) {
(re.test(value) && Number(value) <= MAX_REPEAT_TIMES)
) {
setOccurrences(value);
setIsError(false);
} else {
setIsError(true);
}
}}
value={occurrences}
Expand All @@ -56,6 +60,11 @@ function CalendarBookingRepeatModal({ event, setEvent, onRepeatSlot }: Props) {
<input className={styles.repeatInput} />
<Label basic>times</Label>
</Input>
{isError && (
<p className={styles.errorMsg}>
Enter a number between 1 and {MAX_REPEAT_TIMES}
</p>
)}
<Header>Preview Repeated Dates</Header>
<div className={styles.bookingPreviewGrid}>
{repeatedTimeslots.map((range, index) => (
Expand Down

0 comments on commit 8a150b3

Please sign in to comment.