70 lines
3.0 KiB
TypeScript
Raw Normal View History

2025-02-18 18:22:25 +01:00
import type { FormInstance, StepProps} from 'antd'
import {Card, Col, Row, Steps, Typography} from 'antd'
2024-12-31 13:55:42 +01:00
import type {Connector} from '../../../utils/api/connectors'
2025-01-06 22:58:00 +01:00
import {ConnectorProvider} from '../../../utils/api/connectors'
2025-02-18 17:20:33 +01:00
import React, {useState} from 'react'
import {t} from "ttag"
import {BankOutlined, UserOutlined} from "@ant-design/icons"
2025-02-18 15:41:59 +01:00
import {providersConfig} from "../../../utils/providers"
2024-07-29 19:37:17 +02:00
2025-02-18 17:20:33 +01:00
2024-07-29 19:37:17 +02:00
export function ConnectorForm({form, onCreate}: { form: FormInstance, onCreate: (values: Connector) => void }) {
2025-02-18 17:20:33 +01:00
const [provider, setProvider] = useState<ConnectorProvider>()
const [current, setCurrent] = useState(0)
2025-02-18 21:42:15 +01:00
const ProviderForm = provider !== undefined ? providersConfig[provider].form : undefined
2025-02-18 17:20:33 +01:00
const steps: StepProps[] = [
{
title: t`Registrar`,
icon: <BankOutlined/>,
},
{
title: t`Authentication`,
icon: <UserOutlined/>,
}
]
const next = () => {
setCurrent(current + 1)
}
return (
<>
<Steps current={current} items={steps} onChange={(c: number) => setCurrent(c)}/>
<div style={{padding: 20}}>
{current === 0 && (
<>
<h2>{t`Choose a registrar`}</h2>
<Row gutter={[16, 16]}>
2025-02-18 21:42:15 +01:00
{Object.keys(providersConfig).map((provider: string) => (
2025-02-18 17:20:33 +01:00
<Col key={provider as ConnectorProvider} span={8}>
<Card
hoverable
style={{textAlign: "center"}}
onClick={() => {
setProvider(provider as ConnectorProvider)
next()
}}
>
2025-02-18 18:22:25 +01:00
<div style={{fontSize: "3rem"}}><BankOutlined style={{color: 'lightblue'}}/>
</div>
2025-02-18 17:20:33 +01:00
<h3>{Object.keys(ConnectorProvider).find(p => ConnectorProvider[p as keyof typeof ConnectorProvider] === provider)}</h3>
</Card>
</Col>
))}
</Row>
</>
)}
{current === 1 && ProviderForm && <ProviderForm form={form} onCreate={onCreate}/>}
</div>
2025-02-18 18:22:25 +01:00
<Typography.Text type='secondary'>
{t`This website is neither affiliated with nor sponsored by the registrars mentioned.
The names and logos of these companies are used for informational purposes only and remain registered trademarks of their respective owners.
The use of their services via this website is subject to the terms and conditions set by each registrar and is the sole responsibility of the user.`}
</Typography.Text>
2025-02-18 17:20:33 +01:00
</>
)
2024-12-30 23:50:15 +01:00
}