#!/bin/bash
# Fix products.ts to use cutout_image_url
FILE="/var/www/sneakerpicks/src/lib/products.ts"

# 1. Add cutout_image_url to SELECT queries
sed -i 's/SELECT p.id, p.name, p.slug, p.brand, p.colorway, p.gender, p.image_url, p.original_price,/SELECT p.id, p.name, p.slug, p.brand, p.colorway, p.gender, p.image_url, p.cutout_image_url, p.original_price,/g' "$FILE"

# 2. Update image mapping to prefer cutout_image_url
sed -i "s|image: p\.image_url || 'https://placehold\.co/600x600/0D0B10/D69F7E?text=No+Image'|image: p.cutout_image_url || p.image_url || 'https://placehold.co/600x600/0D0B10/D69F7E?text=No+Image'|g" "$FILE"

# Verify
echo "=== Cutout references ==="
grep -n 'cutout' "$FILE"
echo "=== Image mapping ==="
grep -n 'image: p\.' "$FILE"
