import { useTranslation } from "react-i18next"; import { SendouDialog } from "~/components/elements/Dialog"; import { useUser } from "~/features/auth/core/user"; import { FormField } from "~/form/FormField"; import { SendouForm } from "~/form/SendouForm"; import { SCHEDULE_VISIBILITY_FRIENDS_VALUE } from "../availability-constants"; import { saveScheduleVisibilitySchema } from "../availability-schemas"; import type { ScheduleAudienceTeam } from "../availability-types"; /** Picks the friends and teams the user's schedule is shared with. Nothing saved yet means everyone. */ export function ScheduleVisibilityDialog({ teams, close, }: { teams: Array; close: () => void; }) { const { t } = useTranslation(["schedule"]); const user = useUser(); const saved = user?.preferences.scheduleVisibility; const teamValues = teams.map((team) => String(team.id)); return ( saved.teamIds.includes(team.id)) .map((team) => String(team.id)), ] : [SCHEDULE_VISIBILITY_FRIENDS_VALUE, ...teamValues], }} > t("schedule:visibility.allFriends"), }, ...teams.map((team) => ({ value: String(team.id), label: () => team.name, })), ]} /> ); }