CostCenterSelect.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { useTranslation } from 'react-i18next';
  2. import type { CostCenterSummary } from '../../api/client';
  3. interface CostCenterSelectProps {
  4. costCenters: CostCenterSummary[];
  5. selectedCostCenterId: number | null;
  6. onChange: (costCenterId: number | null) => void;
  7. }
  8. export function CostCenterSelect({
  9. costCenters,
  10. selectedCostCenterId,
  11. onChange,
  12. }: CostCenterSelectProps) {
  13. const { t } = useTranslation();
  14. if (costCenters.length === 0) return null;
  15. return (
  16. <div className="space-y-1">
  17. <label htmlFor="printCostCenter" className="text-sm text-bambu-gray">
  18. {t('printModal.costCenter', 'Cost center')}
  19. </label>
  20. <select
  21. id="printCostCenter"
  22. value={selectedCostCenterId ?? ''}
  23. onChange={(e) => onChange(e.target.value ? Number(e.target.value) : null)}
  24. className="w-full px-3 py-2 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green"
  25. >
  26. {costCenters.map((center) => (
  27. <option key={center.id} value={center.id}>
  28. {center.name}{center.is_private ? ` (${t('printModal.personalDefault', 'Personal')})` : ''}
  29. </option>
  30. ))}
  31. </select>
  32. </div>
  33. );
  34. }