diff --git a/assets/components/tracking/connector/ConnectorForm.tsx b/assets/components/tracking/connector/ConnectorForm.tsx index 273aa7a..97b1824 100644 --- a/assets/components/tracking/connector/ConnectorForm.tsx +++ b/assets/components/tracking/connector/ConnectorForm.tsx @@ -1,302 +1,8 @@ import type {FormInstance} from 'antd' -import {Alert, Button, Checkbox, Form, Input, Popconfirm, Select, Space, Typography} from 'antd' -import React, {useState} from 'react' import type {Connector} from '../../../utils/api/connectors' import {ConnectorProvider} from '../../../utils/api/connectors' -import {t} from 'ttag' -import {BankOutlined} from '@ant-design/icons' -import { - ovhEndpointList as ovhEndpointListFunction, - ovhFields as ovhFieldsFunction, - ovhPricingMode as ovhPricingModeFunction, - ovhSubsidiaryList as ovhSubsidiaryListFunction -} from '../../../utils/providers/ovh' -import {helpGetTokenLink, tosHyperlink} from '../../../utils/providers' - -const formItemLayoutWithOutLabel = { - wrapperCol: { - xs: {span: 24, offset: 0}, - sm: {span: 20, offset: 4} - } -} +import {providersConfig} from "../../../utils/providers" export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { - const [provider, setProvider] = useState() - const ovhFields = ovhFieldsFunction() - const ovhEndpointList = ovhEndpointListFunction() - const ovhSubsidiaryList = ovhSubsidiaryListFunction() - const ovhPricingMode = ovhPricingModeFunction() - const [open, setOpen] = useState(false) - const [ovhPricingModeValue, setOvhPricingModeValue] = useState() - - return ( -
- - - ) - } - - - - - - { - form.resetFields(['authData']) - setOvhPricingModeValue(undefined) - setOpen(false) - }} - onConfirm={() => setOpen(false)} - open={open} - > - - - {t`It indicates the organization that will pay for the ordered product`} - } - required={false} - > - - - - } - { - provider === ConnectorProvider.AutoDNS && <> -
- {t`Attention: AutoDNS do not support 2-Factor Authentication on API Users for automated systems`} - } - rules={[{required: true, message: t`Required`}]} - > - - - - - - {t`The nic-handle of the domain name owner`}{t`You can get it from this page`} - - } - rules={[{required: true, message: t`Required`}]} - required - > - - - - {t`If you not sure, use the default value 4`} - } - - required={false} - > - - - - {t`Owner confirms his consent of domain order jobs`} - - - - - } - { - provider === ConnectorProvider.Namecheap && <> - - - - - - - - } - { - provider === ConnectorProvider['Name.com'] && <> - - - - - - - - } - - - - {t`I have read and accepted the conditions of use of the Provider API, accessible from this hyperlink`} - - - - - {t`I am of the minimum age required to consent to these conditions`} - - - - {t`I waive my right of withdrawal regarding the purchase of domain names via the Provider's API`} - - - - } - - - - - - - -
- ) + return providersConfig()[ConnectorProvider.OVHcloud].form({form, onCreate}) } diff --git a/assets/components/tracking/connector/ConnectorsList.tsx b/assets/components/tracking/connector/ConnectorsList.tsx index 131154b..6586f0b 100644 --- a/assets/components/tracking/connector/ConnectorsList.tsx +++ b/assets/components/tracking/connector/ConnectorsList.tsx @@ -4,8 +4,7 @@ import {DeleteFilled} from '@ant-design/icons' import React from 'react' import type {Connector} from '../../../utils/api/connectors' import { ConnectorProvider, deleteConnector} from '../../../utils/api/connectors' -import {tosHyperlink} from "../../../utils/providers" - +import {providersConfig} from "../../../utils/providers" const {useToken} = theme export type ConnectorElement = Connector & { id: string, createdAt: string, watchlistCount: number } @@ -51,7 +50,7 @@ export function ConnectorsList({connectors, onDelete}: { connectors: ConnectorEl {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.`}   - + {t`The Provider’s conditions are accessible by following this hyperlink.`} diff --git a/assets/utils/providers/forms/AutoDnsConnectorForm.tsx b/assets/utils/providers/forms/AutoDnsConnectorForm.tsx new file mode 100644 index 0000000..48358a2 --- /dev/null +++ b/assets/utils/providers/forms/AutoDnsConnectorForm.tsx @@ -0,0 +1,101 @@ +import type {FormInstance} from 'antd' +import {Alert, Checkbox, Form, Input, Typography} from 'antd' +import React from 'react' +import type {Connector} from '../../../utils/api/connectors' +import {ConnectorProvider} from '../../../utils/api/connectors' +import {t} from 'ttag' +import {DefaultConnectorFormItems} from "../../../utils/providers/forms" +import {providersConfig} from "../index" + +const formItemLayoutWithOutLabel = { + wrapperCol: { + xs: {span: 24, offset: 0}, + sm: {span: 20, offset: 4} + } +} + +export function AutoDnsConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { + + return ( +
+ + + +
+ {t`Attention: AutoDNS do not support 2-Factor Authentication on API Users for automated systems`} + } + rules={[{required: true, message: t`Required`}]} + > + + + + + + {t`The nic-handle of the domain name owner`}{t`You can get it from this page`} + + } + rules={[{required: true, message: t`Required`}]} + required + > + + + + {t`If you not sure, use the default value 4`} + } + + required={false} + > + + + + {t`Owner confirms his consent of domain order jobs`} + + + + + + ) +} diff --git a/assets/utils/providers/forms/GandiConnectorForm.tsx b/assets/utils/providers/forms/GandiConnectorForm.tsx new file mode 100644 index 0000000..359fbc0 --- /dev/null +++ b/assets/utils/providers/forms/GandiConnectorForm.tsx @@ -0,0 +1,55 @@ +import type {FormInstance} from 'antd' +import {Form, Input, Typography} from 'antd' +import React from 'react' +import type {Connector} from '../../api/connectors' +import {ConnectorProvider} from '../../api/connectors' +import {t} from 'ttag' +import {DefaultConnectorFormItems} from "./index" +import {providersConfig} from "../index" + +const formItemLayoutWithOutLabel = { + wrapperCol: { + xs: {span: 24, offset: 0}, + sm: {span: 20, offset: 4} + } +} + +export function GandiConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { + + return ( +
+ + + + + + {t`It indicates the organization that will pay for the ordered product`} + } + required={false} + > + + + + + + + ) +} diff --git a/assets/utils/providers/forms/NamecheapConnectorForm.tsx b/assets/utils/providers/forms/NamecheapConnectorForm.tsx new file mode 100644 index 0000000..d3c85c7 --- /dev/null +++ b/assets/utils/providers/forms/NamecheapConnectorForm.tsx @@ -0,0 +1,51 @@ +import type {FormInstance} from 'antd' +import {Form, Input} from 'antd' +import React from 'react' +import type {Connector} from '../../../utils/api/connectors' +import {ConnectorProvider} from '../../../utils/api/connectors' +import {t} from 'ttag' +import {DefaultConnectorFormItems} from "../../../utils/providers/forms" +import {providersConfig} from "../index" + +const formItemLayoutWithOutLabel = { + wrapperCol: { + xs: {span: 24, offset: 0}, + sm: {span: 20, offset: 4} + } +} + +export function NamecheapConnectorForm({form, onCreate}: { + form: FormInstance, + onCreate: (values: Connector) => void +}) { + + return ( +
+ + + + + + + + + + + + ) +} diff --git a/assets/utils/providers/forms/NamecomConnectorForm.tsx b/assets/utils/providers/forms/NamecomConnectorForm.tsx new file mode 100644 index 0000000..4aefa0b --- /dev/null +++ b/assets/utils/providers/forms/NamecomConnectorForm.tsx @@ -0,0 +1,51 @@ +import type {FormInstance} from 'antd' +import {Alert, Form, Input} from 'antd' +import React from 'react' +import type {Connector} from '../../../utils/api/connectors' +import {ConnectorProvider} from '../../../utils/api/connectors' +import {t} from 'ttag' +import {DefaultConnectorFormItems} from "../../../utils/providers/forms" +import {providersConfig} from "../index" + +const formItemLayoutWithOutLabel = { + wrapperCol: { + xs: {span: 24, offset: 0}, + sm: {span: 20, offset: 4} + } +} + +export function NamecomConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { + + return ( +
+ + + + + + + + + + + ) +} diff --git a/assets/utils/providers/forms/OvhCloudConnectorForm.tsx b/assets/utils/providers/forms/OvhCloudConnectorForm.tsx new file mode 100644 index 0000000..ebb5643 --- /dev/null +++ b/assets/utils/providers/forms/OvhCloudConnectorForm.tsx @@ -0,0 +1,121 @@ +import {t} from 'ttag' +import {regionNames} from "../../../i18n" +import React, {useState} from 'react' +import type { FormInstance} from "antd" +import {Form, Input, Popconfirm, Select} from "antd" +import type {Connector} from "../../api/connectors" +import { ConnectorProvider} from "../../api/connectors" +import {DefaultConnectorFormItems} from "./index" +import {providersConfig} from "../index" + +const ovhFieldsFunction = () => ({ + appKey: t`Application key`, + appSecret: t`Application secret`, + consumerKey: t`Consumer key` +}) + +const ovhEndpointListFunction = () => [ + { + label: t`European Region`, + value: 'ovh-eu' + } +] + +const ovhSubsidiaryListFunction = () => [...[ + 'CZ', 'DE', 'ES', 'FI', 'FR', 'GB', 'IE', 'IT', 'LT', 'MA', 'NL', 'PL', 'PT', 'SN', 'TN' +].map(c => ({value: c, label: regionNames.of(c) ?? c})), {value: 'EU', label: t`Europe`}] + +const ovhPricingModeFunction = () => [ + {value: 'create-default', label: t`The domain is free and at the standard price`}, + { + value: 'create-premium', + label: t`The domain is free but can be premium. Its price varies from one domain to another` + } +] + +const formItemLayoutWithOutLabel = { + wrapperCol: { + xs: {span: 24, offset: 0}, + sm: {span: 20, offset: 4} + } +} + +export function OvhCloudConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { + const ovhFields = ovhFieldsFunction() + const ovhEndpointList = ovhEndpointListFunction() + const ovhSubsidiaryList = ovhSubsidiaryListFunction() + const ovhPricingMode = ovhPricingModeFunction() + const [open, setOpen] = useState(false) + const [ovhPricingModeValue, setOvhPricingModeValue] = useState() + + return ( +
+ + + { + Object.keys(ovhFields).map(fieldName => + + ) + } + + + + + + { + form.resetFields(['authData']) + setOvhPricingModeValue(undefined) + setOpen(false) + }} + onConfirm={() => setOpen(false)} + open={open} + > +