Skip to content
This repository was archived by the owner on May 4, 2024. It is now read-only.

auth 모킹 및 스타일 수정 #14

Merged
merged 3 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"dev:mock": "concurrently --kill-others \"NEXT_PUBLIC_API_MOCKING=enable next dev\" \"pnpx tsx watch ./src/mocks/http.ts\"",
"dev:mock": "NEXT_PUBLIC_API_MOCKING=enable next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
Expand All @@ -26,6 +26,7 @@
"clsx": "^2.1.0",
"next": "14.1.0",
"next-auth": "^4.24.6",
"nextjs-toploader": "^1.6.6",
"pg": "^8.11.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
28 changes: 26 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/app/activities/features/AddButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function AddButton({
<AddIcon />
</Button>
</PopoverTrigger>
<PopoverContent>
<PopoverContent avoidCollisions={false}>
<Form {...form}>
<form
action={async (formData) => {
Expand Down
3 changes: 3 additions & 0 deletions src/app/activities/features/DateController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Button } from "~/components/ui/button";
import { Input } from "~/components/ui/input";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { cn } from "~/lib/utils";
import { isAndroid } from "~/constants/ua";

export default function DateController({ date }: { date: Date }) {
const router = useRouter();
Expand All @@ -30,6 +32,7 @@ export default function DateController({ date }: { date: Date }) {
type="date"
value={time(date)}
onChange={(e) => router.push(`?date=${e.currentTarget.value}`)}
className={cn(isAndroid() && "appearance-none")}
/>
</div>
<Link href={`/?date=${tomorrow}`}>
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Metadata } from "next";
import NextTopLoader from "nextjs-toploader";
import "./globals.css";
import QueryClientProvider from "~/lib/QueryClientProvider";

Expand All @@ -16,6 +17,7 @@ export default function RootLayout({
<html lang="kr">
<body>
<main>
<NextTopLoader showSpinner={false} />
<QueryClientProvider>{children}</QueryClientProvider>
</main>
</body>
Expand Down
3 changes: 0 additions & 3 deletions src/app/loading.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions src/constants/ua.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const isAndroid = () => {
if (typeof window !== "undefined") {
return /android/i.test(window.navigator.userAgent);
}
};
14 changes: 13 additions & 1 deletion src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import PostgresAdapter from "@auth/pg-adapter";
import { Pool } from "pg";
import { Adapter } from "next-auth/adapters";

import { DB, GOOGLE } from "~/constants/env";
import { DB, GOOGLE, IS_API_MOCKING } from "~/constants/env";
import { redirect } from "next/navigation";
import { SIGNIN } from "~/constants/route";

Expand Down Expand Up @@ -63,6 +63,18 @@ export async function auth(
) {
const session = await getServerSession(...args, config);

if (IS_API_MOCKING) {
return {
user: {
name: "Byonghun Lee",
email: "dlqud19@gmail.com",
image:
"https://lh3.googleusercontent.com/a/ACg8ocK2wO1MZUvKiFPQFO_f99Ryekp_w4I1BPqO8Ardj8Fl=s96-c",
id: "3",
},
};
}

if (!session) {
redirect(SIGNIN);
}
Expand Down