#!/bin/bash
set -e
HOST="aissa@10.4.7.18"
PASS='Foodlinkk#2026'
BASE="/tmp/foodlinkk-deploy"
R="~/foodlinkk-command-center"

echo "=== Layout fix: Herman dashboard + Retail filters + Regelgeving → Marketing ==="

sshpass -p "$PASS" scp -o StrictHostKeyChecking=no \
  "$BASE/cockpit/templates/dashboard.html" \
  "$BASE/cockpit/templates/retail.html" \
  "$BASE/cockpit/templates/marketing.html" \
  "$HOST:$R/cockpit/templates/"

sshpass -p "$PASS" scp -o StrictHostKeyChecking=no \
  "$BASE/cockpit/static/css/herman-dashboard.css" \
  "$HOST:$R/cockpit/static/css/"

sshpass -p "$PASS" scp -o StrictHostKeyChecking=no \
  "$BASE/cockpit/static/retail.css" \
  "$HOST:$R/cockpit/static/"

sshpass -p "$PASS" scp -o StrictHostKeyChecking=no \
  "$BASE/cockpit/static/js/briefing-charts.js" \
  "$HOST:$R/cockpit/static/js/"

sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no "$HOST" bash <<'REMOTE'
set -e
cd ~/foodlinkk-command-center
docker compose build cockpit
docker compose up -d cockpit
sleep 6
curl -sf -o /dev/null -w "dashboard: %{http_code}\n" http://localhost:8600/
curl -sf -o /dev/null -w "retail: %{http_code}\n" http://localhost:8600/retail
curl -sf -o /dev/null -w "marketing: %{http_code}\n" http://localhost:8600/marketing
REMOTE

sshpass -p "$PASS" ssh -o StrictHostKeyChecking=no aissa@10.4.7.19 \
  'python3 ~/foodlinkk-ai/hermes/notify.py --team "UI layout fix: Herman dashboard netjes in secties. Retail filters uitgelijnd. Regelgeving verplaatst naar Marketing Hub tab. Hard refresh Ctrl+Shift+R"'

echo DONE
