diff --git a/client/src/api/mailIngest.ts b/client/src/api/mailIngest.ts index b7de67331..f38d7fe53 100644 --- a/client/src/api/mailIngest.ts +++ b/client/src/api/mailIngest.ts @@ -24,7 +24,8 @@ export const mailIngestApi = { inbox: (params: { status?: 'open' | 'resolved'; before?: number; limit?: number }): Promise => apiClient.get('/mail-ingest/inbox', { params }).then(data), inboxCount: (): Promise => apiClient.get('/mail-ingest/inbox/count').then(data), - preview: (messageId: number): Promise => apiClient.get(`/mail-ingest/messages/${messageId}/preview`).then(data), + preview: (messageId: number): Promise => + apiClient.get(`/mail-ingest/messages/${messageId}/preview`).then(data), prefill: (candidateId: number): Promise => apiClient.get(`/mail-ingest/candidates/${candidateId}/prefill`).then(data), diff --git a/client/src/components/MailIngest/MailInboxDialog.tsx b/client/src/components/MailIngest/MailInboxDialog.tsx index 4346f190b..a4b2a4423 100644 --- a/client/src/components/MailIngest/MailInboxDialog.tsx +++ b/client/src/components/MailIngest/MailInboxDialog.tsx @@ -1,11 +1,18 @@ -import { useId, type ReactElement } from 'react'; -import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react'; import type { MailIngestInboxEntry } from '@trek/shared'; +import { Copy, FilePlus2, FileText, Inbox, Loader2, Mail, PencilLine, Plus, Sparkles, Trash2 } from 'lucide-react'; +import { useId, type ReactElement } from 'react'; import { useTranslation } from '../../i18n'; import { copyText } from '../../utils/clipboard'; import { formatDate } from '../../utils/formatters'; import { RES_ICONS } from '../Planner/DayPlanSidebar.constants'; -import { DialogButton, DialogHeader, DialogIconButton, DialogShell, DialogTile, NEUTRAL_TINT } from '../shared/DialogShell'; +import { + DialogButton, + DialogHeader, + DialogIconButton, + DialogShell, + DialogTile, + NEUTRAL_TINT, +} from '../shared/DialogShell'; import { useToast } from '../shared/Toast'; import { entryDates, entryTitle, reasonText, type InboxAction } from './mailInboxModel'; import { useMailInbox, type InboxTrip } from './useMailInbox'; @@ -46,7 +53,9 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
- {title} + + {title} + {dates && ( {formatDate(dates.start, locale)} @@ -57,7 +66,10 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp {reason &&
{reasonText(reason, t)}
} {code && (
- + {code} {entry.suggested_trip && ( - {entry.suggested_trip.title} + + {entry.suggested_trip.title} + )} - @@ -83,22 +101,50 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp {busy && } {rest.map((action) => { const look = actionLook(action, t); - return inbox.perform(entry, action)} />; + return ( + inbox.perform(entry, action)} + /> + ); })} {primary && primary !== 'discard' && ( - inbox.perform(entry, primary)}> + inbox.perform(entry, primary)} + > {actionLook(primary, t).label} )} {primary === 'discard' && ( - inbox.perform(entry, 'discard')} /> + inbox.perform(entry, 'discard')} + /> )}
); } -function TripPicker({ trips, onPick, onCancel }: { trips: InboxTrip[]; onPick: (id: number) => void; onCancel: () => void }) { +function TripPicker({ + trips, + onPick, + onCancel, +}: { + trips: InboxTrip[]; + onPick: (id: number) => void; + onCancel: () => void; +}) { const { t, locale } = useTranslation(); return (
@@ -106,9 +152,19 @@ function TripPicker({ trips, onPick, onCancel }: { trips: InboxTrip[]; onPick: (
    {trips.map((trip) => (
  • -
  • ))} @@ -135,7 +191,11 @@ export default function MailInboxDialog(): ReactElement | null { const header = ( } + tile={ + + + + } tint={NEUTRAL_TINT} labelId={titleId} onClose={inbox.close} @@ -145,13 +205,22 @@ export default function MailInboxDialog(): ReactElement | null { ); return ( - + {inbox.picking ? ( ) : inbox.preview ? (
    {inbox.preview.subject ?? t('mailInbox.untitled')}
    -
    {inbox.preview.text}
    +
    +            {inbox.preview.text}
    +          
    {t('mailInbox.backToList')}
    @@ -164,10 +233,14 @@ export default function MailInboxDialog(): ReactElement | null {
    ) : (
      - {inbox.entries.map((entry) => )} + {inbox.entries.map((entry) => ( + + ))} {inbox.hasMore && (
    • - {t('mailInbox.loadMore')} + + {t('mailInbox.loadMore')} +
    • )}
    diff --git a/client/src/components/MailIngest/TripMailForward.tsx b/client/src/components/MailIngest/TripMailForward.tsx index 96b7ff611..c04c59502 100644 --- a/client/src/components/MailIngest/TripMailForward.tsx +++ b/client/src/components/MailIngest/TripMailForward.tsx @@ -1,6 +1,6 @@ import { mailIngestAddressResponseSchema, type MailIngestAddress } from '@trek/shared'; -import { useEffect, useState, type ReactElement } from 'react'; import { Copy, Mail, Plus } from 'lucide-react'; +import { useEffect, useState, type ReactElement } from 'react'; import { mailIngestApi } from '../../api/mailIngest'; import { useTranslation } from '../../i18n'; import { useMailIngestStore } from '../../store/mailIngestStore'; @@ -68,7 +68,10 @@ export default function TripMailForward({ tripId }: { tripId: number }): ReactEl
    {t('mailInbox.trip.hint')}
    {address ? (
    - + {address.address} @@ -63,7 +78,11 @@ export default function MailImportSection(): ReactElement | null { {t('mailInbox.settings.addressHint')}
    - + {t('mailInbox.settings.howTo')}
      @@ -79,7 +98,14 @@ export default function MailImportSection(): ReactElement | null { void s.toggle('enabled')} label={t('mailInbox.settings.enabled')} />} + control={ + void s.toggle('enabled')} + label={t('mailInbox.settings.enabled')} + /> + } /> {t('mailInbox.title')} - {pending > 0 && {pending}} + {pending > 0 && ( + + {pending} + + )} -
      -
      {entryTitle(entry) ?? t('mailInbox.untitled')}
      +
      + {entryTitle(entry) ?? t('mailInbox.untitled')} +
      {dates && (
      {formatDate(dates.start, locale)} {dates.end ? ` → ${formatDate(dates.end, locale)}` : ''}
      )} - {reason &&
      {reasonText(reason, t)}
      } + {reason && ( +
      + {reasonText(reason, t)} +
      + )} {entry.suggested_trip && ( {entry.suggested_trip.title} @@ -80,7 +87,10 @@ function Entry({ entry, inbox }: { entry: MailIngestInboxEntry; inbox: ReturnTyp
      {code && (
      - + {code} {rest.map((action) => ( @@ -153,14 +168,25 @@ export default function MMailInboxSheet(): ReactElement { + ) : ( ) } - title={page === 'pick' ? t('mailInbox.pickTrip') : page === 'mail' ? (inbox.preview?.subject ?? t('mailInbox.untitled')) : t('mailInbox.title')} + title={ + page === 'pick' + ? t('mailInbox.pickTrip') + : page === 'mail' + ? (inbox.preview?.subject ?? t('mailInbox.untitled')) + : t('mailInbox.title') + } sub={page === 'list' ? sub : undefined} onClose={inbox.close} closeLabel={t('common.close')} @@ -176,15 +202,23 @@ export default function MMailInboxSheet(): ReactElement { onClick={() => inbox.pick(trip.id)} className={`flex w-full items-baseline justify-between gap-3 rounded-[14px] px-3 py-[11px] text-start ${INNER_CLS}`} > - {trip.title} - {trip.start_date && {formatDate(trip.start_date, locale)}} + + {trip.title} + + {trip.start_date && ( + + {formatDate(trip.start_date, locale)} + + )} ))}
    )} {page === 'mail' && inbox.preview && ( -
    {inbox.preview.text}
    +
    +            {inbox.preview.text}
    +          
    )} {page === 'list' && inbox.entries.length === 0 && (
    @@ -195,10 +229,17 @@ export default function MMailInboxSheet(): ReactElement { )} {page === 'list' && inbox.entries.length > 0 && (
      - {inbox.entries.map((entry) => )} + {inbox.entries.map((entry) => ( + + ))} {inbox.hasMore && (
    • -
    • diff --git a/client/src/mobile/screens/settings/MMailImportSection.tsx b/client/src/mobile/screens/settings/MMailImportSection.tsx index 4d5f5afde..6927c8cf4 100644 --- a/client/src/mobile/screens/settings/MMailImportSection.tsx +++ b/client/src/mobile/screens/settings/MMailImportSection.tsx @@ -1,8 +1,8 @@ -import { useRef, type ReactElement } from 'react'; import { Copy, FileUp, Inbox, Mail, RefreshCw } from 'lucide-react'; -import { useTranslation } from '../../../i18n'; -import { useMailImportSettings } from '../../../components/MailIngest/useMailImportSettings'; +import { useRef, type ReactElement } from 'react'; import { openMailInbox } from '../../../components/MailIngest/mailInboxOpener'; +import { useMailImportSettings } from '../../../components/MailIngest/useMailImportSettings'; +import { useTranslation } from '../../../i18n'; import MToggle from '../../components/MToggle'; import { MSetButton, MSetCard, MSetEyebrow, MSetHint, MSetRow } from './MSettingsUi'; @@ -27,10 +27,18 @@ export default function MMailImportSection(): ReactElement | null { <> {t('mailInbox.settings.yourAddress')}
      - + {address.address} -