Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 reset stored user info upon successful sign-up (#251) #254

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import PrimaryButton from '$components/buttons/PrimaryButton.svelte';
import PasswordField from '$components/input/PasswordField.svelte';
import { createUserFormSchema, fullCreateUserFormSchema } from '$lib/schemas/zodSchema';
import { resetUserInfo } from '$store';
import { t } from 'svelte-i18n';

let sendPasswordForm: HTMLFormElement;
Expand All @@ -11,10 +12,11 @@
let confirmPassword = '';
let loading = false;

$: disabled = !fullCreateUserFormSchema.safeParse({
password,
confirmPassword
}).success || loading;
$: disabled =
!fullCreateUserFormSchema.safeParse({
password,
confirmPassword
}).success || loading;

const handler = () => {
if (disabled) return;
Expand All @@ -35,6 +37,7 @@
loading = false;

update();
resetUserInfo();
};
}}
>
Expand Down
19 changes: 14 additions & 5 deletions registration/src/store/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import type { UserInfo, RegistrationStepType } from '$types';
import { writable, get } from 'svelte/store';
import type { ActionData } from '../routes/$types';

const defaultUserInfo = {
firstName: '',
lastName: '',
nickName: ''
};

export const form = writable<ActionData>();
export const registrationStep = writable<RegistrationStepType>('home');

Expand Down Expand Up @@ -35,8 +41,11 @@ export const nextRegistrationStep = () => {
if (currentStep === 'password') return registrationStep.set('success');
};

export const nickNameStepInfo = writable<UserInfo>({
firstName: '',
lastName: '',
nickName: ''
});
export const nickNameStepInfo = writable<UserInfo>(defaultUserInfo);

/**
* Resets the default user info Store
*/
export const resetUserInfo = (): void => {
nickNameStepInfo.set(defaultUserInfo);
};
Loading