docs: add text on watchlist

This commit is contained in:
Maël Gangloff
2025-01-03 15:40:22 +01:00
parent 8b8e6ddbe5
commit fcd5c2e861
3 changed files with 68 additions and 32 deletions

View File

@@ -1,13 +1,13 @@
import {Card, Divider, message, Popconfirm, theme, Typography} from 'antd' import {Card, Divider, message, Popconfirm, Space, theme, Typography} from 'antd'
import {t} from 'ttag' import {jt, t} from 'ttag'
import {DeleteFilled} from '@ant-design/icons' import {DeleteFilled} from '@ant-design/icons'
import React from 'react' import React from 'react'
import type {Connector} from '../../../utils/api/connectors' import type {Connector} from '../../../utils/api/connectors'
import { deleteConnector} from '../../../utils/api/connectors' import {deleteConnector} from '../../../utils/api/connectors'
const {useToken} = theme const {useToken} = theme
export type ConnectorElement = Connector & { id: string, createdAt: string } export type ConnectorElement = Connector & { id: string, createdAt: string, watchlistCount: number }
export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) { export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorElement[], onDelete: () => void }) {
const {token} = useToken() const {token} = useToken()
@@ -19,29 +19,37 @@ export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorEl
return ( return (
<> <>
{connectors.map(connector => {connectors.map(connector => {
<> const createdAt = <Typography.Text strong>
{contextHolder} {new Date(connector.createdAt).toLocaleString()}
<Card </Typography.Text>
hoverable title={<Typography.Text const {watchlistCount} = connector
title={new Date(connector.createdAt).toLocaleString()}
>{t`Connector ${connector.provider}`} return <>
</Typography.Text>} {contextHolder}
size='small' <Card
style={{width: '100%'}} hoverable title={<Space>
extra={<Popconfirm {t`Connector ${connector.provider}`}<Typography.Text code>{connector.id}</Typography.Text>
title={t`Delete the Connector`} </Space>}
description={t`Are you sure to delete this Connector?`} size='small'
onConfirm={async () => await onConnectorDelete(connector)} style={{width: '100%'}}
okText={t`Yes`} extra={<Popconfirm
cancelText={t`No`} title={t`Delete the Connector`}
><DeleteFilled style={{color: token.colorError}}/> description={t`Are you sure to delete this Connector?`}
</Popconfirm>} onConfirm={async () => await onConnectorDelete(connector)}
> okText={t`Yes`}
<Card.Meta description={connector.id} style={{marginBottom: '1em'}}/> cancelText={t`No`}
</Card> ><DeleteFilled style={{color: token.colorError}}/>
<Divider/> </Popconfirm>}
</> >
<Typography.Paragraph>{jt`Creation date: ${createdAt}`}</Typography.Paragraph>
<Typography.Paragraph>{t`Used in: ${watchlistCount} Watchlist`}</Typography.Paragraph>
<Card.Meta description={t`You can stop using a connector at any time. To delete a connector, you must remove it from each linked Watchlist.
The creation date corresponds to the date on which you consented to the creation of the connector and on which you declared in particular that you fulfilled the conditions of use of the supplier's API, waived the right of withdrawal and were of the minimum age to consent to these conditions.`}/>
</Card>
<Divider/>
</>
}
)} )}
</> </>
) )

View File

@@ -67,6 +67,9 @@ class Connector
#[ORM\Column] #[ORM\Column]
private ?\DateTimeImmutable $createdAt = null; private ?\DateTimeImmutable $createdAt = null;
#[Groups(['connector:list'])]
protected int $watchlistCount;
public function __construct() public function __construct()
{ {
$this->id = Uuid::v4(); $this->id = Uuid::v4();
@@ -155,4 +158,9 @@ class Connector
return $this; return $this;
} }
public function getWatchlistCount(): ?int
{
return $this->watchLists->count();
}
} }

View File

@@ -361,29 +361,49 @@ msgid ""
"any Watchlist" "any Watchlist"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:28 #: assets/components/tracking/connector/ConnectorsList.tsx:32
#, javascript-format #, javascript-format
msgid "Connector ${ connector.provider }" msgid "Connector ${ connector.provider }"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:33 #: assets/components/tracking/connector/ConnectorsList.tsx:37
msgid "Delete the Connector" msgid "Delete the Connector"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:34 #: assets/components/tracking/connector/ConnectorsList.tsx:38
msgid "Are you sure to delete this Connector?" msgid "Are you sure to delete this Connector?"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:36 #: assets/components/tracking/connector/ConnectorsList.tsx:40
#: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:16 #: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:16
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:37 #: assets/components/tracking/connector/ConnectorsList.tsx:41
#: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:17 #: assets/components/tracking/watchlist/DeleteWatchlistButton.tsx:17
msgid "No" msgid "No"
msgstr "" msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:45
#, javascript-format
msgid "Creation date: ${ createdAt }"
msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:46
#, javascript-format
msgid "Used in: ${ watchlistCount } Watchlist"
msgstr ""
#: assets/components/tracking/connector/ConnectorsList.tsx:47
msgid ""
"You can stop using a connector at any time. To delete a connector, you must "
"remove it from each linked Watchlist.\n"
"The creation date corresponds to the date on which you consented to the "
"creation of the connector and on which you declared in particular that you "
"fulfilled the conditions of use of the supplier's API, waived the right of "
"withdrawal and were of the minimum age to consent to these conditions."
msgstr ""
#: assets/components/tracking/watchlist/CalendarWatchlistButton.tsx:15 #: assets/components/tracking/watchlist/CalendarWatchlistButton.tsx:15
msgid "QR Code for iCalendar export" msgid "QR Code for iCalendar export"
msgstr "" msgstr ""