Skip to content

Commit

Permalink
fix: types for destination CRUD functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink committed Feb 10, 2025
1 parent f0ed757 commit 156a03c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/containers/destination-drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>
deleteDestination: (id: string) => Promise<void>
testConnection: DestinationFormProps['testConnection']
testLoading: DestinationFormProps['testLoading']
testResult: DestinationFormProps['testResult']
Expand Down Expand Up @@ -124,20 +124,20 @@ const DestinationDrawer: FC<DestinationDrawerProps> = ({
loadFormWithDrawerItem(thisItem)
}

const handleDelete = () => {
deleteDestination(drawerEntityId as string)
const handleDelete = async () => {
await deleteDestination(drawerEntityId as string)
setIsEditing(false)
setIsFormDirty(false)
resetFormData()
// close drawer, all other cases are handled in OverviewDrawer
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)
}
Expand Down
6 changes: 3 additions & 3 deletions src/containers/destination-modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface DestinationModalProps {
isOnboarding?: boolean
categories: DestinationCategories
potentialDestinations: DestinationOption[]
createDestination: (destination: DestinationFormData) => void
createDestination: (destination: DestinationFormData) => Promise<void>
testConnection: DestinationFormProps['testConnection']
testLoading: DestinationFormProps['testLoading']
testResult: DestinationFormProps['testResult']
Expand Down Expand Up @@ -70,7 +70,7 @@ const DestinationModal: FC<DestinationModalProps> = ({
setSelectedItem(item)
}

const handleSubmit = () => {
const handleSubmit = async () => {
const isFormOk = validateForm({ withAlert: !isOnboarding, alertTitle: CRUD.CREATE })
if (!isFormOk) return null

Expand Down Expand Up @@ -98,7 +98,7 @@ const DestinationModal: FC<DestinationModalProps> = ({

addConfiguredDestination({ stored: storedDestination, form: formData })
} else {
createDestination(formData)
await createDestination(formData)
}

handleClose()
Expand Down

0 comments on commit 156a03c

Please sign in to comment.