<?php
require '../../app/db.php';
require '../includes/auth.php';

$data = json_decode(file_get_contents("php://input"), true);

$booking_id = $data['booking_id'];
$driver_id  = $data['driver_id'];

$stmt = $pdo->prepare("
UPDATE bookings
SET driver_id=?, status='assigned'
WHERE id=? AND status='pending'
");

$stmt->execute([$driver_id, $booking_id]);

echo json_encode(['success'=>true]);
