'use server'

import { API_URL, TOKEN } from "@/utils/constants/selectConstants";

interface dadosCadastroSugestoes {
    Nome: string,
    NomePet: string,
    Documento: string,
    MotivoContato: string,
    Observacao: string,
    Email:string
};

export async function postDataSuggestion(data: dadosCadastroSugestoes) {
    try {
        const url = `${API_URL}SiteSugestao/inserir/`;

        const response = await fetch(url, {
            method: 'POST',
            headers: {
                Authorization: TOKEN,
                'Content-Type': 'application/json',
                LocalAcesso: 'Site'
            },
            body: JSON.stringify(data),
        });

        const result = await response.json();
        return result;
    } catch (error) {
        console.error('Erro ao realizar o POST:', error);
        throw error;
    }
}
