2022-12-27 01:57:59 +01:00
|
|
|
import Link from 'next/link';
|
|
|
|
import {
|
|
|
|
Table,
|
|
|
|
TableHeader,
|
|
|
|
TableBody,
|
|
|
|
TableRow,
|
|
|
|
TableCell,
|
|
|
|
TableColumn,
|
|
|
|
Button,
|
2023-01-31 06:44:07 +01:00
|
|
|
Text,
|
2022-12-27 01:57:59 +01:00
|
|
|
Icon,
|
2023-01-19 00:05:39 +01:00
|
|
|
Icons,
|
2023-01-25 16:42:46 +01:00
|
|
|
Flexbox,
|
2022-12-27 01:57:59 +01:00
|
|
|
} from 'react-basics';
|
2023-01-31 06:44:07 +01:00
|
|
|
import { useIntl } from 'react-intl';
|
|
|
|
import { labels } from 'components/messages';
|
2023-01-21 02:12:53 +01:00
|
|
|
|
|
|
|
export default function WebsitesTable({ data = [] }) {
|
2023-01-25 16:42:46 +01:00
|
|
|
const { formatMessage } = useIntl();
|
|
|
|
|
|
|
|
const columns = [
|
2023-01-31 06:44:07 +01:00
|
|
|
{ name: 'name', label: formatMessage(labels.name), style: { flex: 2 } },
|
|
|
|
{ name: 'domain', label: formatMessage(labels.domain) },
|
2023-01-25 16:42:46 +01:00
|
|
|
{ name: 'action', label: ' ' },
|
|
|
|
];
|
|
|
|
|
2022-12-27 01:57:59 +01:00
|
|
|
return (
|
2023-01-25 16:42:46 +01:00
|
|
|
<Table columns={columns} rows={data}>
|
2022-12-27 01:57:59 +01:00
|
|
|
<TableHeader>
|
|
|
|
{(column, index) => {
|
|
|
|
return (
|
|
|
|
<TableColumn key={index} style={{ ...column.style }}>
|
|
|
|
{column.label}
|
|
|
|
</TableColumn>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</TableHeader>
|
|
|
|
<TableBody>
|
|
|
|
{(row, keys, rowIndex) => {
|
|
|
|
const { id } = row;
|
|
|
|
|
|
|
|
row.action = (
|
2023-01-25 16:42:46 +01:00
|
|
|
<Flexbox flex={1} justifyContent="end" gap={10}>
|
2023-01-10 08:59:26 +01:00
|
|
|
<Link href={`/settings/websites/${id}`}>
|
2022-12-27 01:57:59 +01:00
|
|
|
<a>
|
|
|
|
<Button>
|
2023-01-19 00:05:39 +01:00
|
|
|
<Icon>
|
2023-02-04 17:59:52 +01:00
|
|
|
<Icons.Edit />
|
2023-01-19 00:05:39 +01:00
|
|
|
</Icon>
|
2023-02-04 17:59:52 +01:00
|
|
|
<Text>{formatMessage(labels.edit)}</Text>
|
2022-12-27 01:57:59 +01:00
|
|
|
</Button>
|
|
|
|
</a>
|
|
|
|
</Link>
|
2023-01-10 09:13:32 +01:00
|
|
|
<Link href={`/websites/${id}`}>
|
|
|
|
<a>
|
2022-12-27 01:57:59 +01:00
|
|
|
<Button>
|
|
|
|
<Icon>
|
2023-01-28 06:53:13 +01:00
|
|
|
<Icons.External />
|
2022-12-27 01:57:59 +01:00
|
|
|
</Icon>
|
2023-02-04 17:59:52 +01:00
|
|
|
<Text>{formatMessage(labels.view)}</Text>
|
2022-12-27 01:57:59 +01:00
|
|
|
</Button>
|
|
|
|
</a>
|
|
|
|
</Link>
|
2023-01-25 16:42:46 +01:00
|
|
|
</Flexbox>
|
2022-12-27 01:57:59 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<TableRow key={rowIndex} data={row} keys={keys}>
|
|
|
|
{(data, key, colIndex) => {
|
|
|
|
return (
|
2023-01-25 16:42:46 +01:00
|
|
|
<TableCell key={colIndex} style={{ ...columns[colIndex]?.style }}>
|
|
|
|
<Flexbox flex={1} alignItems="center">
|
|
|
|
{data[key]}
|
|
|
|
</Flexbox>
|
2022-12-27 01:57:59 +01:00
|
|
|
</TableCell>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</TableRow>
|
|
|
|
);
|
|
|
|
}}
|
|
|
|
</TableBody>
|
|
|
|
</Table>
|
|
|
|
);
|
|
|
|
}
|