|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import { onMounted } from '@vue/runtime-core' |
|
|
|
|
import { useToast } from 'vue-toastification' |
|
|
|
|
import { MetaInj } from '~/context' |
|
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' |
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
|
hook: Record<string, any> |
|
|
|
@ -9,8 +11,11 @@ interface Props {
|
|
|
|
|
const { hook } = defineProps<Props>() |
|
|
|
|
|
|
|
|
|
const { $state, $api, $e } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
const toast = useToast() |
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj) |
|
|
|
|
const isVisible = ref(false) |
|
|
|
|
|
|
|
|
|
const sampleData = ref({ |
|
|
|
|
data: {}, |
|
|
|
|
user: {}, |
|
|
|
@ -31,6 +36,23 @@ async function loadSampleData() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function testWebhook() { |
|
|
|
|
try { |
|
|
|
|
await $api.dbTableWebhook.test(meta?.value.id as string, { |
|
|
|
|
hook, |
|
|
|
|
payload: sampleData.value, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
toast.success('Webhook tested successfully') |
|
|
|
|
} catch (e: any) { |
|
|
|
|
toast.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
|
testWebhook, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
|
await loadSampleData() |
|
|
|
|
}) |
|
|
|
@ -39,7 +61,7 @@ onMounted(async () => {
|
|
|
|
|
<template> |
|
|
|
|
<a-collapse v-model:activeKey="activeKey" ghost> |
|
|
|
|
<a-collapse-panel key="1" header="Sample Payload"> |
|
|
|
|
<!-- TODO: need changes from Quick Import PR --> |
|
|
|
|
<!-- TODO: set lang --> |
|
|
|
|
<MonacoEditor v-model="sampleData" class="min-h-60 max-h-80" /> |
|
|
|
|
</a-collapse-panel> |
|
|
|
|
</a-collapse> |
|
|
|
|