<?php

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

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

$response = array();

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

$activo = $_POST['activo'];

$faqs = Faq::mdlGetFaqs($activo);

if (!$faqs) {
    $response['response'] = 'error';
    $response['data'] = 'No se encontraron FAQs';
    echo json_encode($response);
    return;
}

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

echo json_encode($response);