2024-08-04 17:16:00 +02:00
|
|
|
import {Card, Divider, Popconfirm, theme, Typography} from "antd";
|
2024-07-29 19:37:17 +02:00
|
|
|
import {t} from "ttag";
|
|
|
|
|
import {DeleteFilled} from "@ant-design/icons";
|
|
|
|
|
import React from "react";
|
2024-08-16 13:56:52 +02:00
|
|
|
import {Connector, deleteConnector} from "../../../utils/api/connectors";
|
2024-07-29 19:37:17 +02:00
|
|
|
|
2024-08-02 16:17:55 +02:00
|
|
|
const {useToken} = theme;
|
|
|
|
|
|
|
|
|
|
|
2024-08-04 17:16:00 +02:00
|
|
|
export type ConnectorElement = Connector & { id: string, createdAt: string }
|
2024-07-29 19:37:17 +02:00
|
|
|
|
|
|
|
|
export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) {
|
2024-08-02 16:17:55 +02:00
|
|
|
const {token} = useToken()
|
|
|
|
|
|
2024-07-29 19:37:17 +02:00
|
|
|
return <>
|
|
|
|
|
{connectors.map(connector =>
|
|
|
|
|
<>
|
2024-08-08 14:00:21 +02:00
|
|
|
<Card hoverable title={<Typography.Text
|
2024-08-04 17:16:00 +02:00
|
|
|
title={new Date(connector.createdAt).toLocaleString()}>{t`Connector ${connector.provider}`}</Typography.Text>}
|
2024-08-02 17:23:27 +02:00
|
|
|
size='small'
|
2024-08-04 17:16:00 +02:00
|
|
|
style={{width: '100%'}}
|
2024-08-02 17:23:27 +02:00
|
|
|
extra={<Popconfirm title={t`Delete the Connector`}
|
|
|
|
|
description={t`Are you sure to delete this Connector?`}
|
|
|
|
|
onConfirm={() => deleteConnector(connector.id).then(onDelete)}
|
|
|
|
|
okText={t`Yes`}
|
|
|
|
|
cancelText={t`No`}
|
|
|
|
|
><DeleteFilled style={{color: token.colorError}}/></Popconfirm>}>
|
|
|
|
|
<Card.Meta description={connector.id} style={{marginBottom: '1em'}}/>
|
2024-07-29 19:37:17 +02:00
|
|
|
</Card>
|
|
|
|
|
<Divider/>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
}
|