|
1 | 1 | <script setup lang="ts"> |
2 | | -import { inject, ref } from 'vue'; |
3 | | -import { useI18n } from 'vue-i18n'; |
4 | | -import { useUserStore } from '@/stores/user-store'; |
5 | | -import { AlertSchemes } from '@/definitions'; |
6 | | -import { callKey } from '@/keys'; |
7 | | -import { BooleanResponse } from '@/models'; |
8 | | -import PrimaryButton from '@/elements/PrimaryButton.vue'; |
9 | | -import AlertBox from '@/elements/AlertBox.vue'; |
10 | | -import TextInput from '@/elements/TextInput.vue'; |
| 2 | +import ExternalRedirect from '@/components/ExternalRedirect.vue'; |
11 | 3 |
|
12 | | -// icons |
13 | | -import { IconSend } from '@tabler/icons-vue'; |
| 4 | +const redirectUrl = import.meta.env?.VITE_SUPPORT_URL; |
14 | 5 |
|
15 | | -// component constants |
16 | | -const user = useUserStore(); |
17 | | -const { t } = useI18n(); |
18 | | -const call = inject(callKey); |
19 | | -
|
20 | | -// form data |
21 | | -const form = ref<HTMLFormElement>(null); |
22 | | -const topic = ref(''); |
23 | | -const details = ref(''); |
24 | | -const sendingState = ref(0); |
25 | | -
|
26 | | -// empty all form inputs |
27 | | -const resetForm = () => { |
28 | | - topic.value = ''; |
29 | | - details.value = ''; |
30 | | -}; |
31 | | -
|
32 | | -// send support request |
33 | | -const send = async () => { |
34 | | - if (!form.value.checkValidity()) { |
35 | | - form.value.reportValidity(); |
36 | | - return; |
37 | | - } |
38 | | - const postObj = { topic: topic.value, details: details.value }; |
39 | | - const { error, data }: BooleanResponse = await call('support').post(postObj).json(); |
40 | | - if (!error.value && data.value) { |
41 | | - sendingState.value = AlertSchemes.Success; |
42 | | - resetForm(); |
43 | | - } else { |
44 | | - sendingState.value = AlertSchemes.Error; |
45 | | - } |
46 | | -}; |
47 | 6 | </script> |
48 | | - |
49 | 7 | <template> |
50 | | - <!-- page title area --> |
51 | | - <div v-if="user.authenticated" class="flex flex-col items-center justify-center gap-4"> |
52 | | - <div class="text-4xl font-light">{{ t('heading.contactRequest') }}</div> |
53 | | - <div class="w-full max-w-lg">{{ t('text.contactRequestForm') }}</div> |
54 | | - <alert-box |
55 | | - v-if="sendingState === AlertSchemes.Success" |
56 | | - :title="t('label.success')" |
57 | | - @close="sendingState = 0" |
58 | | - :scheme="AlertSchemes.Success" |
59 | | - > |
60 | | - {{ t('info.messageWasSent') }} |
61 | | - </alert-box> |
62 | | - <alert-box |
63 | | - v-if="sendingState === AlertSchemes.Error" |
64 | | - :title="t('label.error')" |
65 | | - @close="sendingState = 0" |
66 | | - :scheme="AlertSchemes.Error" |
67 | | - > |
68 | | - {{ t('info.messageWasNotSent') }} |
69 | | - </alert-box> |
70 | | - <form class="flex w-full max-w-lg flex-col gap-2" ref="form"> |
71 | | - <label class="flex flex-col gap-1"> |
72 | | - <div class="font-medium text-gray-500 dark:text-gray-300"> |
73 | | - {{ t("label.topic") }} |
74 | | - </div> |
75 | | - <input type="text" v-model="topic" class="w-full rounded-md" required /> |
76 | | - </label> |
77 | | - <label class="flex flex-col gap-1"> |
78 | | - <div class="font-medium text-gray-500 dark:text-gray-300"> |
79 | | - {{ t("label.message") }} |
80 | | - </div> |
81 | | - <text-input |
82 | | - v-model="details" |
83 | | - :placeholder="t('placeholder.writeHere')" |
84 | | - :maxlength="2500" |
85 | | - /> |
86 | | - </label> |
87 | | - </form> |
88 | | - <primary-button class="btn-send" @click="send" :title="t('label.send')"> |
89 | | - <icon-send /> |
90 | | - {{ t('label.send') }} |
91 | | - </primary-button> |
92 | | - </div> |
| 8 | + <external-redirect :redirect-url="redirectUrl"/> |
93 | 9 | </template> |
0 commit comments