From 839c9600344e2e85f84d3fe4ac3029901d78a20d Mon Sep 17 00:00:00 2001 From: Vanalite Date: Mon, 15 Sep 2025 17:15:42 +0700 Subject: [PATCH] chore: Reroute to new onboarding flow --- mobile-app/package.json | 1 - mobile-app/src/components/SplashScreen.tsx | 8 +-- mobile-app/src/routeTree.gen.ts | 52 +++++++++++++++++-- mobile-app/src/routes/__root.tsx | 48 ++++++++++++++++-- mobile-app/src/routes/chat.tsx | 10 ++++ mobile-app/src/routes/index.tsx | 58 ++++++++++++++++++++-- mobile-app/src/routes/onboarding.tsx | 17 +++++++ 7 files changed, 179 insertions(+), 15 deletions(-) create mode 100644 mobile-app/src/routes/chat.tsx create mode 100644 mobile-app/src/routes/onboarding.tsx diff --git a/mobile-app/package.json b/mobile-app/package.json index 2ff54bec5..3317af81c 100644 --- a/mobile-app/package.json +++ b/mobile-app/package.json @@ -4,7 +4,6 @@ "version": "0.6.6", "type": "module", "scripts": { - "ios:iphone16": "react-native run-ios --simulator=\"iPhone 16 (iOS 18.6)\"", "dev": "vite --port 1422", "build": "tsc -b && vite build", "lint": "eslint .", diff --git a/mobile-app/src/components/SplashScreen.tsx b/mobile-app/src/components/SplashScreen.tsx index 047f9245c..fedbafa94 100644 --- a/mobile-app/src/components/SplashScreen.tsx +++ b/mobile-app/src/components/SplashScreen.tsx @@ -2,16 +2,18 @@ import { useEffect, useState } from 'react' import { cn } from '@/lib/utils' interface SplashScreenProps { - onComplete: () => void + onComplete?: () => void } -export function SplashScreen({ onComplete }: SplashScreenProps) { +export function SplashScreen({ onComplete }: SplashScreenProps = {}) { const [isVisible, setIsVisible] = useState(true) useEffect(() => { const timer = setTimeout(() => { setIsVisible(false) - setTimeout(onComplete, 300) // Wait for fade out animation + if (onComplete) { + setTimeout(onComplete, 300) // Wait for fade out animation + } }, 2000) return () => clearTimeout(timer) diff --git a/mobile-app/src/routeTree.gen.ts b/mobile-app/src/routeTree.gen.ts index d2fcad568..20d12f74c 100644 --- a/mobile-app/src/routeTree.gen.ts +++ b/mobile-app/src/routeTree.gen.ts @@ -12,6 +12,8 @@ import { Route as rootRoute } from './routes/__root' import { Route as SettingsImport } from './routes/settings' +import { Route as OnboardingImport } from './routes/onboarding' +import { Route as ChatImport } from './routes/chat' import { Route as IndexImport } from './routes/index' // Create/Update Routes @@ -22,6 +24,18 @@ const SettingsRoute = SettingsImport.update({ getParentRoute: () => rootRoute, } as any) +const OnboardingRoute = OnboardingImport.update({ + id: '/onboarding', + path: '/onboarding', + getParentRoute: () => rootRoute, +} as any) + +const ChatRoute = ChatImport.update({ + id: '/chat', + path: '/chat', + getParentRoute: () => rootRoute, +} as any) + const IndexRoute = IndexImport.update({ id: '/', path: '/', @@ -39,6 +53,20 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof IndexImport parentRoute: typeof rootRoute } + '/chat': { + id: '/chat' + path: '/chat' + fullPath: '/chat' + preLoaderRoute: typeof ChatImport + parentRoute: typeof rootRoute + } + '/onboarding': { + id: '/onboarding' + path: '/onboarding' + fullPath: '/onboarding' + preLoaderRoute: typeof OnboardingImport + parentRoute: typeof rootRoute + } '/settings': { id: '/settings' path: '/settings' @@ -53,36 +81,46 @@ declare module '@tanstack/react-router' { export interface FileRoutesByFullPath { '/': typeof IndexRoute + '/chat': typeof ChatRoute + '/onboarding': typeof OnboardingRoute '/settings': typeof SettingsRoute } export interface FileRoutesByTo { '/': typeof IndexRoute + '/chat': typeof ChatRoute + '/onboarding': typeof OnboardingRoute '/settings': typeof SettingsRoute } export interface FileRoutesById { __root__: typeof rootRoute '/': typeof IndexRoute + '/chat': typeof ChatRoute + '/onboarding': typeof OnboardingRoute '/settings': typeof SettingsRoute } export interface FileRouteTypes { fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/settings' + fullPaths: '/' | '/chat' | '/onboarding' | '/settings' fileRoutesByTo: FileRoutesByTo - to: '/' | '/settings' - id: '__root__' | '/' | '/settings' + to: '/' | '/chat' | '/onboarding' | '/settings' + id: '__root__' | '/' | '/chat' | '/onboarding' | '/settings' fileRoutesById: FileRoutesById } export interface RootRouteChildren { IndexRoute: typeof IndexRoute + ChatRoute: typeof ChatRoute + OnboardingRoute: typeof OnboardingRoute SettingsRoute: typeof SettingsRoute } const rootRouteChildren: RootRouteChildren = { IndexRoute: IndexRoute, + ChatRoute: ChatRoute, + OnboardingRoute: OnboardingRoute, SettingsRoute: SettingsRoute, } @@ -97,12 +135,20 @@ export const routeTree = rootRoute "filePath": "__root.tsx", "children": [ "/", + "/chat", + "/onboarding", "/settings" ] }, "/": { "filePath": "index.tsx" }, + "/chat": { + "filePath": "chat.tsx" + }, + "/onboarding": { + "filePath": "onboarding.tsx" + }, "/settings": { "filePath": "settings.tsx" } diff --git a/mobile-app/src/routes/__root.tsx b/mobile-app/src/routes/__root.tsx index b8b33b6c3..a0758d66e 100644 --- a/mobile-app/src/routes/__root.tsx +++ b/mobile-app/src/routes/__root.tsx @@ -1,15 +1,55 @@ import { createRootRoute, Outlet } from '@tanstack/react-router' import { TanStackRouterDevtools } from '@tanstack/router-devtools' import { Toaster } from 'sonner' +import { useState, useEffect } from 'react' export const Route = createRootRoute({ - component: () => ( -
+ component: RootLayout, +}) + +function RootLayout() { + const [isInitialized, setIsInitialized] = useState(false) + + useEffect(() => { + // Initialize mobile app + setIsInitialized(true) + }, []) + + if (!isInitialized) { + return ( +
+
+
+ + + + +
+

Loading Jan Mobile...

+
+
+ ) + } + + return ( +
{process.env.NODE_ENV === 'development' && ( )}
- ), -}) \ No newline at end of file + ) +} \ No newline at end of file diff --git a/mobile-app/src/routes/chat.tsx b/mobile-app/src/routes/chat.tsx new file mode 100644 index 000000000..27adffa3a --- /dev/null +++ b/mobile-app/src/routes/chat.tsx @@ -0,0 +1,10 @@ +import { createFileRoute } from '@tanstack/react-router' +import { ChatScreen } from '@/components/ChatScreen' + +export const Route = createFileRoute('/chat')({ + component: ChatPage, +}) + +function ChatPage() { + return +} \ No newline at end of file diff --git a/mobile-app/src/routes/index.tsx b/mobile-app/src/routes/index.tsx index 797abd374..a02cb44e4 100644 --- a/mobile-app/src/routes/index.tsx +++ b/mobile-app/src/routes/index.tsx @@ -1,6 +1,56 @@ -import { createFileRoute } from '@tanstack/react-router' -import { App } from '@/components/App' +import { createFileRoute, useNavigate } from '@tanstack/react-router' +import { useEffect, useState } from 'react' +import { SplashScreen } from '@/components/SplashScreen' +import { ChatScreen } from '@/components/ChatScreen' export const Route = createFileRoute('/')({ - component: App, -}) \ No newline at end of file + component: HomePage, +}) + +function HomePage() { + const [showSplash, setShowSplash] = useState(true) + const [isNavigating, setIsNavigating] = useState(false) + const navigate = useNavigate() + + useEffect(() => { + // Check if user has completed onboarding + const hasCompletedOnboarding = localStorage.getItem('jan_onboarding_completed') + + const timer = setTimeout(() => { + setShowSplash(false) + if (!hasCompletedOnboarding) { + setIsNavigating(true) + navigate({ to: '/onboarding' }) + } + }, 2300) + + return () => clearTimeout(timer) + }, [navigate]) + + if (showSplash) { + return + } + + if (isNavigating) { + return ( +
+
+
+

Setting up...

+
+
+ ) + } + + const hasCompletedOnboarding = localStorage.getItem('jan_onboarding_completed') + + if (!hasCompletedOnboarding) { + return ( +
+

Redirecting to onboarding...

+
+ ) + } + + return +} \ No newline at end of file diff --git a/mobile-app/src/routes/onboarding.tsx b/mobile-app/src/routes/onboarding.tsx new file mode 100644 index 000000000..eb4668aaf --- /dev/null +++ b/mobile-app/src/routes/onboarding.tsx @@ -0,0 +1,17 @@ +import { createFileRoute, useNavigate } from '@tanstack/react-router' +import { OnboardingScreen } from '@/components/OnboardingScreen' + +export const Route = createFileRoute('/onboarding')({ + component: OnboardingPage, +}) + +function OnboardingPage() { + const navigate = useNavigate() + + const handleOnboardingComplete = () => { + localStorage.setItem('jan_onboarding_completed', 'true') + navigate({ to: '/' }) + } + + return +} \ No newline at end of file