import 'server-only';
import {readProfile} from '@/features/settings/mock/settings.mock';
import type {MerchantProfile} from '@/features/settings/types/settings';

/**
 * The server-side half of the settings repository.
 *
 * Server Components can read data without an HTTP round trip, and a settings
 * form should: it has exactly one known state at page load, so fetching it
 * over the network from the same process that already has it would only add a
 * flash of empty inputs.
 *
 * What matters is that the PAGE does not import the fixture. It asks this
 * module, and this module is the single place that changes when the data comes
 * from Postgres or from an upstream service instead — exactly like its client
 * sibling, settingsRepository, which the same page's form saves through.
 *
 * Async today only because every real implementation of it will be.
 */
export const settingsServerRepository = {
  async getProfile(): Promise<MerchantProfile> {
    return readProfile();
  },
};
