feat: improved registration signup flow (#1188)

refactored signup flow for entire registration process. Utilized seed data option for optional seeding of Foods, Units, and Labels. Localized registration page.
This commit is contained in:
Hayden
2022-05-06 11:18:06 -08:00
committed by GitHub
parent 6ee9a31c92
commit 7e4da3e5a4
23 changed files with 1056 additions and 316 deletions

View File

@@ -0,0 +1,66 @@
import { reactive } from "@nuxtjs/composition-api";
export enum States {
Initial,
ProvideToken,
ProvideGroupDetails,
ProvideCredentials,
ProvideAccountDetails,
SelectGroupOptions,
Confirmation,
}
export enum RegistrationType {
Unknown,
JoinGroup,
CreateGroup,
InitialGroup,
}
interface Context {
state: States;
type: RegistrationType;
}
interface RegistrationContext {
ctx: Context;
setState(state: States): void;
setType(type: RegistrationType): void;
back(): void;
}
export function useRegistration(): RegistrationContext {
const context = reactive({
state: States.Initial,
type: RegistrationType.Unknown,
history: [
{
state: States.Initial,
},
],
});
function saveHistory() {
context.history.push({
state: context.state,
});
}
const back = () => {
const last = context.history.pop();
if (last) {
context.state = last.state;
}
};
const setState = (state: States) => {
saveHistory();
context.state = state;
};
const setType = (t: RegistrationType) => {
context.type = t;
};
return { ctx: context, setType, setState, back };
}