<?php
require_once '../app/onboarding/SiteDetector.php';
require_once '../app/onboarding/ProgressStore.php';

$userId = $_SESSION['heru_smm_user']['id'];

if (isset($_POST['site_url'])) {
  $site = SiteDetector::detectFromUrl($_POST['site_url']);
  // insert site via Config Writer
  ProgressStore::save($userId, ['sites' => [$site]]);
}

header('Location: index.php');
