import { API_BASE } from "../config/api.config"; import type { FormData } from "../config/interfaces.config"; export const submitFormData = async ( data: FormData, username: string | null, ) => { if (username == null) { return { success: false, errorCode: "x001" }; } try { const response = await fetch( `${API_BASE}/default/new-entry?username=${username}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify(data), }, ); if (!response.ok) { const errorText = await response.text(); return { success: false, error: `Server error: ${errorText}` }; } return { success: true }; } catch (error) { return { success: false, error: (error as Error).message }; } };