'use client';
import { useApi } from './useApi';
import { storeService } from '@/services/store.service';
import { themeService } from '@/services/theme.service';

/** Carrega dados públicos da loja + tema pelo slug. */
export function useStore(slug: string) {
  const { data: store, loading: loadingStore } = useApi(
    () => storeService.getBySlug(slug),
    [slug],
  );
  const { data: theme, loading: loadingTheme } = useApi(
    () => (store ? themeService.get(store.id) : Promise.resolve(null)),
    [store?.id],
  );
  return { store, theme, loading: loadingStore || loadingTheme };
}
