import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted"; import LockIcon from "@mui/icons-material/Lock"; import PublicIcon from "@mui/icons-material/Public"; import { Box, Button, TextField, ToggleButton, ToggleButtonGroup, Typography, } from "@mui/material"; import { useI18n } from "twake-i18n"; import { useState, useEffect } from "react"; import { useAppSelector } from "../../app/hooks"; import { Calendar } from "../../features/Calendars/CalendarTypes"; import { AddDescButton } from "../Event/AddDescButton"; import { ColorPicker } from "./CalendarColorPicker"; export function SettingsTab({ name, setName, description, setDescription, color, setColor, visibility, setVisibility, calendar, }: { name: string; setName: Function; description: string; setDescription: (d: string) => void; color: Record; setColor: Function; visibility: "public" | "private"; setVisibility: Function; calendar?: Calendar; }) { const { t } = useI18n(); const [toggleDesc, setToggleDesc] = useState(Boolean(description)); const userId = useAppSelector((state) => state.user.userData?.openpaasId) ?? ""; const isOwn = calendar ? calendar.id.split("/")[0] === userId : true; useEffect(() => { if (description) setToggleDesc(true); }, [description]); return ( setName(e.target.value)} size="small" margin="dense" /> {t("calendar.color")} setColor(color)} selectedColor={color} /> {isOwn && ( {t("calendar.newEventsVisibility")} val && setVisibility(val)} size="small" > {t("common.all")} {t("common.you")} )} ); }