added new formcard

This commit is contained in:
2023-04-18 15:24:41 +10:00
parent 24caa9a4f4
commit 00a752173d
3 changed files with 33 additions and 25 deletions

View File

@@ -10,6 +10,11 @@
<div v-if="slots.footer" class="footer"> <div v-if="slots.footer" class="footer">
<slot name="footer"></slot> <slot name="footer"></slot>
</div> </div>
<div
v-if="slots['footer-space-between']"
class="footer justify-content-space-between">
<slot name="footer-space-between"></slot>
</div>
</div> </div>
</template> </template>
@@ -44,9 +49,10 @@ const slots = useSlots();
} }
.footer { .footer {
margin-top: 32px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: center;
} }
h1, h1,

View File

@@ -20,7 +20,7 @@
> >
</SMInput> </SMInput>
</template> </template>
<template #footer> <template #footer-space-between>
<small> <small>
<span class="pr-1">Need an account?</span <span class="pr-1">Need an account?</span
><router-link to="/register">Register</router-link> ><router-link to="/register">Register</router-link>

View File

@@ -1,9 +1,13 @@
<template> <template>
<SMContainer> <SMContainer :center="true">
<SMForm v-model="form" @submit="handleSubmit"> <SMForm v-if="!userRegistered" v-model="form" @submit="handleSubmit">
<SMCard class="form-wide"> <SMFormCard full>
<template #header> <template #header>
<h2>Register</h2> <h2>Register</h2>
<p>
Create an account to access STEMMechanics courses and
features.
</p>
</template> </template>
<template #body> <template #body>
<SMRow> <SMRow>
@@ -35,40 +39,38 @@
</SMColumn> </SMColumn>
</SMRow> </SMRow>
</template> </template>
<template #footer> <template #footer-space-between>
<div class="small"> <div class="small">
<span class="pr-1">Already have an account?</span <span class="pr-1">Already have an account?</span
><router-link to="/login">Log in</router-link> ><router-link to="/login">Log in</router-link>
</div> </div>
<SMButton type="submit" label="Register" /> <SMButton type="submit" label="Register" />
</template> </template>
</SMCard> </SMFormCard>
</SMForm> </SMForm>
<!-- </template> <SMFormCard v-else>
<template v-else> <template #header>
<h1>Email Sent!</h1> <h2>Email Sent!</h2>
<p class="text-center"> </template>
An email has been sent to you to confirm your details and to <template #body>
finish registering your account. <p>
</p> An email has been sent to you to confirm your details and to
<SMFormFooter> finish registering your account.
<template #right> </p>
<SMButton :to="{ name: 'home' }" label="Home" /> </template>
</template> <template #footer>
</SMFormFooter> <SMButton type="primary" :to="{ name: 'home' }" label="Home" />
</template> </template>
</SMCard> --> </SMFormCard>
</SMContainer> </SMContainer>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, ref } from "vue"; import { reactive, ref } from "vue";
import { useReCaptcha } from "vue-recaptcha-v3"; import { useReCaptcha } from "vue-recaptcha-v3";
import SMCard from "../components/SMCard.vue";
import SMButton from "../components/SMButton.vue"; import SMButton from "../components/SMButton.vue";
import SMFormCard from "../components/SMFormCard.vue"; import SMFormCard from "../components/SMFormCard.vue";
import SMForm from "../components/SMForm.vue"; import SMForm from "../components/SMForm.vue";
import SMFormFooter from "../components/SMFormFooter.vue";
import SMInput from "../depreciated/SMInput-old.vue"; import SMInput from "../depreciated/SMInput-old.vue";
import { api } from "../helpers/api"; import { api } from "../helpers/api";
import { Form, FormControl } from "../helpers/form"; import { Form, FormControl } from "../helpers/form";
@@ -114,7 +116,7 @@ const checkUsername = async (value: string): Promise<boolean | string> => {
} }
}; };
const formDone = ref(false); const userRegistered = ref(false);
const lastUsernameCheck = ref(""); const lastUsernameCheck = ref("");
let form = reactive( let form = reactive(
Form({ Form({
@@ -147,7 +149,7 @@ const handleSubmit = async () => {
}, },
}); });
formDone.value = true; userRegistered.value = true;
} catch (error) { } catch (error) {
form.apiErrors(error); form.apiErrors(error);
} finally { } finally {