1 import { c } from 'ttag';
3 import Table from '@proton/components/components/table/Table';
4 import TableBody from '@proton/components/components/table/TableBody';
5 import TableCell from '@proton/components/components/table/TableCell';
6 import TableHeader from '@proton/components/components/table/TableHeader';
7 import TableHeaderCell from '@proton/components/components/table/TableHeaderCell';
8 import TableRow from '@proton/components/components/table/TableRow';
9 import type { Address, IncomingAddressForwarding } from '@proton/shared/lib/interfaces';
11 import ForwardStatus from './ForwardStatus';
12 import IncomingForwardActions from './IncomingForwardActions';
13 import WarningChainedForwarding from './WarningChainedForwarding';
18 forwardings: IncomingAddressForwarding[];
19 chainedEmails: string[];
22 const IncomingForwardTable = ({ addresses, loading, forwardings, chainedEmails }: Props) => {
24 <Table responsive="cards" hasActions={!!forwardings.length}>
27 <TableHeaderCell>{c('email_forwarding_2023: Header').t`From`}</TableHeaderCell>
28 <TableHeaderCell>{c('email_forwarding_2023: Header').t`To`}</TableHeaderCell>
29 <TableHeaderCell className="w-custom" style={{ '--w-custom': '11em' }}>{c(
30 'email_forwarding_2023: Header'
31 ).t`Status`}</TableHeaderCell>
32 <TableHeaderCell className="w-custom" style={{ '--w-custom': '9em' }}>{c(
33 'email_forwarding_2023: Header'
34 ).t`Actions`}</TableHeaderCell>
37 <TableBody loading={loading} colSpan={4}>
38 {forwardings.length === 0 && (
40 <TableCell colSpan={4} className="text-center">{c('email_forwarding_2023: Info')
41 .t`No incoming forwarding rules`}</TableCell>
44 {forwardings.map((forward) => {
45 const from = forward.ForwarderEmail;
46 const toAddress = addresses.find(({ ID }) => ID === forward.ForwardeeAddressID);
47 if (toAddress === undefined) {
50 const to = toAddress.Email;
52 <TableRow key={forward.ID}>
53 <TableCell label={c('email_forwarding_2023: Header').t`From`}>
54 <div className="text-ellipsis" title={from}>
58 <TableCell label={c('email_forwarding_2023: Header').t`To`}>
59 <div className="text-ellipsis">
60 <WarningChainedForwarding chainedEmails={chainedEmails} forwardEmail={to} />
61 <span title={to}>{to}</span>
64 <TableCell label={c('email_forwarding_2023: Header').t`Status`}>
65 <ForwardStatus forward={forward} />
68 <IncomingForwardActions forward={forward} addresses={addresses} />
78 export default IncomingForwardTable;