import type { PackingVisibility } from '@trek/shared'; import { Check, Loader2, Share2, UserRound, Users } from 'lucide-react'; import { type ReactNode, useId } from 'react'; import { useTranslation } from '../../i18n'; import { DialogButton, DialogFooter, DialogHeader, DialogShell, DialogTile, FooterSpacer, NEUTRAL_TINT, fs, } from '../shared/DialogShell'; import type { PackingCategorySharing } from './usePackingCategorySharing'; import type { TripMember } from './usePackingListPanel'; /** * The desktop's choice of one sharing tier for a whole packing list (#2961): the * same three tiers as an item's own sharing control, the people to share with * under the third, and a note on the items that belong to someone else. */ export default function PackingCategorySharingDialog({ sharing, tripMembers, currentUserId, }: { sharing: PackingCategorySharing; tripMembers: TripMember[]; currentUserId: number | null | undefined; }) { const { t } = useTranslation(); const labelId = useId(); const { category, visibility, recipientIds, ownCount, othersCount, busy, ready } = sharing; const others = tripMembers.filter((m) => m.id !== currentUserId); const needsPeople = visibility === 'shared' && others.length > 0 && recipientIds.length === 0; const tier = (value: PackingVisibility, icon: ReactNode, label: string, hint?: string) => { const on = visibility === value; return ( ); }; return ( } tint={NEUTRAL_TINT} labelId={labelId} onClose={sharing.close} eyebrow={t('packing.menuShareCat')} title={category} /> } footer={ {t('common.cancel')} void sharing.apply()} disabled={!ready} icon={busy ? : undefined} > {t('packing.shareCat.apply')} } >

{ownCount === 0 ? t('packing.shareCat.noneOwn') : t('packing.shareCat.hint')}

{tier('common', , t('packing.viewCommon'), t('packing.tierCommonHint'))} {tier('personal', , t('packing.tierPersonal'), t('packing.tierPersonalHint'))} {tier('shared', , t('packing.tierShared'))} {visibility === 'shared' && (
{others.length === 0 ? (

{t('packing.noOneToShare')}

) : ( others.map((m) => { const picked = recipientIds.includes(m.id); return ( ); }) )}
)}
{needsPeople && (

{t('packing.shareCat.pickPeople')}

)} {ownCount > 0 && othersCount > 0 && (

{t('packing.shareCat.othersKept')}

)}
); }