import { delay } from './api';
import { mockThemes } from '@/data/mockStores';
import type { StoreTheme, ThemePreset } from '@/types';

let themes = [...mockThemes];

export const themePresets: ThemePreset[] = [
  {
    id: 'moderno',
    name: 'Moderno',
    description: 'Cores vibrantes, cards arredondados e bastante respiro.',
    primaryColor: '#4f46e5',
    secondaryColor: '#0f172a',
    buttonColor: '#4f46e5',
  },
  {
    id: 'minimalista',
    name: 'Minimalista',
    description: 'Tipografia limpa, tons neutros e foco no produto.',
    primaryColor: '#059669',
    secondaryColor: '#1c1917',
    buttonColor: '#111827',
  },
  {
    id: 'vitrine',
    name: 'Vitrine Premium',
    description: 'Visual editorial, contraste alto e ar de loja premium.',
    primaryColor: '#b45309',
    secondaryColor: '#1c1917',
    buttonColor: '#b45309',
  },
];

export const themeService = {
  // GET /api/store/theme
  get: (storeId: string) =>
    delay(themes.find((t) => t.storeId === storeId) ?? null),
  // PUT /api/store/theme
  update: (storeId: string, patch: Partial<StoreTheme>) => {
    themes = themes.map((t) => (t.storeId === storeId ? { ...t, ...patch } : t));
    return delay(themes.find((t) => t.storeId === storeId) ?? null);
  },
};
