Add self-hosted auth, admin API, and owner web dashboard
- Replace Clerk with self-hosted JWT auth (register/login/verify, bcrypt passwords, Gmail OTP with console fallback) - Add lib/db.ts pg pool + transaction helpers; seed script migrates legacy Clerk-era schema (drop clerk_id, enforce UUID ids and unique email) - Add owner-gated admin API: stats, users, drivers CRUD, rides - Add dashboard/ Vite React owner dashboard (login, overview, users, fleet, rides) with dev-server proxy to avoid Expo CORS middleware - Add scripts/set-owner.mjs for role management
This commit is contained in:
+6
-4
@@ -1,17 +1,17 @@
|
||||
import { useUser } from "@clerk/clerk-expo";
|
||||
import { router } from "expo-router";
|
||||
import { useState } from "react";
|
||||
import { Alert, Text, TouchableOpacity, View } from "react-native";
|
||||
import { SafeAreaView } from "react-native-safe-area-context";
|
||||
|
||||
import { fetchAPI } from "@/lib/fetch";
|
||||
import { useSession } from "@/lib/session";
|
||||
|
||||
const RoleSelection = () => {
|
||||
const { user } = useUser();
|
||||
const { setUserRole } = useSession();
|
||||
const [saving, setSaving] = useState(false);
|
||||
|
||||
const chooseRole = async (role: "rider" | "driver") => {
|
||||
if (!user?.id || saving) return;
|
||||
if (saving) return;
|
||||
|
||||
setSaving(true);
|
||||
|
||||
@@ -19,11 +19,13 @@ const RoleSelection = () => {
|
||||
const { error } = await fetchAPI("/(api)/user", {
|
||||
method: "PATCH",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ clerkId: user.id, role }),
|
||||
body: JSON.stringify({ role }),
|
||||
});
|
||||
|
||||
if (error) throw new Error(error);
|
||||
|
||||
setUserRole(role);
|
||||
|
||||
router.replace(
|
||||
role === "driver" ? "/(root)/driver-home" : "/(root)/(tabs)/home",
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user