'use client'; import { FC, useMemo, useState } from 'react'; import { Select } from '@gitroom/react/form/select'; import { useT } from '@gitroom/react/translation/get.transation.service.client'; import { useClickOutside } from '@mantine/hooks'; import { isUSCitizen } from '@gitroom/frontend/components/launches/helpers/isuscitizen.utils'; import clsx from 'clsx'; import { RepeatIcon, DropdownArrowIcon } from '@gitroom/frontend/components/ui/icons'; const getList = (t: (key: string, fallback: string) => string) => [ { value: 1, label: t('day', 'Day'), }, { value: 2, label: t('two_days', 'Two Days'), }, { value: 3, label: t('three_days', 'Three Days'), }, { value: 4, label: t('four_days', 'Four Days'), }, { value: 5, label: t('five_days', 'Five Days'), }, { value: 6, label: t('six_days', 'Six Days'), }, { value: 7, label: t('week', 'Week'), }, { value: 14, label: t('two_weeks', 'Two Weeks'), }, { value: 30, label: t('month', 'Month'), }, { value: null, label: t('cancel', 'Cancel'), }, ]; export const RepeatComponent: FC<{ repeat: number | null; onChange: (newVal: number) => void; }> = (props) => { const { repeat } = props; const t = useT(); const list = getList(t); const [isOpen, setIsOpen] = useState(false); const ref = useClickOutside(() => { if (!isOpen) { return; } setIsOpen(false); }); const everyLabel = useMemo(() => { if (!repeat) { return ''; } return list.find((p) => p.value === repeat)?.label; }, [repeat, list]); return (