Skip to content

Commit

Permalink
refactor!
Browse files Browse the repository at this point in the history
  • Loading branch information
xgovernor committed Mar 6, 2024
1 parent 4ec7858 commit 5d848c7
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 8 deletions.
32 changes: 28 additions & 4 deletions src/app/auth/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import LOGO from "@/assets/images/simbio-color.svg";
import { Button } from "@/components/ui/button";

const PageAuthLogin: FC = () => {
const handleLogin = async (
medium: "google" | "apple" | "microsoft" | "github",
) => {
try {
const response = await fetch(`/auth/login/${medium}`);
console.log("Response:", response);
window.location.href = response.url; // Redirect to Google login
} catch (error) {
console.error("Error logging in with Google:", error);
}
};

return (
<section className="relative block h-screen w-full">
{/* Background image */}
Expand Down Expand Up @@ -39,16 +51,28 @@ const PageAuthLogin: FC = () => {

<div className="flex flex-col gap-7 ">
<div className="flex flex-col gap-4">
<Button className="w-full bg-[#EA4335] text-white">
<Button
onClick={() => handleLogin("google")}
className="w-full bg-[#EA4335] text-white"
>
Login with Google
</Button>
<Button className="w-full bg-black text-white">
<Button
onClick={() => handleLogin("apple")}
className="w-full bg-black text-white"
>
Login with Apple
</Button>
<Button className="w-full bg-blue-500 text-white">
<Button
onClick={() => handleLogin("microsoft")}
className="w-full bg-blue-500 text-white"
>
Login with Microsoft
</Button>
<Button className="w-full bg-gray-900 text-white">
<Button
onClick={() => handleLogin("github")}
className="w-full bg-gray-900 text-white"
>
Login with GitHub
</Button>
</div>
Expand Down
32 changes: 28 additions & 4 deletions src/app/auth/register/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ import LOGO from "@/assets/images/simbio-color.svg";
import { Button } from "@/components/ui/button";

const PageAuthRegistered: FC = () => {
const handleRegister = async (
medium: "google" | "apple" | "microsoft" | "github",
) => {
try {
const response = await fetch(`/auth/login/${medium}`);
console.log("Response:", response);
window.location.href = response.url; // Redirect to Google login
} catch (error) {
console.error("Error logging in with Google:", error);
}
};

return (
<section className="relative block h-screen w-full">
{/* Background image */}
Expand Down Expand Up @@ -39,16 +51,28 @@ const PageAuthRegistered: FC = () => {

<div className="flex flex-col gap-7 ">
<div className="flex flex-col gap-3">
<Button className="w-full bg-red-600 text-white">
<Button
onClick={() => handleRegister("google")}
className="w-full bg-red-600 text-white"
>
Register with Google
</Button>
<Button className="w-full bg-black text-white">
<Button
onClick={() => handleRegister("apple")}
className="w-full bg-black text-white"
>
Register with Apple
</Button>
<Button className="w-full bg-blue-700 text-white">
<Button
onClick={() => handleRegister("microsoft")}
className="w-full bg-blue-700 text-white"
>
Register with Microsoft
</Button>
<Button className="w-full bg-gray-900 text-white">
<Button
onClick={() => handleRegister("github")}
className="w-full bg-gray-900 text-white"
>
Login with GitHub
</Button>
</div>
Expand Down

0 comments on commit 5d848c7

Please sign in to comment.