import { delay } from './api';
import { mockStores } from '@/data/mockStores';
import type { Store } from '@/types';

let stores = [...mockStores];

export const storeService = {
  // GET /api/stores/:slug
  getBySlug: (slug: string) =>
    delay(stores.find((s) => s.slug === slug) ?? null),
  getById: (id: string) =>
    delay(stores.find((s) => s.id === id) ?? null),
  // GET/PUT /api/store/settings
  updateSettings: (id: string, patch: Partial<Store>) => {
    stores = stores.map((s) => (s.id === id ? { ...s, ...patch } : s));
    return delay(stores.find((s) => s.id === id) ?? null);
  },
};
