feat: submit function

This commit is contained in:
Arman committed 2023-01-10 14:27:00 +01:00
1 parent 1d3907201a
commit ffda6a6bb7
2 files changed
+9 -8

No files matched your search

+7 -6
View File
@@ -10,13 +10,13 @@
import Dark from '$lib/images/support/support-wizard-dark.svg';
import { Pill } from '$lib/elements';
import { Collapsible, CollapsibleItem } from '$lib/components';
import { user } from '$lib/stores/user';
$wizard.media = $app.themeInUse === 'dark' ? Dark : Light;
let files: FileList;
async function beforeSubmit() {
console.log('test');
const response = await fetch('https://growth.appwrite.io/v1/support', {
method: 'POST',
headers: {
@@ -24,12 +24,13 @@
},
body: JSON.stringify({
subject: 'support',
email: $user.email,
firstName: $user?.name ?? '',
message: $supportData.message,
email: 'test@email.com',
tags: $supportData.tags
tags: ['cloud'],
customFields: [{ id: '41612', value: $supportData.category }]
})
});
console.log(response);
trackEvent('submit_support_ticket');
if (response.status !== 200) {
addNotification({
@@ -53,9 +54,9 @@
{#each ['General', 'Billing', 'Technical'] as topic}
<Pill
button
selected={$supportData.tags.includes(topic.toLowerCase())}
selected={$supportData.category === topic.toLowerCase()}
on:click={() => {
$supportData.tags = [topic.toLocaleLowerCase()];
$supportData.category = topic.toLocaleLowerCase();
}}>{topic}</Pill>
{/each}
</div>
+2 -2
View File
@@ -2,12 +2,12 @@ import { writable } from 'svelte/store';
export type SupportData = {
message: string;
tags: string[];
category: string;
file?: File | null;
};
export const supportData = writable<SupportData>({
message: '',
tags: ['general'],
category: 'general',
file: null
});