mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-30 01:32:52 +03:00
fix(frontend): cleaner fix for onboarding (#2415)
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
6c600bc680
commit
a479065922
@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useLayoutEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
import { QuivrLogo } from "@/lib/assets/QuivrLogo";
|
||||||
import { AddBrainModal } from "@/lib/components/AddBrainModal";
|
import { AddBrainModal } from "@/lib/components/AddBrainModal";
|
||||||
@ -20,7 +20,7 @@ import { ButtonType } from "@/lib/types/QuivrButton";
|
|||||||
import styles from "./page.module.scss";
|
import styles from "./page.module.scss";
|
||||||
|
|
||||||
const Search = (): JSX.Element => {
|
const Search = (): JSX.Element => {
|
||||||
const [isPageLoaded, setIsPageLoaded] = useState<boolean>(false);
|
const [isUserDataFetched, setIsUserDataFetched] = useState(false);
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const { session } = useSupabase();
|
const { session } = useSupabase();
|
||||||
const { isBrainCreationModalOpened, setIsBrainCreationModalOpened } =
|
const { isBrainCreationModalOpened, setIsBrainCreationModalOpened } =
|
||||||
@ -28,11 +28,15 @@ const Search = (): JSX.Element => {
|
|||||||
const { userIdentityData } = useUserData();
|
const { userIdentityData } = useUserData();
|
||||||
const { isDarkMode } = useUserSettingsContext();
|
const { isDarkMode } = useUserSettingsContext();
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useEffect(() => {
|
||||||
|
if (userIdentityData) {
|
||||||
|
setIsUserDataFetched(true);
|
||||||
|
}
|
||||||
|
}, [userIdentityData]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
if (session === null) {
|
if (session === null) {
|
||||||
redirectToLogin();
|
redirectToLogin();
|
||||||
} else {
|
|
||||||
setTimeout(() => setIsPageLoaded(true), 1000);
|
|
||||||
}
|
}
|
||||||
}, [pathname, session]);
|
}, [pathname, session]);
|
||||||
|
|
||||||
@ -80,7 +84,7 @@ const Search = (): JSX.Element => {
|
|||||||
</div>
|
</div>
|
||||||
{!isBrainCreationModalOpened &&
|
{!isBrainCreationModalOpened &&
|
||||||
!userIdentityData?.onboarded &&
|
!userIdentityData?.onboarded &&
|
||||||
!!isPageLoaded && (
|
!!isUserDataFetched && (
|
||||||
<div className={styles.onboarding_overlay}>
|
<div className={styles.onboarding_overlay}>
|
||||||
<div className={styles.first_brain_button}>
|
<div className={styles.first_brain_button}>
|
||||||
<MessageInfoBox type="tutorial">
|
<MessageInfoBox type="tutorial">
|
||||||
|
Loading…
Reference in New Issue
Block a user