<?php

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: *');

require '../../modelo/conexion.php';
require '../../modelo/faq.php';
require '../usuario/decodeUsuario.php';

$response = array();

if (
    !isset($_POST['id_faq'])
) {
    $response['response'] = 'error';
    $response['data'] = 'Datos incompletos';
    echo json_encode($response);
    return;
}

$id_faq = $_POST['id_faq'];

$faq = Faq::mdlGetFaq($id_faq);

if (!$faq) {
    $response['response'] = 'error';
    $response['data'] = 'No se encontró la FAQ';
    echo json_encode($response);
    return;
}

$response['response'] = 'success';
$response['data'] = $faq;

echo json_encode($response);