import type { BrandingBackgroundImage } from './branding';

/**
 * The holding page a site wears while it is being finished.
 *
 * A new installation belongs to a solar company that has not gone live yet, so
 * the words on this page and the date it is expected to open are settings
 * rather than constants. Everything here is already resolved server-side,
 * including the date in the words the page prints, so the screen never has to
 * guess what a setting meant.
 */
export type LaunchPage = {
    /** Whether visitors are seeing this page right now. */
    enabled: boolean;
    /** The small word above the headline. */
    eyebrow: string;
    headline: string;
    message: string;
    /** The expected launch day as `YYYY-MM-DD`, for the date field. */
    expected_on: string | null;
    /** The same day written as the page says it — "March 2027". */
    expected_label: string | null;
    /** Days left, negative once the date has passed. */
    days_away: number | null;
    /** Who to contact rather than wait: this page's own, or the company's. */
    contact_email: string | null;
    contact_phone: string | null;
    /** The chosen photograph, or null for the page's own colour and lights. */
    background_url: string | null;
};

/** The public page, plus the one flag only a preview sets. */
export type ComingSoonPageProps = LaunchPage & {
    preview?: boolean;
};

/**
 * What the office typed, as opposed to what the page prints. A null here means
 * the box is empty and the page is using its default.
 */
export type LaunchFields = {
    eyebrow: string | null;
    headline: string | null;
    message: string | null;
    expected_on: string | null;
    contact_email: string | null;
    contact_phone: string | null;
};

export type LaunchSettingsProps = {
    launch: LaunchPage;
    fields: LaunchFields;
    /** What an emptied box falls back to. */
    defaults: {
        eyebrow: string;
        headline: string;
        message: string;
    };
    /** The real page, shown to somebody allowed to edit it. */
    previewUrl: string;
    /** The photographs uploaded in the company profile, and the chosen one. */
    background_images: BrandingBackgroundImage[];
    background_path: string | null;
    can: { manage: boolean };
};
