fix(mobile): update public menu URL format to https://menul.io/menu/:slug
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { router } from "expo-router";
|
||||
import { ActivityIndicator, View } from "react-native";
|
||||
import { api } from "@/lib/api";
|
||||
import { getActiveRestaurant, setActiveRestaurant } from "@/lib/active-restaurant";
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import { clearActiveRestaurant, getActiveRestaurant, setActiveRestaurant } from "@/lib/active-restaurant";
|
||||
import { supabase } from "@/lib/supabase";
|
||||
|
||||
interface MeRestaurantResponse {
|
||||
@@ -55,6 +55,19 @@ export default function Index() {
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn("Index resolve error:", e);
|
||||
|
||||
// A 401 here means the cached session's token is no longer valid
|
||||
// server-side (expired refresh token, deleted user, etc.) — that is
|
||||
// not the same as "no restaurant yet", so send them to login instead
|
||||
// of silently starting onboarding with a broken session.
|
||||
if (e instanceof ApiError && e.status === 401) {
|
||||
await clearActiveRestaurant();
|
||||
await supabase.auth.signOut();
|
||||
if (!cancelled) {
|
||||
router.replace("/(auth)/login");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cancelled) {
|
||||
|
||||
Reference in New Issue
Block a user