feat: delte webhook

This commit is contained in:
Arman committed 2022-10-06 12:39:29 +02:00
1 parent eb57cd0588
commit 3ccce7293a
2 files changed
+42 -1

No files matched your search

@@ -15,7 +15,7 @@
import { webhook } from './store';
import { page } from '$app/stores';
import { toLocaleDateTime } from '$lib/helpers/date';
// import Delete from './delete.svelte';
import Delete from './delete.svelte';
import Regenerate from './regenerate.svelte';
import { difference } from '$lib/helpers/array';
@@ -319,6 +319,7 @@
</CardGrid>
</Container>
<Delete bind:showDelete />
<Regenerate bind:show={showRegenerate} />
<EventModal
bind:showCreate={showCreateEvent}
@@ -0,0 +1,40 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { Modal } from '$lib/components';
import { Button, Form } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../../../../store';
import { webhook } from './store';
export let showDelete = false;
async function handleDelete() {
try {
await sdkForConsole.projects.deleteWebhook($project.$id, $webhook.$id);
showDelete = false;
addNotification({
type: 'success',
message: `${$webhook.name} has been deleted`
});
await goto(`${base}/console/project-${$project.$id}/settings/webhooks`);
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
}
</script>
<Form on:submit={handleDelete}>
<Modal bind:show={showDelete} warning>
<svelte:fragment slot="header">Delete Webhook</svelte:fragment>
<p>Are you sure you want to delete <b>{$webhook.name}</b> from '{$project.name}'?</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
<Button secondary submit>Delete</Button>
</svelte:fragment>
</Modal>
</Form>