From 622ace2094b93acdec2f2c98f7692f4dd7f85f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Silva?= Date: Thu, 27 Jun 2024 14:41:50 +0100 Subject: [PATCH] fix: send schedules undefined when none present (#459) --- .../api/db-cluster/useCreateDbCluster.ts | 21 ++++++++++--------- .../api/db-cluster/useUpdateDbCluster.ts | 21 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/ui/apps/everest/src/hooks/api/db-cluster/useCreateDbCluster.ts b/ui/apps/everest/src/hooks/api/db-cluster/useCreateDbCluster.ts index d30292650..26627a8f2 100644 --- a/ui/apps/everest/src/hooks/api/db-cluster/useCreateDbCluster.ts +++ b/ui/apps/everest/src/hooks/api/db-cluster/useCreateDbCluster.ts @@ -59,16 +59,17 @@ const formValuesToPayloadMapping = ( : dbPayload.pitrStorageLocation!.name, }, }), - ...(dbPayload.schedules?.length > 0 && { - schedules: dbPayload.schedules.map((schedule) => ({ - ...schedule, - schedule: cronConverter( - schedule.schedule, - Intl.DateTimeFormat().resolvedOptions().timeZone, - 'UTC' - ), - })), - }), + schedules: + dbPayload.schedules?.length > 0 + ? dbPayload.schedules.map((schedule) => ({ + ...schedule, + schedule: cronConverter( + schedule.schedule, + Intl.DateTimeFormat().resolvedOptions().timeZone, + 'UTC' + ), + })) + : undefined, }, engine: { type: dbTypeToDbEngine(dbPayload.dbType), diff --git a/ui/apps/everest/src/hooks/api/db-cluster/useUpdateDbCluster.ts b/ui/apps/everest/src/hooks/api/db-cluster/useUpdateDbCluster.ts index 3cecc9617..89ca2fcdf 100644 --- a/ui/apps/everest/src/hooks/api/db-cluster/useUpdateDbCluster.ts +++ b/ui/apps/everest/src/hooks/api/db-cluster/useUpdateDbCluster.ts @@ -51,16 +51,17 @@ const formValuesToPayloadOverrides = ( enabled: dbPayload.pitrEnabled, backupStorageName: pitrBackupStorageName, }, - ...(dbPayload.schedules?.length > 0 && { - schedules: dbPayload.schedules.map((schedule) => ({ - ...schedule, - schedule: cronConverter( - schedule.schedule, - Intl.DateTimeFormat().resolvedOptions().timeZone, - 'UTC' - ), - })), - }), + schedules: + dbPayload.schedules.length > 0 + ? dbPayload.schedules.map((schedule) => ({ + ...schedule, + schedule: cronConverter( + schedule.schedule, + Intl.DateTimeFormat().resolvedOptions().timeZone, + 'UTC' + ), + })) + : undefined, }, engine: { ...dbCluster.spec.engine,