Add checking for the emptiness of event types
This commit is contained in:
@ -62,6 +62,14 @@ export default function Webhooks(): JSX.Element {
|
||||
|
||||
applyStoredTheme(false)
|
||||
|
||||
function validateEventTypes(eventTypes: WebhookEvent[]): boolean {
|
||||
if (eventTypes.length > 0) return true
|
||||
showErrorToast('Please select at least one event type', {
|
||||
position: 'bottom-right',
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
async function onDelete(id: string): Promise<void> {
|
||||
const result = await deleteWebhookMutation(id)
|
||||
if (result) {
|
||||
@ -73,6 +81,7 @@ export default function Webhooks(): JSX.Element {
|
||||
}
|
||||
|
||||
async function onCreate(): Promise<void> {
|
||||
if (!validateEventTypes(eventTypes)) return
|
||||
const result = await setWebhookMutation({ url, eventTypes })
|
||||
if (result) {
|
||||
showSuccessToast('Webhook created', { position: 'bottom-right' })
|
||||
@ -83,6 +92,7 @@ export default function Webhooks(): JSX.Element {
|
||||
}
|
||||
|
||||
async function onUpdate(): Promise<void> {
|
||||
if (!validateEventTypes(eventTypes)) return
|
||||
const result = await setWebhookMutation({
|
||||
id: onEditWebhook?.id,
|
||||
url,
|
||||
|
||||
Reference in New Issue
Block a user