From 5a2cfefc63bd8b1de4c8a4651c4b7dc4cbda7167 Mon Sep 17 00:00:00 2001 From: ElasticBottle Date: Fri, 6 Dec 2024 02:40:18 +0000 Subject: [PATCH] fix: defaultChainId should be validated in `refine` (#5638) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://linear.app/thirdweb/issue/DASH-546/can-not-update-ecosystem-settings-form-if-default-chain-id-is-not-set --- ## PR-Codex overview This PR focuses on enhancing the `update-partner-modal.client.tsx` and `auth-options-form.client.tsx` components. It modifies the dialog trigger and updates the validation logic for the form, ensuring better handling of the `defaultChainId` field. ### Detailed summary - Updated `` in `update-partner-modal.client.tsx` to use `asChild`. - Modified `defaultChainId` in `auth-options-form.client.tsx` to be optional. - Added a refinement check to validate `defaultChainId` based on `useSmartAccount` in `auth-options-form.client.tsx`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../client/auth-options-form.client.tsx | 20 ++++++++++++++++--- .../client/update-partner-modal.client.tsx | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/auth-options-form.client.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/auth-options-form.client.tsx index 64096581d44..8da099a5a2d 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/auth-options-form.client.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/auth-options-form.client.tsx @@ -86,9 +86,11 @@ export function AuthOptionsForm({ ecosystem }: { ecosystem: Ecosystem }) { .optional(), useSmartAccount: z.boolean(), sponsorGas: z.boolean(), - defaultChainId: z.coerce.number({ - invalid_type_error: "Please enter a valid chain ID", - }), + defaultChainId: z.coerce + .number({ + invalid_type_error: "Please enter a valid chain ID", + }) + .optional(), accountFactoryType: z.enum(["v0.6", "v0.7", "custom"]), customAccountFactoryAddress: z.string().optional(), }) @@ -108,6 +110,18 @@ export function AuthOptionsForm({ ecosystem }: { ecosystem: Ecosystem }) { path: ["customAccountFactoryAddress"], }, ) + .refine( + (data) => { + if (data.useSmartAccount && (data.defaultChainId ?? 0) <= 0) { + return false; + } + return true; + }, + { + message: "Please enter a valid chain ID", + path: ["defaultChainId"], + }, + ) .refine( (data) => { if (data.useCustomAuth && !data.customAuthEndpoint) { diff --git a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/update-partner-modal.client.tsx b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/update-partner-modal.client.tsx index 8728af6e70c..93ebf7e6704 100644 --- a/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/update-partner-modal.client.tsx +++ b/apps/dashboard/src/app/team/[team_slug]/(team)/~/ecosystem/[slug]/(active)/configuration/components/client/update-partner-modal.client.tsx @@ -19,7 +19,7 @@ export function UpdatePartnerModal({ return ( - {children} + {children} Update {partner.name}