mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Add Tournament form
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { LatLngLiteral } from "leaflet";
|
||||
import { TournamentFormProps } from "@/types";
|
||||
import formatDate from "@/utils/formatDate";
|
||||
|
||||
const tournamentFormToDB = async (formRefs: TournamentFormProps) => {
|
||||
const data = {
|
||||
address: formRefs.addressRef.current?.value,
|
||||
town: formRefs.townRef.current?.value.toUpperCase(),
|
||||
department: formRefs.departmentRef.current?.value,
|
||||
tournament: formRefs.tournamentNameRef.current?.value,
|
||||
url: formRefs.urlRef.current?.value,
|
||||
time_control: formRefs.timeControlRef.current?.value,
|
||||
date: formatDate(formRefs.dateRef.current?.value),
|
||||
coordinates: [formRefs.position.lat, formRefs.position.lng],
|
||||
country: formRefs.countryRef.current?.value,
|
||||
norm_tournament: formRefs.normRef.current?.value,
|
||||
};
|
||||
|
||||
return await fetch("/api/add-tournament", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
};
|
||||
|
||||
export default tournamentFormToDB;
|
||||
Reference in New Issue
Block a user