import api from "./axios";

/**
 * Get all stores in the system
 */
export const getAllStores = () => api.get("/stores");

/**
 * Get stores linked to a household
 */
export const getHouseholdStores = (householdId) =>
  api.get(`/stores/household/${householdId}`);

/**
 * Add a store to a household
 */
export const addStoreToHousehold = (householdId, storeId, isDefault = false) =>
  api.post(`/stores/household/${householdId}`, { storeId: storeId, isDefault: isDefault });

/**
 * Remove a store from a household
 */
export const removeStoreFromHousehold = (householdId, storeId) =>
  api.delete(`/stores/household/${householdId}/${storeId}`);

/**
 * Set a store as default for a household
 */
export const setDefaultStore = (householdId, storeId) =>
  api.patch(`/stores/household/${householdId}/${storeId}/default`);

/**
 * Create a new store (system admin only)
 */
export const createStore = (name, location) =>
  api.post("/stores", { name, location });

/**
 * Update store details (system admin only)
 */
export const updateStore = (storeId, name, location) =>
  api.patch(`/stores/${storeId}`, { name, location });

/**
 * Delete a store (system admin only)
 */
export const deleteStore = (storeId) =>
  api.delete(`/stores/${storeId}`);
