feat: ovh api conditions checkbox

This commit is contained in:
Maël Gangloff 2024-07-30 17:48:09 +02:00
parent 51e5cb7e36
commit d7682ce4ac
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
5 changed files with 123 additions and 106 deletions

View File

@ -3,7 +3,13 @@ import React, {useState} from "react";
import {Connector, ConnectorProvider} from "../../utils/api/connectors"; import {Connector, ConnectorProvider} from "../../utils/api/connectors";
import {t} from "ttag"; import {t} from "ttag";
import {BankOutlined} from "@ant-design/icons"; import {BankOutlined} from "@ant-design/icons";
import {regionNames} from "../../i18n"; 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 = { const formItemLayoutWithOutLabel = {
wrapperCol: { wrapperCol: {
@ -14,53 +20,10 @@ const formItemLayoutWithOutLabel = {
export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) { export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) {
const [provider, setProvider] = useState<string>() const [provider, setProvider] = useState<string>()
const ovhFields = ovhFieldsFunction()
const ovhFields = { const ovhEndpointList = ovhEndpointListFunction()
appKey: t`Application key`, const ovhSubsidiaryList = ovhSubsidiaryListFunction()
appSecret: t`Application secret`, const ovhPricingMode = ovhPricingModeFunction()
consumerKey: t`Consumer key`
}
const ovhEndpointList = [
{
label: t`European Region`,
value: 'ovh-eu'
}
]
const ovhSubsidiaryList = [{value: 'EU', label: t`Europa`}, ...[
'CZ', 'DE', 'ES', 'FI', 'FR', 'GB', 'IE', 'IT', 'LT', 'MA', 'NL', 'PL', 'PT', 'SN', 'TN'
].map(c => ({value: c, label: regionNames.of(c) ?? c}))]
const ovhPricingMode = [
{value: 'create-default', label: t`The domain is free and at the standard price`},
{
value: 'create-premium',
label: t`The domain is free but is a premium. Its price varies from one domain to another`
}
]
const helpGetTokenLink = (provider?: string) => {
switch (provider) {
case ConnectorProvider.OVH:
return <Typography.Link target='_blank'
href="https://api.ovh.com/createToken/index.cgi?GET=/order/cart/*&POST=/order/cart&POST=/order/cart/*&DELETE=/order/cart/*">
{t`Retrieve a set of tokens from your OVH account`}
</Typography.Link>
default:
return <></>
}
}
const tosHyperlink = (provider?: string) => {
switch (provider) {
case ConnectorProvider.OVH:
return 'https://storage.gra.cloud.ovh.net/v1/AUTH_325716a587c64897acbef9a4a4726e38/contracts/9973515-contrat_genServices-FR-15.1.pdf'
default:
return ''
}
}
return <Form return <Form
{...formItemLayoutWithOutLabel} {...formItemLayoutWithOutLabel}
@ -154,7 +117,7 @@ export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate:
rules={[{required: true, message: t`Required`}]} rules={[{required: true, message: t`Required`}]}
> >
<Checkbox <Checkbox
required={true}>{t`I expressly waive my right of withdrawal regarding the purchase of domain names via the Provider's API.`}</Checkbox> required={true}>{t`I expressly waive my right of withdrawal regarding the purchase of domain names via the Provider's API`}</Checkbox>
</Form.Item> </Form.Item>
</> </>
} }

View File

@ -52,7 +52,7 @@ export default function Page() {
name="username" name="username"
rules={[{required: true, message: t`Required`}]} rules={[{required: true, message: t`Required`}]}
> >
<Input/> <Input autoFocus/>
</Form.Item> </Form.Item>
<Form.Item<FieldType> <Form.Item<FieldType>

View File

@ -0,0 +1,25 @@
import {ConnectorProvider} from "../api/connectors";
import {Typography} from "antd";
import {t} from "ttag";
import React from "react";
export const helpGetTokenLink = (provider?: string) => {
switch (provider) {
case ConnectorProvider.OVH:
return <Typography.Link target='_blank'
href="https://api.ovh.com/createToken/index.cgi?GET=/order/cart/*&POST=/order/cart&POST=/order/cart/*&DELETE=/order/cart/*">
{t`Retrieve a set of tokens from your customer account on the Provider's website`}
</Typography.Link>
default:
return <></>
}
}
export const tosHyperlink = (provider?: string) => {
switch (provider) {
case ConnectorProvider.OVH:
return 'https://www.ovhcloud.com/fr/terms-and-conditions/contracts/'
default:
return ''
}
}

View File

@ -0,0 +1,27 @@
import {t} from "ttag";
import {regionNames} from "../../i18n";
export const ovhFields = () => ({
appKey: t`Application key`,
appSecret: t`Application secret`,
consumerKey: t`Consumer key`
})
export const ovhEndpointList = () => [
{
label: t`European Region`,
value: 'ovh-eu'
}
]
export const ovhSubsidiaryList = () => [...[
'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`}]
export const ovhPricingMode = () => [
{value: 'create-default', label: t`The domain is free and at the standard price`},
{
value: 'create-premium',
label: t`The domain is free but is a premium. Its price varies from one domain to another`
}
]

View File

@ -48,14 +48,14 @@ msgid "ENUM validation expiration"
msgstr "" msgstr ""
#: assets/components/search/DomainSearchBar.tsx:23 #: assets/components/search/DomainSearchBar.tsx:23
#: assets/components/tracking/ConnectorForm.tsx:77 #: assets/components/tracking/ConnectorForm.tsx:40
#: assets/components/tracking/ConnectorForm.tsx:101 #: assets/components/tracking/ConnectorForm.tsx:64
#: assets/components/tracking/ConnectorForm.tsx:109 #: assets/components/tracking/ConnectorForm.tsx:72
#: assets/components/tracking/ConnectorForm.tsx:116 #: assets/components/tracking/ConnectorForm.tsx:79
#: assets/components/tracking/ConnectorForm.tsx:124 #: assets/components/tracking/ConnectorForm.tsx:87
#: assets/components/tracking/ConnectorForm.tsx:132 #: assets/components/tracking/ConnectorForm.tsx:95
#: assets/components/tracking/ConnectorForm.tsx:145 #: assets/components/tracking/ConnectorForm.tsx:108
#: assets/components/tracking/ConnectorForm.tsx:154 #: assets/components/tracking/ConnectorForm.tsx:117
#: assets/components/tracking/WatchlistForm.tsx:115 #: assets/components/tracking/WatchlistForm.tsx:115
#: assets/components/tracking/WatchlistForm.tsx:174 #: assets/components/tracking/WatchlistForm.tsx:174
#: assets/components/tracking/WatchlistForm.tsx:184 #: assets/components/tracking/WatchlistForm.tsx:184
@ -199,99 +199,65 @@ msgstr ""
msgid "Add a Trigger" msgid "Add a Trigger"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:166 #: assets/components/tracking/ConnectorForm.tsx:129
#: assets/components/tracking/WatchlistForm.tsx:237 #: assets/components/tracking/WatchlistForm.tsx:237
msgid "Create" msgid "Create"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:169 #: assets/components/tracking/ConnectorForm.tsx:132
#: assets/components/tracking/WatchlistForm.tsx:240 #: assets/components/tracking/WatchlistForm.tsx:240
msgid "Reset" msgid "Reset"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:19 #: assets/components/tracking/ConnectorForm.tsx:37
msgid "Application key"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:20
msgid "Application secret"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:21
msgid "Consumer key"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:26
msgid "European Region"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:31
msgid "Europa"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:36
msgid "The domain is free and at the standard price"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:39
msgid ""
"The domain is free but is a premium. Its price varies from one domain to "
"another"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:48
msgid "Retrieve a set of tokens from your OVH account"
msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:74
#: assets/components/tracking/ConnectorsList.tsx:21 #: assets/components/tracking/ConnectorsList.tsx:21
msgid "Provider" msgid "Provider"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:80 #: assets/components/tracking/ConnectorForm.tsx:43
msgid "Please select a Provider" msgid "Please select a Provider"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:107 #: assets/components/tracking/ConnectorForm.tsx:70
msgid "OVH Endpoint" msgid "OVH Endpoint"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:114 #: assets/components/tracking/ConnectorForm.tsx:77
msgid "OVH subsidiary" msgid "OVH subsidiary"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:122 #: assets/components/tracking/ConnectorForm.tsx:85
msgid "OVH pricing mode" msgid "OVH pricing mode"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:130 #: assets/components/tracking/ConnectorForm.tsx:93
msgid "API Terms of Service" msgid "API Terms of Service"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:137 #: assets/components/tracking/ConnectorForm.tsx:100
msgid "" msgid ""
"I certify that I have read and accepted the conditions of use of the " "I certify that I have read and accepted the conditions of use of the "
"Provider API, accessible from this hyperlink" "Provider API, accessible from this hyperlink"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:143 #: assets/components/tracking/ConnectorForm.tsx:106
msgid "Legal age" msgid "Legal age"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:148 #: assets/components/tracking/ConnectorForm.tsx:111
msgid "" msgid ""
"I certify on my honor that I am of the minimum age required to consent to " "I certify on my honor that I am of the minimum age required to consent to "
"these conditions" "these conditions"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:152 #: assets/components/tracking/ConnectorForm.tsx:115
msgid "Withdrawal period" msgid "Withdrawal period"
msgstr "" msgstr ""
#: assets/components/tracking/ConnectorForm.tsx:157 #: assets/components/tracking/ConnectorForm.tsx:120
msgid "" msgid ""
"I expressly waive my right of withdrawal regarding the purchase of domain " "I expressly waive my right of withdrawal regarding the purchase of domain "
"names via the Provider's API." "names via the Provider's API"
msgstr "" msgstr ""
#: assets/components/tracking/WatchlistsList.tsx:14 #: assets/components/tracking/WatchlistsList.tsx:14
@ -506,6 +472,42 @@ msgstr ""
msgid "Log in with SSO" msgid "Log in with SSO"
msgstr "" msgstr ""
#: assets/utils/providers/index.tsx:11
msgid ""
"Retrieve a set of tokens from your customer account on the Provider's "
"website"
msgstr ""
#: assets/utils/providers/ovh.tsx:5
msgid "Application key"
msgstr ""
#: assets/utils/providers/ovh.tsx:6
msgid "Application secret"
msgstr ""
#: assets/utils/providers/ovh.tsx:7
msgid "Consumer key"
msgstr ""
#: assets/utils/providers/ovh.tsx:12
msgid "European Region"
msgstr ""
#: assets/utils/providers/ovh.tsx:19
msgid "Europe"
msgstr ""
#: assets/utils/providers/ovh.tsx:22
msgid "The domain is free and at the standard price"
msgstr ""
#: assets/utils/providers/ovh.tsx:25
msgid ""
"The domain is free but is a premium. Its price varies from one domain to "
"another"
msgstr ""
#: assets/App.tsx:71 #: assets/App.tsx:71
msgid "Home" msgid "Home"
msgstr "" msgstr ""