#!/bin/bash
# Create a new Figma file for a product
# Usage: ./figma-create-file.sh <product-name>
#
# NOTE: Figma REST API cannot create files directly.
# This script provides the manual workflow and sets up tracking.

set -e

PRODUCT="${1:?Product name required}"
WORKSPACE="/home/aria/.openclaw/workspace"
PROJECT_DIR="/home/aria/projects/$PRODUCT"

# Load environment
eval $($WORKSPACE/scripts/load-env.sh --export)

if [ -z "$FIGMA_ACCESS_TOKEN" ] || [ -z "$FIGMA_PROJECT_ID" ]; then
    echo "Error: FIGMA_ACCESS_TOKEN and FIGMA_PROJECT_ID must be set in .env" >&2
    exit 1
fi

echo "=============================================="
echo "🎨 Figma File Setup for: $PRODUCT"
echo "=============================================="
echo ""
echo "Step 1: Create file in Figma"
echo "   → Open: https://www.figma.com/files/project/$FIGMA_PROJECT_ID"
echo "   → Click '+' → 'Design file'"  
echo "   → Name it: '$PRODUCT - UI Screens'"
echo ""
echo "Step 2: Copy the file URL (e.g., https://www.figma.com/design/ABC123/...)"
echo ""
echo "Step 3: Run this to save the URL:"
echo "   $WORKSPACE/scripts/figma-set-url.sh $PRODUCT <figma-url>"
echo ""
echo "=============================================="
