From a63705619ae668869f237a863c6a81ce88ed45e5 Mon Sep 17 00:00:00 2001 From: Sacha Al Himdani Date: Thu, 6 Nov 2025 18:05:21 +0100 Subject: [PATCH] Fix vendors validation Signed-off-by: Sacha Al Himdani --- .../console/src/hooks/forms/useVendorForm.tsx | 44 +++++++++---------- .../vendors/dialogs/CreateVendorDialog.tsx | 24 +++++----- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/console/src/hooks/forms/useVendorForm.tsx b/apps/console/src/hooks/forms/useVendorForm.tsx index c404062e8..e22a3658e 100644 --- a/apps/console/src/hooks/forms/useVendorForm.tsx +++ b/apps/console/src/hooks/forms/useVendorForm.tsx @@ -11,18 +11,18 @@ const schema = z.object({ name: z.string().min(1, "Name is required"), description: z.string().optional().nullable(), category: z.string().nullish(), - statusPageUrl: z.string().optional(), - termsOfServiceUrl: z.string().optional(), - privacyPolicyUrl: z.string().optional(), - serviceLevelAgreementUrl: z.string().optional(), - dataProcessingAgreementUrl: z.string().optional(), - websiteUrl: z.string().optional(), - legalName: z.string().optional(), - headquarterAddress: z.string().optional(), + statusPageUrl: z.string().optional().nullable(), + termsOfServiceUrl: z.string().optional().nullable(), + privacyPolicyUrl: z.string().optional().nullable(), + serviceLevelAgreementUrl: z.string().optional().nullable(), + dataProcessingAgreementUrl: z.string().optional().nullable(), + websiteUrl: z.string().optional().nullable(), + legalName: z.string().optional().nullable(), + headquarterAddress: z.string().optional().nullable(), certifications: z.array(z.string()), countries: z.array(z.string()), - securityPageUrl: z.string().optional(), - trustPageUrl: z.string().optional(), + securityPageUrl: z.string().optional().nullable(), + trustPageUrl: z.string().optional().nullable(), businessOwnerId: z.string().nullish(), securityOwnerId: z.string().nullish(), }); @@ -76,20 +76,20 @@ export function useVendorForm(vendorKey: useVendorFormFragment$key) { const defaultValues = useMemo( () => ({ name: vendor.name, - description: vendor.description ?? "", - category: vendor.category ?? null, - statusPageUrl: vendor.statusPageUrl ?? "", - termsOfServiceUrl: vendor.termsOfServiceUrl ?? "", - privacyPolicyUrl: vendor.privacyPolicyUrl ?? "", - serviceLevelAgreementUrl: vendor.serviceLevelAgreementUrl ?? "", - dataProcessingAgreementUrl: vendor.dataProcessingAgreementUrl ?? "", - websiteUrl: vendor.websiteUrl ?? "", - legalName: vendor.legalName ?? "", - headquarterAddress: vendor.headquarterAddress ?? "", + description: vendor.description || null, + category: vendor.category || null, + statusPageUrl: vendor.statusPageUrl || null, + termsOfServiceUrl: vendor.termsOfServiceUrl || null, + privacyPolicyUrl: vendor.privacyPolicyUrl || null, + serviceLevelAgreementUrl: vendor.serviceLevelAgreementUrl || null, + dataProcessingAgreementUrl: vendor.dataProcessingAgreementUrl || null, + websiteUrl: vendor.websiteUrl || null, + legalName: vendor.legalName || null, + headquarterAddress: vendor.headquarterAddress || null, certifications: [...(vendor.certifications ?? [])], countries: [...(vendor.countries ?? [])], - securityPageUrl: vendor.securityPageUrl ?? "", - trustPageUrl: vendor.trustPageUrl ?? "", + securityPageUrl: vendor.securityPageUrl || null, + trustPageUrl: vendor.trustPageUrl || null, businessOwnerId: vendor.businessOwner?.id, securityOwnerId: vendor.securityOwner?.id, }), diff --git a/apps/console/src/pages/organizations/vendors/dialogs/CreateVendorDialog.tsx b/apps/console/src/pages/organizations/vendors/dialogs/CreateVendorDialog.tsx index 31fb5ba9a..4c75defb7 100644 --- a/apps/console/src/pages/organizations/vendors/dialogs/CreateVendorDialog.tsx +++ b/apps/console/src/pages/organizations/vendors/dialogs/CreateVendorDialog.tsx @@ -41,20 +41,20 @@ export function CreateVendorDialog({ : { organizationId, name: vendor.name, - description: vendor.description, - headquarterAddress: vendor.headquarterAddress, - legalName: vendor.legalName, - websiteUrl: vendor.websiteUrl, - category: vendor.category, - privacyPolicyUrl: vendor.privacyPolicyUrl, - serviceLevelAgreementUrl: vendor.serviceLevelAgreementUrl, - dataProcessingAgreementUrl: vendor.dataProcessingAgreementUrl, + description: vendor.description || null, + headquarterAddress: vendor.headquarterAddress || null, + legalName: vendor.legalName || null, + websiteUrl: vendor.websiteUrl || null, + category: vendor.category || null, + privacyPolicyUrl: vendor.privacyPolicyUrl || null, + serviceLevelAgreementUrl: vendor.serviceLevelAgreementUrl || null, + dataProcessingAgreementUrl: vendor.dataProcessingAgreementUrl || null, certifications: vendor.certifications, countries: vendor.countries, - securityPageUrl: vendor.securityPageUrl, - trustPageUrl: vendor.trustPageUrl, - statusPageUrl: vendor.statusPageUrl, - termsOfServiceUrl: vendor.termsOfServiceUrl, + securityPageUrl: vendor.securityPageUrl || null, + trustPageUrl: vendor.trustPageUrl || null, + statusPageUrl: vendor.statusPageUrl || null, + termsOfServiceUrl: vendor.termsOfServiceUrl || null, }; createVendor({ variables: {