Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Prettier #280

Merged
merged 1 commit into from
Dec 13, 2024
Merged
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
5 changes: 1 addition & 4 deletions app/contact/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ export const metadata: Metadata = {
};

export default function Layout({ children }: { children: React.ReactNode }) {
return (
<div>{children}</div>

);
return <div>{children}</div>;
}
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import ModeToggle from "@/components/mode-toggle";
import Nav from "@/components/nav";
import Footer from "@/components/footer";
import Script from "next/script";
import { Toaster } from "@/components/ui/toaster"
import { Toaster } from "@/components/ui/toaster";
export const metadata: Metadata = {
title: {
template: "%s | Persona.fm",
Expand Down Expand Up @@ -64,7 +64,7 @@ export default function RootLayout({
>
{children}
</div>
<Toaster/>
<Toaster />
<Footer />
<ModeToggle />
</ThemeProvider>
Expand Down
128 changes: 70 additions & 58 deletions components/contact.tsx
Original file line number Diff line number Diff line change
@@ -1,64 +1,76 @@
"use client"
"use client";

import { Button } from "@/components/ui/button"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { useToast } from "@/hooks/use-toast"
import { useState, useRef } from "react"
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Textarea } from "@/components/ui/textarea";
import { useToast } from "@/hooks/use-toast";
import { useState, useRef } from "react";

export default function ContactForm() {
const [isLoading, setIsLoading] = useState(false)
const { toast } = useToast()
const formRef = useRef<HTMLFormElement>(null) // Add form reference
async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault()
setIsLoading(true)
const [isLoading, setIsLoading] = useState(false);
const { toast } = useToast();
const formRef = useRef<HTMLFormElement>(null); // Add form reference
async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
event.preventDefault();
setIsLoading(true);

// Simulate form submission
await new Promise((resolve) => setTimeout(resolve, 1000))

setIsLoading(false)
toast({
title: "Message sent",
description: "We'll get back to you within 3 business days.",
})


formRef.current?.reset()
}
// Simulate form submission
await new Promise((resolve) => setTimeout(resolve, 1000));

return (
<Card className="w-full max-w-md">
<CardHeader>
<CardTitle>Contact Us</CardTitle>
<CardDescription>
Report a bug, request a feature, or submit feedback
</CardDescription>
</CardHeader>
<CardContent>
<form ref={formRef} onSubmit={onSubmit} className="space-y-4">

<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input id="email" type="email" placeholder="Enter your email" required />
</div>
<div className="space-y-2">
<Label htmlFor="message">Message</Label>
<Textarea
id="message"
placeholder="Type your message here"
className="min-h-[100px]"
required
/>
</div>
<Button type="submit" className="w-full" disabled={isLoading}>
{isLoading ? "Sending..." : "Send message"}
</Button>
</form>
</CardContent>
</Card>
)
}
setIsLoading(false);
toast({
title: "Message sent",
description: "We'll get back to you within 3 business days.",
});

formRef.current?.reset();
}

return (
<Card className="w-full max-w-md">
<CardHeader>
<CardTitle>Contact Us</CardTitle>
<CardDescription>
Report a bug, request a feature, or submit feedback
</CardDescription>
</CardHeader>
<CardContent>
<form ref={formRef} onSubmit={onSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="Enter your email"
required
/>
</div>
<div className="space-y-2">
<Label htmlFor="message">Message</Label>
<Textarea
id="message"
placeholder="Type your message here"
className="min-h-[100px]"
required
/>
</div>
<Button
type="submit"
className="w-full"
disabled={isLoading}
>
{isLoading ? "Sending..." : "Send message"}
</Button>
</form>
</CardContent>
</Card>
);
}
Loading
Loading