Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions components/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,28 @@ import contactusImage from "/public/contact-us.webp";
const ContactForm = () => {
const [sending, setSending] = useState<boolean>(false);

const handleSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
setSending(true);
const form = e.currentTarget;
const formData = new FormData(form);
const data = Object.fromEntries(formData);

await fetch("/api/contact", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
const formElement = event.currentTarget;
const formData = new FormData(formElement);
const formEntries = Object.fromEntries(formData);

form.reset();
setSending(false);
try {
await fetch("/api/contact", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(formEntries),
});
formElement.reset();
} catch (error) {
console.error("Error submitting form:", error);
} finally {
setSending(false);
}
};
return (
<section
Expand Down
13 changes: 13 additions & 0 deletions components/Projects.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
import Project from "./Project";
import { fetchData } from "../db/fetchData";

export async function getStaticProps() {
const data = (await fetchData()) || [];
return {
props: {
data,
},
// Next.js will attempt to re-generate the page:
// - When a request comes in
// - At most once every 10 seconds
revalidate: 10, // In seconds
};
}

type ProjectProps = {
id: number;
name: string;
Expand Down
20 changes: 20 additions & 0 deletions global-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"use client";

import * as Sentry from "@sentry/nextjs";
import NextError from "next/error";
import { useEffect } from "react";

export default function GlobalError({ error }) {
useEffect(() => {
Sentry.captureException(error);
}, [error]);

return (
<html>
<body>
{/* This is the default Next.js error component but it doesn't allow omitting the statusCode property yet. */}
<NextError statusCode={undefined} />
</body>
</html>
);
}
File renamed without changes.
8 changes: 1 addition & 7 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ const nextConfig = {
webpack: (config) => {
config.module.rules.push({
test: /\.pdf$/,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]",
},
},
use: { loader: "file-loader", options: { name: "[name].[ext]" } },
});
return config;
},
Expand All @@ -18,7 +13,6 @@ const nextConfig = {
formats: ["image/webp"],
},
reactStrictMode: true,
swcMinify: true,
};

// const nextConfig = {}
Expand Down
Loading