chore: implemented MobX in the onboarding screens (#2617)

* fix: wrap the onboarding route with the UserWrapper

* chore: implement mobx in the onboarding screens
This commit is contained in:
Aaryan Khandelwal 2023-11-02 19:27:25 +05:30 committed by GitHub
parent b0397dfd74
commit a9b72fa1d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 164 additions and 190 deletions

View file

@ -29,7 +29,6 @@ const authService = new AuthService();
export const SignInView = observer(() => {
const { user: userStore } = useMobxStore();
const { fetchCurrentUserSettings } = userStore;
// router
const router = useRouter();
const { next: next_url } = router.query as { next: string };
@ -46,7 +45,7 @@ export const SignInView = observer(() => {
(data?.email_password_login || !(data?.email_password_login || data?.magic_login || data?.google || data?.github));
useEffect(() => {
fetchCurrentUserSettings().then((settings) => {
userStore.fetchCurrentUserSettings().then((settings) => {
setLoading(true);
if (next_url) router.push(next_url);
else
@ -58,12 +57,13 @@ export const SignInView = observer(() => {
}`
);
});
}, [fetchCurrentUserSettings, router, next_url]);
}, [userStore, router, next_url]);
const handleLoginRedirection = () => {
userStore.fetchCurrentUser().then((user) => {
const isOnboard = user.onboarding_step.profile_complete;
if (isOnboard) {
const isOnboarded = user.is_onboarded;
if (isOnboarded) {
userStore
.fetchCurrentUserSettings()
.then((userSettings: IUserSettings) => {