This commit is contained in:
ernstmul committed 2025-03-11 10:52:04 +01:00
1 parent a124dec8d9
commit 4e76c07a5c
1 file changed
+136 -35
+136 -35
View File
@@ -1,4 +1,11 @@
<script lang="ts">
import { Wizard } from '$lib/layout';
import { Icon, Layout, Tag, Typography, Button } from '@appwrite.io/pink-svelte';
import { supportData, isSupportOnline } from './wizard/support/store';
import { onMount } from 'svelte';
import { sdk } from '$lib/stores/sdk';
import { InputSelect, InputText, InputTextarea } from '$lib/elements/forms/index.js';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import {
localeTimezoneName,
@@ -6,16 +13,23 @@
utcWeekDayToLocaleWeekDay,
type WeekDay
} from '$lib/helpers/date';
import { WizardWithSteps } from '$lib/layout';
import type { WizardStepsType } from '$lib/layout/wizardWithSteps.svelte';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { user } from '$lib/stores/user';
import { wizard } from '$lib/stores/wizard';
import { VARS } from '$lib/system';
import { onDestroy } from 'svelte';
import Step1 from './wizard/support/step1.svelte';
import { isSupportOnline, supportData } from './wizard/support/store';
import { IconCheckCircle, IconXCircle } from '@appwrite.io/pink-icons-svelte';
let projectOptions: Array<{ value: string; label: string }>;
onMount(async () => {
const projectList = await sdk.forConsole.projects.list();
projectOptions = projectList.projects.map((project) => ({
value: project.$id,
label: project.name
}));
});
onDestroy(() => {
$supportData = {
@@ -26,14 +40,22 @@
};
});
const stepsComponents: WizardStepsType = new Map();
stepsComponents.set(1, {
label: 'How can we help you?',
component: Step1
});
async function handleSubmit() {
console.log({
email: $user.email,
subject: $supportData.subject,
firstName: $user?.name || 'Unknown',
message: $supportData.message,
tags: ['cloud'],
customFields: [
{ id: '41612', value: $supportData.category },
{ id: '48493', value: $user?.name ?? '' },
{ id: '48492', value: $organization?.$id ?? '' },
{ id: '48491', value: $supportData?.project ?? '' },
{ id: '48490', value: $user?.$id ?? '' }
]
});
return;
const response = await fetch(`${VARS.GROWTH_ENDPOINT}/support`, {
method: 'POST',
headers: {
@@ -96,29 +118,108 @@
$: supportWeekDays = `${utcWeekDayToLocaleWeekDay(workTimings.startDay, workTimings.start)} - ${utcWeekDayToLocaleWeekDay(workTimings.endDay, workTimings.end)}`;
</script>
<WizardWithSteps
title="Contact us"
steps={stepsComponents}
finalAction="Submit"
on:exit={resetData}>
<!--<WizardWithSteps-->
<!-- title="Contact us"-->
<!-- steps={stepsComponents}-->
<!-- finalAction="Submit"-->
<!-- on:exit={resetData}>-->
<!-- <svelte:fragment slot="aside">-->
<!-- <h4 class="body-text-1 u-bold">Contact the Appwrite Team</h4>-->
<!-- <p class="text u-margin-block-start-16">-->
<!-- If you found a bug or have questions, please reach out to the Appwrite team. We try to-->
<!-- respond to all messages within our office hours.-->
<!-- </p>-->
<!-- <p class="text u-margin-block-start-32">-->
<!-- Available: <b>{supportWeekDays}, {supportTimings}</b>-->
<!-- </p>-->
<!-- <div class="u-flex u-gap-4 u-cross-center">-->
<!-- <span>Currently:</span>-->
<!-- {#if isSupportOnline()}-->
<!-- <span class="icon-check-circle u-color-text-success" aria-hidden="true" />-->
<!-- <span class="u-color-text-success text">Online</span>-->
<!-- {:else}-->
<!-- <span class="icon-x-circle" aria-hidden="true" />-->
<!-- <span class="text">Offline</span>-->
<!-- {/if}-->
<!-- </div>-->
<!-- </svelte:fragment>-->
<!--</WizardWithSteps>-->
<Wizard title="Contact us">
<Layout.Stack gap="xl">
<Layout.Stack gap="s">
<Typography.Title>How can we help you?</Typography.Title>
<Typography.Text
>Please describe your request in detail. If applicable, include steps for
reproduction of any in-app issues.</Typography.Text>
</Layout.Stack>
<Layout.Stack gap="s">
<Typography.Text color="--fgcolor-neutral-secondary">Choose a topic</Typography.Text>
<Layout.Stack gap="s" direction="row">
<Tag
on:click={() => {
$supportData.category = 'general';
}}
selected={$supportData.category === 'general'}>general</Tag>
<Tag
on:click={() => {
$supportData.category = 'billing';
}}
selected={$supportData.category === 'billing'}>billing</Tag>
<Tag
on:click={() => {
$supportData.category = 'technical';
}}
selected={$supportData.category === 'technical'}>technical</Tag>
</Layout.Stack>
</Layout.Stack>
<InputSelect
id="project"
label="Choose a project"
options={projectOptions ?? []}
bind:value={$supportData.project}
required={false}
placeholder="Select project" />
<InputText
id="subject"
label="Subject"
bind:value={$supportData.subject}
placeholder="What do you need help with?"
required />
<InputTextarea
id="message"
bind:value={$supportData.message}
placeholder="Type here..."
label="Tell us a bit more" />
<Layout.Stack direction="row" justifyContent="flex-end" gap="s">
<Button.Button on:click={handleSubmit}>Submit</Button.Button>
</Layout.Stack>
</Layout.Stack>
<svelte:fragment slot="aside">
<h4 class="body-text-1 u-bold">Contact the Appwrite Team</h4>
<p class="text u-margin-block-start-16">
If you found a bug or have questions, please reach out to the Appwrite team. We try to
respond to all messages within our office hours.
</p>
<p class="text u-margin-block-start-32">
Available: <b>{supportWeekDays}, {supportTimings}</b>
</p>
<div class="u-flex u-gap-4 u-cross-center">
<span>Currently:</span>
{#if isSupportOnline()}
<span class="icon-check-circle u-color-text-success" aria-hidden="true" />
<span class="u-color-text-success text">Online</span>
{:else}
<span class="icon-x-circle" aria-hidden="true" />
<span class="text">Offline</span>
{/if}
</div>
<Layout.Stack gap="xl">
<Typography.Title size="s">Contact the Appwrite Team</Typography.Title>
<Typography.Text
>If you found a bug or have questions, please reach out to the Appwrite team. We try
to respond to all messages within our office hours.</Typography.Text>
<Layout.Stack direction="row" gap="s">
<Typography.Text>Available:</Typography.Text>
<Typography.Text variant="m-500"
>{supportWeekDays}, {supportTimings}</Typography.Text>
</Layout.Stack>
<Layout.Stack direction="row" gap="s">
<Typography.Text>Currently:</Typography.Text>
{#if isSupportOnline()}
<Layout.Stack direction="row" gap="xxxs" alignItems="center">
<Icon icon={IconCheckCircle} color="--fgcolor-success" />
<Typography.Text color="--fgcolor-success">Online</Typography.Text>
</Layout.Stack>{:else}
<Layout.Stack direction="row" gap="xxxs" alignItems="center">
<Icon icon={IconXCircle} />
<Typography.Text>Offline</Typography.Text>
</Layout.Stack>
{/if}
</Layout.Stack>
</Layout.Stack>
</svelte:fragment>
</WizardWithSteps>
</Wizard>