1
1
<template >
2
2
<div class =" flex flex-col items-center gap-4" >
3
+ <ButtonColored
4
+ :is-primary =" false"
5
+ :aria-label =" t('register')"
6
+ :to =" localePath('session-create')"
7
+ >
8
+ {{ t('signIn') }}
9
+ <template #prefix >
10
+ <IHeroiconsArrowLeft />
11
+ </template >
12
+ </ButtonColored >
3
13
<Form
4
14
:errors =" api.errors"
5
15
:errors-pg-ids =" {
10
20
form-class =" w-full"
11
21
:is-form-sent =" isFormSent"
12
22
:submit-name =" t('register')"
13
- @submit.prevent =" handleSubmit "
23
+ @submit.prevent =" submit "
14
24
>
15
25
<FormInputUsername
16
26
:form-input =" v$.username"
37
47
</FormInputStateInfo >
38
48
</template >
39
49
</Form >
40
-
41
- <AppLink
42
- :to =" localePath('session-create')"
43
- :is-underlined =" true"
44
- :is-colored =" true"
45
- >
46
- {{ t('alreadyHaveAnAccount') }}
47
- </AppLink >
48
-
49
- <!-- Modals -->
50
- <ModalPrivacyPolicy
51
- v-model =" privacyModalOpen"
52
- @open-general-terms =" openGeneralTerms"
53
- />
54
-
55
- <ModalGeneralTerms v-model =" generalTermsModalOpen" @accepted =" submit" />
56
50
</div >
57
51
</template >
58
52
59
53
<script setup lang="ts">
60
54
import { useVuelidate } from ' @vuelidate/core'
61
- import { useCreateLegalTermAcceptanceMutation } from ' ~~/gql/documents/mutations/account/accountLegalTermAcceptance'
62
55
import { useAccountRegistrationMutation } from ' ~~/gql/documents/mutations/account/accountRegistration'
63
56
64
57
const { locale, t } = useI18n ()
65
58
const localePath = useLocalePath ()
66
59
const fireAlert = useFireAlert ()
67
60
const store = useMaevsiStore ()
68
61
69
- const privacyModalOpen = ref (false )
70
- const generalTermsModalOpen = ref (false )
71
-
62
+ // api data
72
63
const accountRegistrationMutation = useAccountRegistrationMutation ()
73
64
const api = getApiData ([accountRegistrationMutation ])
74
65
66
+ // data
75
67
const form = reactive ({
76
68
captcha: ref <string >(),
77
69
emailAddress: ref <string >(),
78
70
password: ref <string >(),
79
71
username: ref <string >(),
80
72
})
81
-
82
73
const isFormSent = ref (false )
83
74
84
- // Methods
85
- const submit = async (termId : string ) => {
75
+ // methods
76
+ const submit = async () => {
77
+ if (! (await isFormValid ({ v$ , isFormSent }))) return
78
+
86
79
store .turnstileToken = form .captcha
87
80
88
- const accountResult = await accountRegistrationMutation .executeMutation ({
81
+ const result = await accountRegistrationMutation .executeMutation ({
89
82
emailAddress: form .emailAddress || ' ' ,
90
83
language: locale .value ,
91
84
password: form .password || ' ' ,
92
85
username: form .username || ' ' ,
93
86
})
94
87
95
- if (accountResult .error ) {
96
- return
97
- }
98
-
99
- const accountUuid = accountResult .data ?.accountRegistration ?.uuid
100
- if (! accountUuid ) {
101
- console .error (' No account UUID received' )
102
- return
103
- }
104
-
105
- const legalTermAcceptanceMutation = useCreateLegalTermAcceptanceMutation ()
106
-
107
- const acceptanceResult = await legalTermAcceptanceMutation .executeMutation ({
108
- input: {
109
- legalTermAcceptance: {
110
- accountId: accountUuid ,
111
- legalTermId: termId ,
112
- },
113
- },
114
- })
115
-
116
- if (acceptanceResult .error ) {
117
- console .error (' Legal term acceptance error:' , acceptanceResult .error )
118
- return
119
- }
88
+ if (result .error || ! result .data ) return
120
89
121
90
await fireAlert ({
122
91
level: ' success' ,
@@ -125,16 +94,6 @@ const submit = async (termId: string) => {
125
94
})
126
95
}
127
96
128
- const handleSubmit = async () => {
129
- if (! (await isFormValid ({ v$ , isFormSent }))) return
130
-
131
- privacyModalOpen .value = true
132
- }
133
-
134
- const openGeneralTerms = () => {
135
- generalTermsModalOpen .value = true
136
- }
137
-
138
97
// vuelidate
139
98
const rules = {
140
99
captcha: VALIDATION_CAPTCHA (),
@@ -145,7 +104,6 @@ const rules = {
145
104
password: VALIDATION_PASSWORD (),
146
105
emailAddress: VALIDATION_EMAIL_ADDRESS ({ isRequired: true }),
147
106
}
148
-
149
107
const v$ = useVuelidate (rules , form )
150
108
</script >
151
109
@@ -157,13 +115,13 @@ de:
157
115
register : Registrieren
158
116
registrationSuccessBody : Verifiziere deinen Account über den Link in der E-Mail, die du in Kürze erhalten wirst.
159
117
registrationSuccessTitle : Verifizierungs-E-Mail gesendet.
160
- alreadyHaveAnAccount : ' Du hast bereits ein Konto? Anmelden '
118
+ signIn : Stattdessen anmelden
161
119
en :
162
120
accountDeletionNotice : " You'll be able to delete your account at any time."
163
121
postgres22023 : Your password is too short! Think of a longer one.
164
122
postgres23505 : This username or email address is already in use! Think of a new name or try signing in instead.
165
- register : Sign Up
123
+ register : Register
166
124
registrationSuccessBody : Verify your account using the verification link sent to you by email.
167
125
registrationSuccessTitle : Verification email sent.
168
- alreadyHaveAnAccount : Already have an account? Log in
126
+ signIn : Sign in instead
169
127
</i18n >
0 commit comments