From 6433379f44d6d21bd99d1b962f85f1459a76fc02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qu=E1=BB=91c=20Kh=C3=A1nh?= Date: Sun, 9 Jun 2024 02:00:54 +0700 Subject: [PATCH] feat(mobile): setup clerk email auth and integrate with api rpc --- apps/api/package.json | 2 + apps/api/tsconfig.json | 5 +- apps/mobile/.env.example | 3 + .../mobile/app/{ => (app)}/(tabs)/_layout.tsx | 6 +- apps/mobile/app/(app)/(tabs)/explore.tsx | 47 + apps/mobile/app/(app)/(tabs)/index.tsx | 7 + apps/mobile/app/(app)/_layout.tsx | 17 + apps/mobile/app/(auth)/_layout.tsx | 19 + apps/mobile/app/(auth)/login.tsx | 12 + apps/mobile/app/(tabs)/explore.tsx | 25 - apps/mobile/app/(tabs)/index.tsx | 7 - apps/mobile/app/_layout.tsx | 42 +- apps/mobile/components/auth/auth-email.tsx | 114 + apps/mobile/lib/cache.ts | 25 + apps/mobile/lib/client.ts | 18 + apps/mobile/metro.config.js | 3 + apps/mobile/package.json | 11 +- apps/mobile/tsconfig.json | 1 + pnpm-lock.yaml | 2178 +++++++++++++++-- 19 files changed, 2316 insertions(+), 226 deletions(-) create mode 100644 apps/mobile/.env.example rename apps/mobile/app/{ => (app)}/(tabs)/_layout.tsx (78%) create mode 100644 apps/mobile/app/(app)/(tabs)/explore.tsx create mode 100644 apps/mobile/app/(app)/(tabs)/index.tsx create mode 100644 apps/mobile/app/(app)/_layout.tsx create mode 100644 apps/mobile/app/(auth)/_layout.tsx create mode 100644 apps/mobile/app/(auth)/login.tsx delete mode 100644 apps/mobile/app/(tabs)/explore.tsx delete mode 100644 apps/mobile/app/(tabs)/index.tsx create mode 100644 apps/mobile/components/auth/auth-email.tsx create mode 100644 apps/mobile/lib/cache.ts create mode 100644 apps/mobile/lib/client.ts diff --git a/apps/api/package.json b/apps/api/package.json index 2c192357..12a1ae20 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -2,6 +2,7 @@ "name": "@6pm/api", "version": "0.0.0", "license": "GPL-3.0", + "main": "index.ts", "private": true, "scripts": { "dev": "next dev", @@ -34,6 +35,7 @@ "@types/react-dom": "18.3.0", "prisma": "^5.15.0", "typescript": "^5.4.5", + "vercel": "^34.2.6", "zod-prisma-types": "^3.1.8" } } diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index c1e94dd7..02f8bb2c 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -17,7 +17,8 @@ "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", - "incremental": true + "incremental": true, + "composite": true }, "include": [ "next-env.d.ts", @@ -27,4 +28,4 @@ "exclude": [ "node_modules" ] -} \ No newline at end of file +} diff --git a/apps/mobile/.env.example b/apps/mobile/.env.example new file mode 100644 index 00000000..cf782442 --- /dev/null +++ b/apps/mobile/.env.example @@ -0,0 +1,3 @@ +EXPO_USE_METRO_WORKSPACE_ROOT=1 +EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY= +EXPO_PUBLIC_API_URL= diff --git a/apps/mobile/app/(tabs)/_layout.tsx b/apps/mobile/app/(app)/(tabs)/_layout.tsx similarity index 78% rename from apps/mobile/app/(tabs)/_layout.tsx rename to apps/mobile/app/(app)/(tabs)/_layout.tsx index 22a49b62..db19c68d 100644 --- a/apps/mobile/app/(tabs)/_layout.tsx +++ b/apps/mobile/app/(app)/(tabs)/_layout.tsx @@ -2,16 +2,12 @@ import { Tabs } from 'expo-router'; import React from 'react'; import { TabBarIcon } from '@/components/navigation/TabBarIcon'; -import { Colors } from '@/constants/Colors'; -import { useColorScheme } from '@/hooks/useColorScheme'; export default function TabLayout() { - const colorScheme = useColorScheme(); - return ( { + const hc = await getHonoClient() + const res = await hc.v1.auth.me.$get() + if (res.ok) { + return await res.json() + } else { + throw new Error(await res.text()) + } + }, + }) + + return ( + + + + + CG + + + + SS + + + {data?.email ? `Logged as ${data.email}` : 'loading...'} +