feat: update EPP form

This commit is contained in:
Maël Gangloff
2025-02-25 22:29:22 +01:00
parent 9c56dec069
commit 3657442f67
4 changed files with 94 additions and 31 deletions

View File

@@ -12,7 +12,10 @@ export enum ConnectorProvider {
export interface Connector {
provider: ConnectorProvider
authData: object
authData: Record<string, Record<string, string>>,
objURI?: { key: string, value: string }[],
extURI?: { key: string, value: string }[]
}
interface ConnectorResponse {
@@ -28,6 +31,18 @@ export async function getConnectors(): Promise<ConnectorResponse> {
}
export async function postConnector(connector: Connector) {
for (const key of ['objURI', 'extURI'] as (keyof Connector)[]) {
if (key in connector) {
const obj = connector[key] as { key: string, value: string }[]
connector.authData[key] = obj.reduce((acc: { [key: string]: string }, x) => ({
...acc,
[x.key]: x.value
}), {})
delete connector[key]
}
}
const response = await request<Connector & { id: string }>({
method: 'POST',
url: 'connectors',