fix(medusa, admin-ui): Add deleted_at to Return Reason unique constraint (#4834)

* Update return reason create to upsert

* Create strange-wombats-invite.md

* Revert upsert, make value index only apply on non-deleted entities
This commit is contained in:
Rares Stefan
2023-08-29 19:26:58 +02:00
committed by GitHub
parent 046b0dcfa5
commit 470379e631
4 changed files with 42 additions and 19 deletions
@@ -36,27 +36,22 @@ const CreateReturnReasonModal = ({
},
})
const notification = useNotification()
const { mutate, isLoading } = useAdminCreateReturnReason()
const { mutateAsync, isLoading } = useAdminCreateReturnReason()
const onCreate = (data: CreateReturnReasonFormData) => {
mutate(
{
const onCreate = async (data: CreateReturnReasonFormData) => {
try {
await mutateAsync({
...data,
description: data.description || undefined,
},
{
onSuccess: () => {
notification("Success", "Created a new return reason", "success")
},
onError: () => {
notification(
"Error",
"Cant create a Return reason with an existing code",
"error"
)
},
}
)
})
notification("Success", "Created a new return reason", "success")
} catch {
notification(
"Error",
"Cannot create a return reason with an existing value",
"error"
)
}
handleClose()
}