/**
 * Shared mailbox selector — switch between personal and shared accounts.
 */

import React from 'react';
import { useTranslation } from 'react-i18next';
import { Select } from '@/components/ui/Select';
import type { MailAccount } from '@/api/mail';

export interface SharedMailboxSelectorProps {
  accounts: MailAccount[];
  selectedAccountId: string;
  onSelect: (accountId: string) => void;
}

export function SharedMailboxSelector({ accounts, selectedAccountId, onSelect }: SharedMailboxSelectorProps) {
  const { t } = useTranslation();

  const options = accounts.map((acc) => ({
    value: acc.id,
    label: `${acc.display_name} (${acc.email})${acc.is_shared ? ' — ' + t('mail.shared') : ''}`,
  }));

  return (
    <div data-testid="shared-mailbox-selector">
      <Select
        label={t('mail.selectAccount')}
        value={selectedAccountId}
        onChange={(e) => onSelect(e.target.value)}
        options={options}
      />
    </div>
  );
}
