Skip to content

Commit

Permalink
refactor: Fix formatting in middleware.ts, route.ts, loading.tsx, and…
Browse files Browse the repository at this point in the history
… use-system-theme.ts
  • Loading branch information
iceship committed Sep 19, 2024
1 parent 6315119 commit 2bc3cba
Show file tree
Hide file tree
Showing 15 changed files with 325 additions and 325 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
{
"name": "Node.js & TypeScript",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm",
"image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm"

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [3000],
//"forwardPorts": [3000]

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install"
//"postCreateCommand": "npm install"

// Configure tool-specific properties.
// "customizations": {},
Expand Down
8 changes: 4 additions & 4 deletions public/dark-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions public/light-bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import NextAuth from "next-auth";

import options from "@/config/auth";

const handler = NextAuth(options);

export { handler as GET, handler as POST };
import NextAuth from "next-auth";

import options from "@/config/auth";

const handler = NextAuth(options);

export { handler as GET, handler as POST };
26 changes: 13 additions & 13 deletions src/app/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { CircularProgress } from "@nextui-org/react";

export default function Loading() {
return (
<CircularProgress
className="mx-auto mt-4"
classNames={{
svg: "w-36 h-36",
}}
aria-label="Loading page"
/>
);
}
import { CircularProgress } from "@nextui-org/react";

export default function Loading() {
return (
<CircularProgress
className="mx-auto mt-4"
classNames={{
svg: "w-36 h-36",
}}
aria-label="Loading page"
/>
);
}
30 changes: 15 additions & 15 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Card, CardBody } from "@nextui-org/react";
import { IconFileUnknown } from "@tabler/icons-react";

export default function NotFound() {
return (
<Card className="mx-auto mt-4 max-w-md">
<CardBody>
<p className="flex items-center justify-center gap-2 text-2xl">
<IconFileUnknown />
404 | Page Not Found
</p>
</CardBody>
</Card>
);
}
import { Card, CardBody } from "@nextui-org/react";
import { IconFileUnknown } from "@tabler/icons-react";

export default function NotFound() {
return (
<Card className="mx-auto mt-4 max-w-md">
<CardBody>
<p className="flex items-center justify-center gap-2 text-2xl">
<IconFileUnknown />
404 | Page Not Found
</p>
</CardBody>
</Card>
);
}
46 changes: 23 additions & 23 deletions src/app/profile/page.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Card, CardBody, User } from "@nextui-org/react";
import { getServerSession } from "next-auth";

import options from "@/config/auth";

export default async function Profile() {
const session = await getServerSession(options);

return (
<Card className="mx-auto mt-4 max-w-md">
<CardBody>
<User
name={session?.user?.name}
description={session?.user?.email}
avatarProps={{
showFallback: !session?.user?.image,
src: session?.user?.image || "",
}}
/>
</CardBody>
</Card>
);
}
import { Card, CardBody, User } from "@nextui-org/react";
import { getServerSession } from "next-auth";

import options from "@/config/auth";

export default async function Profile() {
const session = await getServerSession(options);

return (
<Card className="mx-auto mt-4 max-w-md">
<CardBody>
<User
name={session?.user?.name}
description={session?.user?.email}
avatarProps={{
showFallback: !session?.user?.image,
src: session?.user?.image || "",
}}
/>
</CardBody>
</Card>
);
}
126 changes: 63 additions & 63 deletions src/components/app-navbar/auth-button.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
"use client";

import {
Avatar,
Button,
CircularProgress,
Dropdown,
DropdownItem,
DropdownMenu,
DropdownTrigger,
} from "@nextui-org/react";
import { IconBrandGoogle } from "@tabler/icons-react";
import { signIn, signOut, useSession } from "next-auth/react";

export default function AuthButton({ minimal = true }: { minimal?: boolean }) {
const { data, status } = useSession();
if (status === "loading") {
return <CircularProgress />;
}
if (status === "authenticated") {
const signOutClick = () => signOut({ callbackUrl: "/" });
if (minimal) {
return (
<Button onClick={signOutClick} color="success" variant="ghost">
<IconBrandGoogle />
Sign Out
</Button>
);
}
return (
<Dropdown placement="bottom-end">
<DropdownTrigger>
<Avatar
isBordered
as="button"
className="transition-transform"
showFallback={!data.user?.image}
src={data.user?.image || ""}
/>
</DropdownTrigger>
<DropdownMenu aria-label="Profile Actions" variant="flat">
<DropdownItem key="profile" className="h-14 gap-2">
<p className="font-semibold">Signed in as</p>
<p className="font-semibold">{data.user?.email}</p>
</DropdownItem>
<DropdownItem key="logout" color="danger" onClick={signOutClick}>
Sign Out
</DropdownItem>
</DropdownMenu>
</Dropdown>
);
}
return (
<Button
onClick={() => signIn("google", { callbackUrl: "/profile" })}
color="danger"
variant="ghost"
>
<IconBrandGoogle />
Sign In
</Button>
);
}
"use client";

import {
Avatar,
Button,
CircularProgress,
Dropdown,
DropdownItem,
DropdownMenu,
DropdownTrigger,
} from "@nextui-org/react";
import { IconBrandGoogle } from "@tabler/icons-react";
import { signIn, signOut, useSession } from "next-auth/react";

export default function AuthButton({ minimal = true }: { minimal?: boolean }) {
const { data, status } = useSession();
if (status === "loading") {
return <CircularProgress />;
}
if (status === "authenticated") {
const signOutClick = () => signOut({ callbackUrl: "/" });
if (minimal) {
return (
<Button onClick={signOutClick} color="success" variant="ghost">
<IconBrandGoogle />
Sign Out
</Button>
);
}
return (
<Dropdown placement="bottom-end">
<DropdownTrigger>
<Avatar
isBordered
as="button"
className="transition-transform"
showFallback={!data.user?.image}
src={data.user?.image || ""}
/>
</DropdownTrigger>
<DropdownMenu aria-label="Profile Actions" variant="flat">
<DropdownItem key="profile" className="h-14 gap-2">
<p className="font-semibold">Signed in as</p>
<p className="font-semibold">{data.user?.email}</p>
</DropdownItem>
<DropdownItem key="logout" color="danger" onClick={signOutClick}>
Sign Out
</DropdownItem>
</DropdownMenu>
</Dropdown>
);
}
return (
<Button
onClick={() => signIn("google", { callbackUrl: "/profile" })}
color="danger"
variant="ghost"
>
<IconBrandGoogle />
Sign In
</Button>
);
}
Loading

0 comments on commit 2bc3cba

Please sign in to comment.