Upgraded to Next Auth v5
This commit is contained in:
40
components/auth/card-wrapper.tsx
Normal file
40
components/auth/card-wrapper.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
"use client"
|
||||
|
||||
import { LoginForm } from "@/components/auth/login-form";
|
||||
import React from "react";
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardHeader,
|
||||
CardFooter,
|
||||
CardTitle
|
||||
} from "@/components/ui/card";
|
||||
import { Header } from "@/components/auth/header";
|
||||
import { Social } from "@/components/auth/social";
|
||||
|
||||
|
||||
interface CardWrapperProps {
|
||||
children: React.ReactNode
|
||||
headerLabel: string
|
||||
}
|
||||
|
||||
export const CardWrapper = ({
|
||||
children,
|
||||
headerLabel
|
||||
}: CardWrapperProps) => {
|
||||
return (
|
||||
<Card className="w-[400px] shadow-md bg-white text-black">
|
||||
<CardHeader>
|
||||
<Header label={headerLabel} />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{children}
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<Social />
|
||||
</CardFooter>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default CardWrapper
|
||||
25
components/auth/header.tsx
Normal file
25
components/auth/header.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Poppins } from "next/font/google";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
|
||||
const font = Poppins({
|
||||
subsets: ["latin"],
|
||||
weight: ["600"]
|
||||
})
|
||||
|
||||
interface HeaderProps {
|
||||
label: string
|
||||
}
|
||||
|
||||
export const Header = ({ label }: HeaderProps) => {
|
||||
return (
|
||||
<div className="w-full flex flex-col gap-y-4 items-center justify-center">
|
||||
<h1 className={cn(
|
||||
"text-3xl font-semibold", font.className
|
||||
)}>Login</h1>
|
||||
<p className="text-muted-foreground text-sm">
|
||||
{label}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
11
components/auth/login-form.tsx
Normal file
11
components/auth/login-form.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { CardWrapper } from "./card-wrapper"
|
||||
|
||||
export const LoginForm = () => {
|
||||
return (
|
||||
<CardWrapper
|
||||
headerLabel="Welcome back"
|
||||
>
|
||||
Login Form
|
||||
</CardWrapper>
|
||||
)
|
||||
}
|
||||
27
components/auth/social.tsx
Normal file
27
components/auth/social.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
"use client"
|
||||
|
||||
import { signIn } from "next-auth/react"
|
||||
import { FaTwitch } from "react-icons/fa"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { DEFAULT_REDIRECT } from "@/routes"
|
||||
|
||||
export const Social = () => {
|
||||
const onClick = (provider: "twitch") => {
|
||||
signIn(provider, {
|
||||
callbackUrl: DEFAULT_REDIRECT,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center w-full gap-x-2">
|
||||
<Button
|
||||
size="lg"
|
||||
variant="outline"
|
||||
className="w-full bg-white hover:bg-purple-500"
|
||||
onClick={() => onClick("twitch")}
|
||||
>
|
||||
<FaTwitch className="h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user