Skip to content

Commit

Permalink
feat: init register
Browse files Browse the repository at this point in the history
  • Loading branch information
chrispanag committed Oct 28, 2022
1 parent 47f890f commit 8eba850
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/pages/Register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { onMounted, ref } from 'vue';
import CapsuleIcon from '@/components/icons/CapsuleIcon.vue';
import RegisterMethods from '@/components/register/RegisterMethods.vue';
import SignUp from '@/components/register/SignUp.vue';
import useLogin, { Status } from '@/plugins/loginMethods';
import useLogin, { ITorusResponse, Status } from '@/plugins/loginMethods';
import router from '@/router';
import { toastError, toastWarning } from '@/plugins/toast';
import { toastError } from '@/plugins/toast';
const isLoading = ref<boolean>(false);
const step = ref<`registerMethods` | `signUp`>(`registerMethods`);
const userInfo = ref<ITorusResponse | null>(null);
const login = useLogin();
onMounted(async () => {
Expand All @@ -18,24 +18,25 @@ onMounted(async () => {
if (userData) {
const res = await login.verify(userData.privateKey);
switch (res) {
case Status.NO_ACCOUNT:
// If no username is found then register...
toastWarning(`looks like you don't have an account`);
return;
case Status.BLOCKED:
// If account is blocked then send to register page...
// If account is blocked then send to home page...
toastError(`Your account has been deactivated or banned`);
router.push(`/home`);
return;
case Status.SUCCESS:
router.push(`/home`);
location.reload();
return;
case Status.NO_ACCOUNT:
userInfo.value = userData;
}
}
isLoading.value = false;
} catch (err) {
console.log(err);
} catch (err: unknown) {
console.error(err);
if (err instanceof Error) {
toastError(err.message);
}
}
});
</script>
Expand All @@ -58,8 +59,8 @@ onMounted(async () => {
</div>
<div v-show="!isLoading" class="flex w-full h-full flex-col justify-center items-center px-14">
<!-- Step 1: Choose Login / register -->
<RegisterMethods v-if="step === `registerMethods`" />
<SignUp v-else-if="step === `signUp`" />
<RegisterMethods v-if="userInfo === null" />
<SignUp v-else />
</div>
</section>
<p class="text-gray5 dark:text-gray3 px-4 py-5 pl-10 text-sm">
Expand Down

0 comments on commit 8eba850

Please sign in to comment.