Skip to content

Commit

Permalink
cors damn
Browse files Browse the repository at this point in the history
  • Loading branch information
eonurk committed Jul 29, 2024
1 parent ab4f1e2 commit 71e6b89
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import { About } from "@/pages/About";
import { Contact } from "@/pages/Contact";
import { Cellama } from "@/pages/solutions/Cellama";
import { BlogPage } from "@/pages/Blog";
import { Toaster } from "@/components/ui/toaster";

function App() {
return (
<>
<Toaster />
<Router basename="">
<Routes>
<Route path="/" element={<Home />} />
Expand Down
24 changes: 12 additions & 12 deletions src/components/ContactForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,21 @@ import {
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { toast } from "@/components/ui/use-toast";
import { useToast } from "@/components/ui/use-toast";

const FormSchema = z.object({
Email: z.string().email({ message: "Invalid email address." }).min(2, {
message: "Email must be at least 2 characters.",
}),

Email: z.string().email({ message: "Invalid email address." }),
Name: z.string().min(2, {
message: "Name must be at least 2 characters.",
}),

Message: z.string().min(10, {
message: "Description must be at least 10 characters.",
}),
});

export function ContactFormDemo() {
const { toast } = useToast();

const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
Expand All @@ -48,15 +46,17 @@ export function ContactFormDemo() {
"https://script.google.com/macros/s/AKfycbxUVRtZlOusMMHw-B076NRY0mapwcWGwgKP_naDoVlEYc_NC2TO6mNEKdYtvNNHNPSwcg/exec",
{
method: "POST",
mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
}
);

if (response.ok) {
const result = await response.json();
console.log("HERE:");
console.log(result);
if (result.result === "success") {
toast({
title: "Success!",
description: "Your message has been sent.",
Expand All @@ -65,20 +65,21 @@ export function ContactFormDemo() {
} else {
toast({
title: "Error!",
description: "There was a problem submitting your form.",
variant: "destructive",
description: `There was a problem submitting your form: ${result.error}`,
});
}
} catch (error) {
toast({
title: "Error!",
description: "There was a problem submitting your form.",
variant: "destructive",
description: `There was a problem submitting your form: ${error.message}`,

Check failure on line 76 in src/components/ContactForm.tsx

View workflow job for this annotation

GitHub Actions / deploy

'error' is of type 'unknown'.
});
}
}

return (
<Form {...form}>
{/* Connected to google sheet. */}
<form onSubmit={form.handleSubmit(onSubmit)} className="w-full space-y-8">
<FormField
control={form.control}
Expand Down Expand Up @@ -106,7 +107,6 @@ export function ContactFormDemo() {
</FormItem>
)}
/>

<FormField
control={form.control}
name="Message"
Expand Down

0 comments on commit 71e6b89

Please sign in to comment.