import AsyncStorage from "@react-native-async-storage/async-storage";

const KEY = "menulio.active-restaurant";

export interface ActiveRestaurant {
  restaurantId: string;
  locationId: string;
  menuId: string;
  slug: string;
}

export async function getActiveRestaurant(): Promise<ActiveRestaurant | null> {
  const raw = await AsyncStorage.getItem(KEY);
  return raw ? (JSON.parse(raw) as ActiveRestaurant) : null;
}

export async function setActiveRestaurant(value: ActiveRestaurant): Promise<void> {
  await AsyncStorage.setItem(KEY, JSON.stringify(value));
}

export async function clearActiveRestaurant(): Promise<void> {
  await AsyncStorage.removeItem(KEY);
}
