<?php
// api/select_story.php  —  Story als ausgewählt markieren
require_once __DIR__ . '/../includes/config.php';
require_once __DIR__ . '/../includes/db.php';
c2c_cors_headers();
require_api_token();

$storyId  = (int)($_GET['story_id'] ?? 0);
$clientId = (int)($_GET['client_id'] ?? 0);

if (!$storyId || !$clientId) json_response(['error' => 'Parameter fehlen'], 422);

$db = C2CDatabase::get();
$db->prepare("UPDATE story_variants SET selected=0 WHERE client_id=?")->execute([$clientId]);
$db->prepare("UPDATE story_variants SET selected=1 WHERE id=? AND client_id=?")->execute([$storyId, $clientId]);

json_response(['success' => true]);
