From 156a03c47a1e7a0af916e61968a1ec781eb8c798 Mon Sep 17 00:00:00 2001 From: Ben Elferink Date: Mon, 10 Feb 2025 13:29:47 +0200 Subject: [PATCH] fix: types for destination CRUD functions --- src/containers/destination-drawer/index.tsx | 12 ++++++------ src/containers/destination-modal/index.tsx | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/containers/destination-drawer/index.tsx b/src/containers/destination-drawer/index.tsx index 3ffce7d..e318f1b 100644 --- a/src/containers/destination-drawer/index.tsx +++ b/src/containers/destination-drawer/index.tsx @@ -19,8 +19,8 @@ import { interface DestinationDrawerProps { categories: DestinationCategories destinations: Destination[] - updateDestination: (id: string, destination: DestinationFormData) => void - deleteDestination: (id: string) => void + updateDestination: (id: string, destination: DestinationFormData) => Promise + deleteDestination: (id: string) => Promise testConnection: DestinationFormProps['testConnection'] testLoading: DestinationFormProps['testLoading'] testResult: DestinationFormProps['testResult'] @@ -124,8 +124,8 @@ const DestinationDrawer: FC = ({ loadFormWithDrawerItem(thisItem) } - const handleDelete = () => { - deleteDestination(drawerEntityId as string) + const handleDelete = async () => { + await deleteDestination(drawerEntityId as string) setIsEditing(false) setIsFormDirty(false) resetFormData() @@ -133,11 +133,11 @@ const DestinationDrawer: FC = ({ onClose() } - const handleSave = (newTitle: string) => { + const handleSave = async (newTitle: string) => { if (validateForm({ withAlert: true, alertTitle: CRUD.UPDATE })) { const title = newTitle !== thisItem.destinationType.displayName ? newTitle : '' handleFormChange('name', title) - updateDestination(drawerEntityId as string, { ...formData, name: title }) + await updateDestination(drawerEntityId as string, { ...formData, name: title }) setIsEditing(false) setIsFormDirty(false) } diff --git a/src/containers/destination-modal/index.tsx b/src/containers/destination-modal/index.tsx index 593209a..1838520 100644 --- a/src/containers/destination-modal/index.tsx +++ b/src/containers/destination-modal/index.tsx @@ -13,7 +13,7 @@ interface DestinationModalProps { isOnboarding?: boolean categories: DestinationCategories potentialDestinations: DestinationOption[] - createDestination: (destination: DestinationFormData) => void + createDestination: (destination: DestinationFormData) => Promise testConnection: DestinationFormProps['testConnection'] testLoading: DestinationFormProps['testLoading'] testResult: DestinationFormProps['testResult'] @@ -70,7 +70,7 @@ const DestinationModal: FC = ({ setSelectedItem(item) } - const handleSubmit = () => { + const handleSubmit = async () => { const isFormOk = validateForm({ withAlert: !isOnboarding, alertTitle: CRUD.CREATE }) if (!isFormOk) return null @@ -98,7 +98,7 @@ const DestinationModal: FC = ({ addConfiguredDestination({ stored: storedDestination, form: formData }) } else { - createDestination(formData) + await createDestination(formData) } handleClose()