Skip to content

Commit da23a5a

Browse files
committed
refactor(dev): Move components & add StatusBadge component
1 parent 7374439 commit da23a5a

17 files changed

+57
-59
lines changed
File renamed without changes.

packages/dev/src/app/components/auth/ExpiresBadge.tsx renamed to packages/dev/src/app/(app)/_components/auth/ExpiresBadge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import Badge from "@/components/general/Badge";
12
import type { ComponentProps } from "react";
2-
import Badge from "../general/Badge";
33

44
export const ExpiresBadge = ({
55
expiresAt: expiresAtString,

packages/dev/src/app/components/auth/SignInOrOutButtons.tsx renamed to packages/dev/src/app/(app)/_components/auth/SignInOrOutButtons.tsx

File renamed without changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Badge from "@/components/general/Badge";
2+
import type { ComponentProps } from "react";
3+
4+
export const StatusBadge = ({
5+
status,
6+
...props
7+
}: {
8+
status: "authenticated" | "unauthenticated" | "loading";
9+
} & Omit<ComponentProps<typeof Badge>, "variant" | "children">) => {
10+
return (
11+
<Badge
12+
variant={status === "authenticated" ? "green" : status === "loading" ? "yellow" : "red"}
13+
{...props}
14+
>
15+
Status: {status}
16+
</Badge>
17+
);
18+
};

packages/dev/src/app/components/auth/authjs/AuthjsSessionClient.tsx renamed to packages/dev/src/app/(app)/_components/auth/authjs/AuthjsSessionClient.tsx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
"use client";
22

33
import { useSession } from "next-auth/react";
4-
import Badge from "../../general/Badge";
4+
import { ExpiresBadge } from "../ExpiresBadge";
5+
import { StatusBadge } from "../StatusBadge";
56

67
export const AuthjsSessionClient = () => {
78
const { status, data: session } = useSession();
89

910
return (
1011
<>
1112
<div className="mb-2 flex gap-1">
12-
<Badge
13-
variant={status === "authenticated" ? "green" : status === "loading" ? "yellow" : "red"}
14-
>
15-
Status: {status}
16-
</Badge>
17-
{session?.expires && (
18-
<Badge variant="yellow">Expires: {new Date(session.expires).toLocaleString()}</Badge>
19-
)}
13+
<StatusBadge status={status} />
14+
<ExpiresBadge title="Session Expires" expiresAt={session?.expires} />
2015
</div>
2116
<pre className="overflow-auto rounded-lg bg-gray-100 p-4">
2217
{JSON.stringify(session?.user ?? null, null, 2)}

packages/dev/src/app/components/auth/authjs/AuthjsSessionServer.tsx renamed to packages/dev/src/app/(app)/_components/auth/authjs/AuthjsSessionServer.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { auth } from "@/auth";
2-
import Badge from "../../general/Badge";
2+
import { ExpiresBadge } from "../ExpiresBadge";
3+
import { StatusBadge } from "../StatusBadge";
34

45
export const AuthjsSessionServer = async () => {
56
const session = await auth();
67

78
return (
89
<>
910
<div className="mb-2 flex gap-1">
10-
<Badge variant={session ? "green" : "red"}>
11-
Status: {session ? "authenticated" : "unauthenticated"}
12-
</Badge>
13-
{session?.expires && (
14-
<Badge variant="yellow">Expires: {new Date(session.expires).toLocaleString()}</Badge>
15-
)}
11+
<StatusBadge status={session ? "authenticated" : "unauthenticated"} />
12+
<ExpiresBadge title="Session Expires" expiresAt={session?.expires} />
1613
</div>
1714
<pre className="overflow-auto rounded-lg bg-gray-100 p-4">
1815
{JSON.stringify(session?.user ?? null, null, 2)}

packages/dev/src/app/components/auth/authjs/SignInButtonAuthjs.tsx renamed to packages/dev/src/app/(app)/_components/auth/authjs/SignInButtonAuthjs.tsx

File renamed without changes.

packages/dev/src/app/components/auth/authjs/SignOutButtonAuthjs.tsx renamed to packages/dev/src/app/(app)/_components/auth/authjs/SignOutButtonAuthjs.tsx

File renamed without changes.

packages/dev/src/app/components/auth/payload/PayloadAuthProvider.tsx renamed to packages/dev/src/app/(app)/_components/auth/payload/PayloadAuthProvider.tsx

File renamed without changes.

packages/dev/src/app/components/auth/payload/PayloadSessionClientWithUsePayloadSession.tsx renamed to packages/dev/src/app/(app)/_components/auth/payload/PayloadSessionClient.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
"use client";
22

3+
import Badge from "@/components/general/Badge";
34
import { usePayloadSession } from "payload-authjs/client";
4-
import Badge from "../../general/Badge";
55
import { ExpiresBadge } from "../ExpiresBadge";
6+
import { StatusBadge } from "../StatusBadge";
67

7-
export const PayloadSessionClientWithUsePayloadSession = () => {
8+
export const PayloadSessionClient = () => {
89
const { status, session, refresh } = usePayloadSession();
910

1011
return (
1112
<>
1213
<div className="mb-2 flex gap-1">
13-
<Badge
14-
variant={status === "authenticated" ? "green" : status === "loading" ? "yellow" : "red"}
15-
>
16-
Status: {status}
17-
</Badge>
14+
<StatusBadge status={status} />
1815
<ExpiresBadge title="Session Expires" expiresAt={session?.expires} onClick={refresh} />
1916
<ExpiresBadge title="Account Expires" expiresAt={session?.user.currentAccount?.expiresAt} />
2017
<ExpiresBadge

0 commit comments

Comments
 (0)