Use tRPC and react-hook-form

This commit is contained in:
Timothy Armes
2023-09-11 10:28:02 +02:00
parent 7111f000e5
commit ac633670ab
42 changed files with 5490 additions and 587 deletions
-42
View File
@@ -1,42 +0,0 @@
import { TournamentFormProps } from "@/types";
import formatDate from "@/utils/formatDate";
const discordWebhook = async ({
tournamentNameRef,
countryRef,
dateRef,
timeControlRef,
yourNameRef,
yourEmailRef,
messageRef,
}: TournamentFormProps) => {
const webhookBody = {
embeds: [
{
title: "Tournament Submitted",
fields: [
{ name: "Tournament", value: tournamentNameRef.current?.value },
{ name: "Country", value: countryRef.current?.value },
{ name: "Date", value: formatDate(dateRef.current?.value) },
{
name: "Time Control",
value: timeControlRef.current?.value,
},
{ name: "Sender", value: yourNameRef.current?.value },
{ name: "Sender Email", value: yourEmailRef.current?.value },
{ name: "Message", value: messageRef.current?.value },
],
},
],
};
return await fetch("/api/send-discord-notification", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(webhookBody),
});
};
export default discordWebhook;
-29
View File
@@ -1,29 +0,0 @@
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;