import { FormControl, InputLabel, Select, SelectChangeEvent, MenuItem, Box, Stack, Paper, Typography, TextField, Checkbox, List, ListItem, FormControlLabel, FormGroup, Radio, RadioGroup, } from "@mui/material"; import { useState } from "react"; import { RepetitionObject } from "../../features/Events/EventsTypes"; export default function RepeatEvent({ repetition, setRepetition, isOwn = true, }: { repetition: RepetitionObject; setRepetition: Function; isOwn?: boolean; }) { console.log(JSON.stringify(repetition)); const repetitionValues = ["day", "week", "month", "year"]; const [interval, setInterval] = useState(repetition.interval ?? 0); const [selectedDays, setSelectedDays] = useState( repetition.selectedDays ?? [] ); const [endOption, setEndOption] = useState(""); const [occurrences, setOccurrences] = useState(repetition.occurrences) ?? 0; const [endDate, setEndDate] = useState(repetition.endDate ?? ""); const days = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"]; const handleDayChange = (day: string) => { setSelectedDays((prev: string[]) => prev.includes(day) ? prev.filter((d) => d !== day) : [...prev, day] ); }; return ( Repetition {repetition.freq && ( Interval: setInterval(Number(e.target.value))} size="small" sx={{ width: 80 }} /> { repetitionValues[ repetitionValues.findIndex((el) => el === repetition.freq) ] } {repetition.freq === "weekly" && ( On days: {days.map((day) => ( handleDayChange(day)} /> } label={day} /> ))} )} End: setEndOption(e.target.value)} > } label="Never" /> } label={ After setOccurrences(Number(e.target.value))} sx={{ width: 100 }} inputProps={{ min: 1 }} disabled={endOption !== "after"} /> occurrences } /> } label={ On setEndDate(e.target.value)} disabled={endOption !== "on"} /> } /> )} ); }