2024-07-03 19:29:49 +02:00
|
|
|
"use client";
|
|
|
|
import Iconss from "@/components/ui/icons";
|
2024-07-05 21:29:16 +02:00
|
|
|
import { Mail, Send, WebhookIcon, Bug, Shield } from "lucide-react";
|
2024-07-03 19:29:49 +02:00
|
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
|
|
import { useForm } from "react-hook-form";
|
|
|
|
import { z } from "zod";
|
|
|
|
import { contactFormSchema } from "@/lib/validations/validation";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
|
|
import {
|
|
|
|
Form,
|
|
|
|
FormControl,
|
|
|
|
FormDescription,
|
|
|
|
FormField,
|
|
|
|
FormItem,
|
|
|
|
FormLabel,
|
|
|
|
FormMessage,
|
|
|
|
} from "@/components/ui/form";
|
|
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
import { Textarea } from "@/components/ui/textarea";
|
2024-07-03 19:47:51 +02:00
|
|
|
import { useToast } from "@/components/ui/use-toast";
|
|
|
|
import { useState } from "react";
|
2024-07-03 19:29:49 +02:00
|
|
|
|
|
|
|
const ContactUs = () => {
|
2024-07-03 19:47:51 +02:00
|
|
|
const { toast } = useToast();
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
|
2024-07-03 19:29:49 +02:00
|
|
|
const form = useForm<z.infer<typeof contactFormSchema>>({
|
|
|
|
resolver: zodResolver(contactFormSchema),
|
|
|
|
defaultValues: {
|
|
|
|
name: "",
|
|
|
|
email: "",
|
|
|
|
message: "",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
async function onSubmit(values: z.infer<typeof contactFormSchema>) {
|
2024-07-03 19:47:51 +02:00
|
|
|
setLoading(true);
|
|
|
|
try {
|
|
|
|
const res = await fetch("/api/contact", {
|
|
|
|
method: "POST",
|
|
|
|
body: JSON.stringify(values),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
Accept: "application/json",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
form.reset();
|
|
|
|
toast({
|
|
|
|
description: "Your message has been sent.",
|
|
|
|
});
|
|
|
|
setLoading(false);
|
|
|
|
} else {
|
|
|
|
toast({
|
|
|
|
title: "Uh oh! Something went wrong.",
|
|
|
|
variant: "destructive",
|
|
|
|
});
|
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
toast({
|
|
|
|
title: "Uh oh! Something went wrong.",
|
|
|
|
variant: "destructive",
|
|
|
|
});
|
|
|
|
setLoading(false);
|
|
|
|
}
|
|
|
|
|
2024-07-03 19:29:49 +02:00
|
|
|
console.log(values);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<div className="flex items-center justify-center py-16 md:py-24 w-full transition-all duration-300">
|
|
|
|
<h1 className="text-4xl md:text-6xl tracking-tight font-bold uppercase">
|
|
|
|
Contact Us
|
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<section id="contact" className="w-full">
|
2024-07-05 21:29:16 +02:00
|
|
|
<div className="flex max-md:flex-center flex-col md:flex-row justify-between mx-auto p-5 max-w-4xl">
|
2024-07-03 19:29:49 +02:00
|
|
|
{/* Left contact page */}
|
|
|
|
<Form {...form}>
|
|
|
|
<form
|
|
|
|
onSubmit={form.handleSubmit(onSubmit)}
|
|
|
|
className="space-y-4 pb-8 mb-4 max-w-sm w-full"
|
|
|
|
>
|
|
|
|
<FormField
|
|
|
|
control={form.control}
|
|
|
|
name="name"
|
|
|
|
render={({ field }) => (
|
|
|
|
<FormItem>
|
|
|
|
<FormLabel>Name</FormLabel>
|
|
|
|
<FormControl>
|
|
|
|
<Input placeholder="Your Name" {...field} />
|
|
|
|
</FormControl>
|
|
|
|
<FormMessage />
|
|
|
|
</FormItem>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<FormField
|
|
|
|
control={form.control}
|
|
|
|
name="email"
|
|
|
|
render={({ field }) => (
|
|
|
|
<FormItem>
|
|
|
|
<FormLabel>Email</FormLabel>
|
|
|
|
<FormControl>
|
|
|
|
<Input type="email" placeholder="Your Email" {...field} />
|
|
|
|
</FormControl>
|
|
|
|
<FormMessage />
|
|
|
|
</FormItem>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<FormField
|
|
|
|
control={form.control}
|
|
|
|
name="message"
|
|
|
|
render={({ field }) => (
|
|
|
|
<FormItem>
|
|
|
|
<FormLabel>Message</FormLabel>
|
|
|
|
<FormControl>
|
|
|
|
<Textarea placeholder="Your Message" {...field} />
|
|
|
|
</FormControl>
|
|
|
|
<FormMessage />
|
|
|
|
</FormItem>
|
|
|
|
)}
|
|
|
|
/>
|
2024-07-03 19:47:51 +02:00
|
|
|
<Button
|
|
|
|
type="submit"
|
|
|
|
variant={"default"}
|
|
|
|
className="w-full"
|
|
|
|
disabled={loading}
|
|
|
|
>
|
2024-07-03 19:29:49 +02:00
|
|
|
<div className="flex items-center justify-center">
|
|
|
|
<span className="tracking-tight font-[600px]">SEND</span>
|
|
|
|
<Send className="ml-2 w-5 h-5" />
|
|
|
|
</div>
|
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
</Form>
|
|
|
|
|
|
|
|
{/* Right contact page */}
|
|
|
|
<div className="max-w-xl mt-3 md:ml-5">
|
|
|
|
<ul className="ml-2 max-md:flex-center flex-col pr-5">
|
|
|
|
<li className="mb-2 text-[#aaa] flex items-center">
|
2024-07-05 21:29:16 +02:00
|
|
|
<WebhookIcon className="mr-2" size={24} />
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
href="mailto:#"
|
|
|
|
title="Send me an email"
|
|
|
|
className="opacity-70 hover:opacity-100 transition duration-200"
|
|
|
|
>
|
|
|
|
webmaster@svrjs.org
|
|
|
|
</a>
|
|
|
|
</span>
|
2024-07-03 19:29:49 +02:00
|
|
|
</li>
|
|
|
|
<li className="mb-2 text-[#aaa] flex items-center">
|
2024-07-05 21:29:16 +02:00
|
|
|
<Bug className="mr-2" size={24} />
|
2024-07-03 19:29:49 +02:00
|
|
|
<span>
|
|
|
|
<a
|
2024-07-05 21:29:16 +02:00
|
|
|
href="mailto:#"
|
|
|
|
title="Send me an email"
|
|
|
|
className="opacity-70 hover:opacity-100 transition duration-200"
|
2024-07-03 19:29:49 +02:00
|
|
|
>
|
|
|
|
bugreports@svrjs.org
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</li>
|
2024-07-05 21:29:16 +02:00
|
|
|
<li className="mb-2 text-[#aaa] flex items-center">
|
|
|
|
<Shield className="mr-2" size={24} />
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
href="mailto:#"
|
|
|
|
title="Send me an email"
|
|
|
|
className="opacity-70 hover:opacity-100 transition duration-200"
|
|
|
|
>
|
|
|
|
vulnerability-reports@svrjs.org
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</li>
|
2024-07-03 19:29:49 +02:00
|
|
|
<li className="mb-2 text-[#aaa] flex items-center">
|
|
|
|
<Mail className="mr-2" size={24} />
|
|
|
|
<span>
|
|
|
|
<a
|
|
|
|
href="mailto:#"
|
|
|
|
title="Send me an email"
|
2024-07-05 21:29:16 +02:00
|
|
|
className="opacity-70 hover:opacity-100 transition duration-200"
|
2024-07-03 19:29:49 +02:00
|
|
|
>
|
|
|
|
support@svrjs.org
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<hr className="border-t border-white opacity-60 my-4" />
|
|
|
|
<ul className="flex justify-center space-x-3 mb-6">
|
|
|
|
<Iconss />
|
|
|
|
</ul>
|
|
|
|
<hr className="border-t border-white opacity-60 my-4" />
|
|
|
|
<div className="text-center text-[#555] text-sm font-light">
|
2024-07-05 21:29:16 +02:00
|
|
|
© ALL RIGHTS RESERVED SVRJS
|
2024-07-03 19:29:49 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ContactUs;
|