diff --git a/src/app/(auth-routes)/register/page.tsx b/src/app/(auth-routes)/register/page.tsx index e5845f651..2c4d59ced 100644 --- a/src/app/(auth-routes)/register/page.tsx +++ b/src/app/(auth-routes)/register/page.tsx @@ -2,14 +2,13 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { DialogContent, DialogTitle } from "@radix-ui/react-dialog"; -import Image from "next/image"; import Link from "next/link"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { z } from "zod"; +import CustomButton from "~/components/common/common-button/common-button"; import { DialogDemo } from "~/components/common/Dialog"; -import { Button } from "~/components/ui/button"; import { Form, FormControl, @@ -24,6 +23,8 @@ import { InputOTPGroup, InputOTPSlot, } from "~/components/ui/input-otp"; +import { useToast } from "~/components/ui/use-toast"; +import { getApiUrl } from "~/utils/getApiUrl"; const formSchema = z.object({ fullname: z.string().min(2, { @@ -40,6 +41,26 @@ const formSchema = z.object({ type FormData = z.infer; const SignUp = () => { + const [apiUrl, setApiUrl] = useState(""); + const { toast } = useToast(); + + useEffect(() => { + const fetchApiUrl = async () => { + try { + const url = await getApiUrl(); + setApiUrl(url); + } catch { + toast({ + title: "Error", + description: "Failed to fetch API URL", + variant: "destructive", + }); + } + }; + + fetchApiUrl(); + }, [toast]); + const form = useForm({ resolver: zodResolver(formSchema), }); @@ -53,7 +74,7 @@ const SignUp = () => { })(); }; - const handleSubmit = () => { + const handleSubmit = async () => { form.handleSubmit(handleFormSubmit)(); }; @@ -66,26 +87,77 @@ const SignUp = () => {

- - + + + + + + + } + > + Sign up with Google + + + + + + + + + + + + } + > + Sign up with Facebook +
@@ -157,9 +229,14 @@ const SignUp = () => { )} /> - + { ))} - +

Would you rather use email and password? diff --git a/src/utils/getApiUrl.ts b/src/utils/getApiUrl.ts new file mode 100644 index 000000000..2579b1996 --- /dev/null +++ b/src/utils/getApiUrl.ts @@ -0,0 +1,11 @@ +"use server"; + +export const getApiUrl = async (): Promise => { + const apiUrl = process.env.API_URL; + + if (!apiUrl) { + throw new Error("API_URL environment variable is not defined"); + } + + return apiUrl; +};