From 79f8452ab54c50938c1fe31dfec70cc79cfdf050 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Fri, 29 Oct 2021 20:28:58 +0200 Subject: [PATCH] Normalize client attributes before saving (#1442) --- src/clients/add/NewClientForm.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clients/add/NewClientForm.tsx b/src/clients/add/NewClientForm.tsx index b27b2ce960..51441a1fe1 100644 --- a/src/clients/add/NewClientForm.tsx +++ b/src/clients/add/NewClientForm.tsx @@ -15,6 +15,7 @@ import { useAlerts } from "../../components/alert/Alerts"; import { ViewHeader } from "../../components/view-header/ViewHeader"; import { useAdminClient } from "../../context/auth/AdminClient"; import { useRealm } from "../../context/realm-context/RealmContext"; +import { convertFormValuesToObject } from "../../util"; import { toClient } from "../routes/Client"; import { toClients } from "../routes/Clients"; import { CapabilityConfig } from "./CapabilityConfig"; @@ -43,8 +44,15 @@ export default function NewClientForm() { const methods = useForm({ defaultValues: client }); const save = async () => { + const attributes = client.attributes + ? convertFormValuesToObject(client.attributes) + : undefined; + try { - const newClient = await adminClient.clients.create({ ...client }); + const newClient = await adminClient.clients.create({ + ...client, + attributes, + }); addAlert(t("createSuccess"), AlertVariant.success); history.push( toClient({ realm, clientId: newClient.id, tab: "settings" })