-- =============================================================================
-- SEED: Storefront templates — `classic` (free) and `boutique` (premium)
--
-- `classic` is everything the storefront ships today, published immediately so
-- the merchant picker is never empty and so NULL → classic has a real row to
-- resolve to.
--
-- `boutique` is seeded UNPUBLISHED on purpose. Its components do not exist yet
-- (Phase 6); unpublish is the global kill switch that /api/store/config honours,
-- so an unpublished row can sit in the table safely and be flipped on with a
-- single UPDATE once it passes its performance gate.
--
-- Existing stores are NOT backfilled — storefrontTemplateId stays NULL and
-- resolves to `classic`.
--
-- Idempotent — uses ON CONFLICT DO NOTHING on slug
-- =============================================================================

BEGIN;

-- `previewImageUrl` holds a REMOTE url, not a path into our uploads dir.
-- These are illustrative stock photos for the picker card, not merchant
-- content: they do not belong in the uploads quota, do not need backing up,
-- and must not be served through /api/img (which only resizes files inside
-- the uploads root). The storefront image loader passes absolute URLs through
-- untouched, so nothing tries to rewrite them.
--
-- Replace with real per-template screenshots when they exist — see the open
-- question in docs/16-storefront-templates.md about who produces them.
INSERT INTO platform.storefront_templates (
    id, name, slug, description, "previewImageUrl", tier, metadata,
    "isPublished", "isActive", "sortOrder", "createdBy", "updatedBy"
)
VALUES

-- Template 1: Classic — the current storefront, free for everyone
(
    gen_random_uuid()::text,
    'Classic',
    'classic',
    'The original Shopora storefront — a stacked homepage, straightforward product list, and single-column product page. Works with every theme.',
    'https://images.unsplash.com/photo-1441986300917-64674bd600d8?w=800&h=500&fit=crop&q=80&auto=format',
    'free',
    '{
        "features": [
            "Stacked homepage with hero carousel",
            "Category and deals sections",
            "Single-column product detail page",
            "Works with every theme"
        ],
        "badge": "Included"
    }'::jsonb,
    TRUE, TRUE, 0, 'system', 'system'
),

-- Template 2: Boutique — premium, intentionally unpublished until Phase 6
(
    gen_random_uuid()::text,
    'Boutique',
    'boutique',
    'An editorial, image-led storefront: full-bleed hero, asymmetric category grid, faceted product list, and a sticky buy panel on the product page.',
    'https://images.unsplash.com/photo-1445205170230-053b83016050?w=800&h=500&fit=crop&q=80&auto=format',
    'premium',
    '{
        "features": [
            "Full-bleed editorial hero",
            "Asymmetric category grid",
            "Faceted product list with filter chips",
            "Sticky buy panel and related-products rail on product pages"
        ],
        "badge": "Premium"
    }'::jsonb,
    FALSE, TRUE, 1, 'system', 'system'
)

ON CONFLICT (slug) DO NOTHING;

COMMIT;
