5c035ba1c0
- Added lucide-react to package dependencies - Refactored MainForm to improve form handling and user selection - Removed SuccessPage component and related logic - Updated localization files to include new keys for invoice details - Created interfaces for form data and messages
34 lines
814 B
TypeScript
34 lines
814 B
TypeScript
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 };
|
|
}
|
|
};
|