From 6ef816820adca222e46617d628410acd75ab0e2d Mon Sep 17 00:00:00 2001 From: aliraza556 Date: Sun, 27 Oct 2024 15:27:25 +0500 Subject: [PATCH] fix(onboarding-flow): implement onboarding functionality --- src/components/App/index.tsx | 29 ++- .../OnboardingFlow/GraphDetailsStep/index.tsx | 169 ++++++++++++++++++ .../ModalsContainer/OnboardingFlow/index.tsx | 80 +++++++++ src/components/ModalsContainer/index.tsx | 40 +++-- src/stores/useModalStore/index.ts | 2 + 5 files changed, 300 insertions(+), 20 deletions(-) create mode 100644 src/components/ModalsContainer/OnboardingFlow/GraphDetailsStep/index.tsx create mode 100644 src/components/ModalsContainer/OnboardingFlow/index.tsx diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index bf355b12b..7254af6eb 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -15,6 +15,7 @@ import { useAppStore } from '~/stores/useAppStore' import { useDataStore } from '~/stores/useDataStore' import { useFeatureFlagStore } from '~/stores/useFeatureFlagStore' import { useUpdateSelectedNode } from '~/stores/useGraphStore' +import { useModal } from '~/stores/useModalStore' import { useTeachStore } from '~/stores/useTeachStore' import { useUserStore } from '~/stores/useUserStore' import { @@ -53,12 +54,17 @@ const LazyMainToolbar = lazy(() => import('./MainToolbar').then(({ MainToolbar } const LazyUniverse = lazy(() => import('~/components/Universe').then(({ Universe }) => ({ default: Universe }))) const LazySideBar = lazy(() => import('./SideBar').then(({ SideBar }) => ({ default: SideBar }))) +const LazyOnboardingModal = lazy(() => + import('../ModalsContainer/OnboardingFlow').then(({ OnboardingModal }) => ({ default: OnboardingModal })), +) + export const App = () => { const [searchParams] = useSearchParams() const query = searchParams.get('q') - const { setBudget, setNodeCount } = useUserStore((s) => s) + const { setBudget, setNodeCount, isAdmin } = useUserStore((s) => s) const queueRef = useRef(null) const timerRef = useRef(null) + const { open, visible } = useModal('onboardingFlow') const { setSidebarOpen, @@ -68,6 +74,7 @@ export const App = () => { setTranscriptOpen, universeQuestionIsOpen, setUniverseQuestionIsOpen, + appMetaData, } = useAppStore((s) => s) const setTeachMeAnswer = useTeachStore((s) => s.setTeachMeAnswer) @@ -322,10 +329,16 @@ export const App = () => { }, [runningProjectId, setRunningProjectMessages]) useEffect(() => { - if (!splashDataLoading) { + if (isAdmin && !appMetaData?.title && !visible) { + open() + } + }, [isAdmin, appMetaData?.title, open, visible]) + + useEffect(() => { + if (!splashDataLoading && !visible) { setUniverseQuestionIsOpen() } - }, [setUniverseQuestionIsOpen, splashDataLoading]) + }, [setUniverseQuestionIsOpen, splashDataLoading, visible]) return ( <> @@ -336,7 +349,13 @@ export const App = () => {