From 15562f8ca886e0669fe7cbc9d80a5b867238e2f7 Mon Sep 17 00:00:00 2001
From: Prudent Bird
Date: Mon, 29 Jul 2024 12:14:58 +0100
Subject: [PATCH 1/2] chore: social auth for registration - team kimiko
---
src/app/(auth-routes)/register/page.tsx | 133 +++++++++++++++++++-----
src/utils/getApiUrl.ts | 11 ++
2 files changed, 116 insertions(+), 28 deletions(-)
create mode 100644 src/utils/getApiUrl.ts
diff --git a/src/app/(auth-routes)/register/page.tsx b/src/app/(auth-routes)/register/page.tsx
index e5845f651..333dc2db2 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,7 @@ import {
InputOTPGroup,
InputOTPSlot,
} from "~/components/ui/input-otp";
+import { getApiUrl } from "~/utils/getApiUrl";
const formSchema = z.object({
fullname: z.string().min(2, {
@@ -40,6 +40,21 @@ const formSchema = z.object({
type FormData = z.infer;
const SignUp = () => {
+ const [apiUrl, setApiUrl] = useState("");
+
+ useEffect(() => {
+ const fetchApiUrl = async () => {
+ try {
+ const url = await getApiUrl();
+ setApiUrl(url);
+ } catch (error) {
+ console.error("Failed to fetch API URL:", error);
+ }
+ };
+
+ fetchApiUrl();
+ }, []);
+
const form = useForm({
resolver: zodResolver(formSchema),
});
@@ -53,7 +68,9 @@ const SignUp = () => {
})();
};
- const handleSubmit = () => {
+ const handleSubmit = async () => {
+ console.log(apiUrl);
+
form.handleSubmit(handleFormSubmit)();
};
@@ -66,26 +83,77 @@ const SignUp = () => {
-
-
+
+
+
+
+
+
+ }
+ >
+ Sign up with Google
+
+
+
+
+
+
+
+
+
+
+
+ }
+ >
+ Sign up with Facebook
+