2024-08-12 07:55:15 +00:00
|
|
|
<template>
|
|
|
|
<v-container class="h-[calc(100vh-80px)] flex flex-col gap-3 items-center justify-center">
|
|
|
|
<auth-callback-hint />
|
|
|
|
|
|
|
|
<v-card class="w-full max-w-[720px] overflow-auto" :loading="loading">
|
|
|
|
<v-card-text class="card-grid pa-9">
|
|
|
|
<div>
|
|
|
|
<v-avatar color="accent" icon="mdi-login-variant" size="large" class="card-rounded mb-2" />
|
2024-08-13 09:43:44 +00:00
|
|
|
<h1 class="text-2xl">{{ t("signUpTitle") }}</h1>
|
|
|
|
<p class="max-w-5/6">{{ t("signUpCaption") }}</p>
|
2024-08-12 07:55:15 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="flex items-center">
|
|
|
|
<v-form class="flex-grow-1" @submit.prevent="submit">
|
|
|
|
<v-row dense class="mb-3">
|
|
|
|
<v-col :cols="6">
|
|
|
|
<v-text-field
|
|
|
|
hide-details
|
2024-08-13 09:43:44 +00:00
|
|
|
:label="t('username')"
|
2024-08-12 07:55:15 +00:00
|
|
|
autocomplete="username"
|
|
|
|
variant="solo"
|
|
|
|
density="comfortable"
|
|
|
|
v-model="data.name"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col :cols="6">
|
|
|
|
<v-text-field
|
|
|
|
hide-details
|
2024-08-13 09:43:44 +00:00
|
|
|
:label="t('nickname')"
|
2024-08-12 07:55:15 +00:00
|
|
|
autocomplete="nickname"
|
|
|
|
variant="solo"
|
|
|
|
density="comfortable"
|
|
|
|
v-model="data.nick"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col :cols="12">
|
|
|
|
<v-text-field
|
|
|
|
hide-details
|
2024-08-13 09:43:44 +00:00
|
|
|
:label="t('email')"
|
2024-08-12 07:55:15 +00:00
|
|
|
type="email"
|
|
|
|
variant="solo"
|
|
|
|
density="comfortable"
|
|
|
|
v-model="data.email"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
<v-col :cols="12">
|
|
|
|
<v-text-field
|
|
|
|
hide-details
|
2024-08-13 09:43:44 +00:00
|
|
|
:label="t('password')"
|
2024-08-12 07:55:15 +00:00
|
|
|
type="password"
|
|
|
|
autocomplete="new-password"
|
|
|
|
variant="solo"
|
|
|
|
density="comfortable"
|
|
|
|
v-model="data.password"
|
|
|
|
/>
|
|
|
|
</v-col>
|
|
|
|
</v-row>
|
|
|
|
|
|
|
|
<v-expand-transition>
|
|
|
|
<v-alert v-show="error" variant="tonal" type="error" class="text-xs mb-3">
|
2024-08-13 09:43:44 +00:00
|
|
|
{{ t("errorOccurred", [error]) }}
|
2024-08-12 07:55:15 +00:00
|
|
|
</v-alert>
|
|
|
|
</v-expand-transition>
|
|
|
|
|
|
|
|
<div class="flex justify-between">
|
|
|
|
<v-btn type="button" variant="plain" color="grey-darken-3" to="/auth/sign-in">
|
2024-08-13 09:43:44 +00:00
|
|
|
{{ t("userMenuSignIn") }}
|
2024-08-12 07:55:15 +00:00
|
|
|
</v-btn>
|
|
|
|
|
|
|
|
<v-btn type="submit" variant="text" color="primary" append-icon="mdi-arrow-right" :disabled="loading">
|
2024-08-13 09:43:44 +00:00
|
|
|
{{ t("next") }}
|
2024-08-12 07:55:15 +00:00
|
|
|
</v-btn>
|
|
|
|
</div>
|
|
|
|
</v-form>
|
|
|
|
</div>
|
|
|
|
</v-card-text>
|
|
|
|
</v-card>
|
|
|
|
|
|
|
|
<v-dialog v-model="done" class="max-w-[560px]">
|
|
|
|
<v-card title="Congratulations">
|
|
|
|
<template #text>
|
2024-08-13 09:43:44 +00:00
|
|
|
{{ t("signUpCompleted") }}
|
2024-08-12 07:55:15 +00:00
|
|
|
</template>
|
|
|
|
<template #actions>
|
|
|
|
<div class="flex flex-grow-1 justify-end">
|
2024-08-13 09:43:44 +00:00
|
|
|
<v-btn @click="callback">{{ t("signUpCompletedAction") }}</v-btn>
|
2024-08-12 07:55:15 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</v-card>
|
|
|
|
</v-dialog>
|
|
|
|
|
|
|
|
<copyright service="passport" />
|
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref } from "vue"
|
|
|
|
import { useRoute, useRouter } from "vue-router"
|
|
|
|
|
|
|
|
const error = ref<string | null>(null)
|
|
|
|
|
2024-08-13 09:43:44 +00:00
|
|
|
const { t } = useI18n()
|
2024-08-12 07:55:15 +00:00
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
|
|
|
const route = useRoute()
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
const done = ref(false)
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
const data = ref({
|
|
|
|
name: "",
|
|
|
|
nick: "",
|
|
|
|
email: "",
|
|
|
|
password: "",
|
|
|
|
})
|
|
|
|
|
|
|
|
async function submit() {
|
|
|
|
const payload = data.value
|
|
|
|
if (!payload.name || !payload.nick || !payload.email || !payload.password) return
|
|
|
|
|
|
|
|
loading.value = true
|
2024-08-17 15:56:03 +00:00
|
|
|
const res = await fetch(`${config.public.solarNetworkApi}/cgi/id/users`, {
|
2024-08-12 07:55:15 +00:00
|
|
|
method: "POST",
|
|
|
|
headers: { "Content-Type": "application/json" },
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
})
|
|
|
|
if (res.status !== 200) {
|
|
|
|
error.value = await res.text()
|
|
|
|
} else {
|
|
|
|
done.value = true
|
|
|
|
error.value = null
|
|
|
|
}
|
|
|
|
loading.value = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function callback() {
|
|
|
|
if (route.params["closable"]) {
|
|
|
|
window.close()
|
|
|
|
} else {
|
2024-08-13 09:43:44 +00:00
|
|
|
router.push("/auth/sign-in")
|
2024-08-12 07:55:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.card-grid {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: 1fr 1fr;
|
|
|
|
gap: 1rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 768px) {
|
|
|
|
.card-grid {
|
|
|
|
grid-template-columns: 1fr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.card-rounded {
|
|
|
|
border-radius: 8px;
|
|
|
|
}
|
|
|
|
</style>
|