-
Notifications
You must be signed in to change notification settings - Fork 237
Expand file tree
/
Copy pathsupport.svelte
More file actions
202 lines (179 loc) · 7.33 KB
/
support.svelte
File metadata and controls
202 lines (179 loc) · 7.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { wizard } from '$lib/stores/wizard';
import SupportWizard from '$routes/(console)/supportWizard.svelte';
import { isSupportOnline, showSupportModal } from '$routes/(console)/wizard/support/store';
import { Click, trackEvent } from '$lib/actions/analytics';
import { localeShortTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date';
import { plansInfo } from '$lib/stores/billing';
import { Card } from '$lib/components/index';
import { app } from '$lib/stores/app';
import { currentPlan, type Organization, organizationList } from '$lib/stores/organization';
import { isCloud } from '$lib/system';
import { Typography } from '@appwrite.io/pink-svelte';
import { base } from '$app/paths';
import { resolvedProfile } from '$lib/profiles/index.svelte';
export let show = false;
export let showHeader = true;
$: hasPremiumSupport = $currentPlan?.premiumSupport ?? allOrgsHavePremiumSupport ?? false;
$: allOrgsHavePremiumSupport = $organizationList.teams.every(
(team) => $plansInfo.get((team as Organization).billingPlan)?.premiumSupport
);
// there can only be one free organization
$: freeOrganization = $organizationList.teams.find(
(team) => !$plansInfo.get((team as Organization).billingPlan)?.premiumSupport
);
$: upgradeURL = `${base}/organization-${freeOrganization?.$id}/change-plan`;
$: supportTimings = `${utcHourToLocaleHour('16:00')} - ${utcHourToLocaleHour('00:00')} ${localeShortTimezoneName()}`;
type SupportOption = {
cta?: string;
icon: string;
label: string;
link?: string;
description: string;
showSupport: boolean;
};
const supportOptions: SupportOption[] = [
{
showSupport: true,
icon: 'support',
label: 'Premium support',
description: `Get priority email support from the ${resolvedProfile.platform} team`
},
{
icon: 'discord',
cta: 'Discord',
showSupport: false,
label: 'Community support',
link: `${resolvedProfile.links.discord}`,
description: 'Get support from our community through Discord'
},
...(!resolvedProfile.showGithubIssueSupport
? []
: [
{
icon: 'github',
cta: 'Open issue',
showSupport: false,
label: 'Open GitHub issue',
link: 'https://github.com/appwrite/appwrite/issues/new/choose',
description: 'Report a bug or pitch a new feature'
}
])
];
const showCloudSupport = (index: number) => {
return (index === 0 && isCloud) || index > 0;
};
</script>
<section class="drop-section support-section">
{#if showHeader}
<Typography.Title size="s">Support</Typography.Title>
{/if}
{#each supportOptions as option, index}
{#if showCloudSupport(index)}
<Card
class="support-option-card "
style="border-radius: var(--border-radius-small, 8px); --gap-xl: 16px">
<div class="u-flex u-flex-vertical u-gap-4">
<Typography.Text variant="m-500">{option.label}</Typography.Text>
<Typography.Text variant="m-400">{option.description}</Typography.Text>
</div>
{#if option.showSupport}
<div class="u-flex u-gap-12 u-cross-center">
{#if !hasPremiumSupport}
<Button
href={upgradeURL}
on:click={() => {
trackEvent(Click.OrganizationClickUpgrade, {
from: 'button',
source: 'support_menu'
});
}}>
<span class="text">Get Premium support</span>
</Button>
{:else}
<Button
secondary
class="secondary-button"
on:click={() => {
show = false;
$showSupportModal = false;
wizard.start(SupportWizard);
}}>
<span class="text">Contact support</span>
</Button>
{/if}
<div class="u-flex u-gap-6 u-cross-center">
<span
aria-hidden="true"
class="{isSupportOnline()
? 'icon-check-circle u-color-text-success'
: 'icon-x-circle'} u-padding-block-end-1"></span>
{supportTimings}
</div>
</div>
{:else}
<Button
href={option.link}
external
secondary
class="secondary-button u-flex u-cross-center u-gap-6"
on:click={() => {
trackEvent(Click.OrganizationClickUpgrade, {
from: 'button',
source: 'support_menu'
});
}}>
<span class={`icon-${option.icon}`}></span>
<span>{option.cta}</span>
</Button>
{/if}
</Card>
{/if}
{/each}
{#if isCloud}
<div class="u-width-full-line">
{#key $app.themeInUse}
<iframe
style="color-scheme: none"
title="{resolvedProfile.platform} Status"
src={`${resolvedProfile.links.status}/badge?theme=${
$app.themeInUse === 'dark' ? 'dark' : 'light'
}`}
width="250"
height="30"
frameborder="0"
scrolling="no">
</iframe>
{/key}
</div>
{/if}
</section>
<style lang="scss">
.support-section {
gap: 1rem;
width: 100%;
padding: 1rem;
display: flex;
flex-direction: column;
@media (max-width: 768px) {
padding: 0;
gap: 1.25rem;
}
}
:global(.u-gap-6) {
gap: 0.375rem;
}
:global(.support-option-card) {
padding: 0.75rem !important;
}
:global(.theme-dark .support-option-card) {
/* override required due to the card's background color */
background: var(--bgcolor-neutral-default, #19191c) !important;
}
:global(.theme-light .support-option-card) {
border: 1px solid var(--border-neutral, #ededf0);
/* override required due to the card's background color */
background: var(--bgcolor-neutral-default, #fafafb) !important;
}
</style>