-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/inv-29
- Loading branch information
Showing
35 changed files
with
1,362 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DATABASE_URL= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
{ | ||
"extends": "next/core-web-vitals" | ||
"extends": [ | ||
"next/core-web-vitals", | ||
"plugin:@tanstack/eslint-plugin-query/recommended" | ||
], | ||
"rules": { | ||
"react/no-children-prop": "no" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from "drizzle-kit"; | ||
|
||
import { env } from "~/lib/env"; | ||
|
||
export default defineConfig({ | ||
dialect: "postgresql", | ||
schema: "./src/lib/db/schema", | ||
out: "./src/lib/db/migrations", | ||
dbCredentials: { | ||
url: env.DATABASE_URL, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Link, { type LinkProps } from "next/link"; | ||
import { cn } from "~/lib/utils"; | ||
|
||
export function AMain(props: React.HTMLAttributes<HTMLDivElement>) { | ||
return ( | ||
<main | ||
{...props} | ||
className={cn( | ||
"mx-auto w-full max-w-2xl space-y-20 px-10 pt-20", | ||
props.className, | ||
)} | ||
/> | ||
); | ||
} | ||
|
||
export function ALink({ | ||
className, | ||
...props | ||
}: React.AnchorHTMLAttributes<HTMLAnchorElement> & LinkProps) { | ||
return ( | ||
<Link | ||
{...props} | ||
className={cn( | ||
"inline-block font-bold text-blue-500 transition-all hover:text-blue-700", | ||
className, | ||
)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { GlobalAlert } from "~/components/global-alert"; | ||
import Providers from "~/components/providers"; | ||
import { Toaster } from "~/components/ui/sonner"; | ||
|
||
export default async function AppLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<Providers> | ||
{children} | ||
<Toaster /> | ||
<GlobalAlert /> | ||
</Providers> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { promises as fs } from "fs"; | ||
import path from "path"; | ||
import { ALink, AMain } from "~/app/(playground)/playground/inner-tools"; | ||
|
||
async function getPlaygroundRoutes() { | ||
const playgroundDir = path.join( | ||
process.cwd(), | ||
"src/app/(playground)/playground", | ||
); | ||
const entries = await fs.readdir(playgroundDir, { withFileTypes: true }); | ||
|
||
const routes = await Promise.all( | ||
entries | ||
.filter((entry) => entry.isDirectory()) | ||
.map(async (entry) => { | ||
const fullPath = path.join(playgroundDir, entry.name); | ||
const files = await fs.readdir(fullPath); | ||
if (files.includes("page.tsx")) { | ||
return `/playground/${entry.name}`; | ||
} | ||
return null; | ||
}), | ||
); | ||
|
||
return routes.filter((route) => route !== null); | ||
} | ||
|
||
export default async function Page() { | ||
const routes = await getPlaygroundRoutes(); | ||
|
||
return ( | ||
<AMain> | ||
<h2 className="font-bold">playground</h2> | ||
<ul className="space-y-2"> | ||
{routes.map((route) => ( | ||
<li key={route}> | ||
<ALink href={route}>{route}</ALink> | ||
</li> | ||
))} | ||
</ul> | ||
</AMain> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
dehydrate, | ||
HydrationBoundary, | ||
QueryClient, | ||
} from "@tanstack/react-query"; | ||
import { cache } from "react"; | ||
import { ALink, AMain } from "~/app/(playground)/playground/inner-tools"; | ||
import TestInfo from "~/app/(playground)/playground/test/[testId]/test-info"; | ||
import TestEditDialog from "~/app/(playground)/playground/test/test-edit-dialog"; | ||
import { getTestWithTestJobs } from "~/lib/db/schema/test.query"; | ||
|
||
const getQueryClient = cache(() => new QueryClient()); | ||
|
||
export default async function Page({ params }: { params: { testId: string } }) { | ||
const { testId } = params; | ||
|
||
const queryClient = getQueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey: ["tests", testId], | ||
queryFn: () => getTestWithTestJobs(+testId), | ||
}); | ||
|
||
return ( | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<AMain> | ||
<ALink href="/playground/test">뒤로가기</ALink> | ||
<TestInfo /> | ||
<TestEditDialog /> | ||
</AMain> | ||
</HydrationBoundary> | ||
); | ||
} |
70 changes: 70 additions & 0 deletions
70
src/app/(playground)/playground/test/[testId]/test-info.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
"use client"; | ||
|
||
import { GearIcon } from "@radix-ui/react-icons"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { useParams } from "next/navigation"; | ||
import { useTestEditDialog } from "~/app/(playground)/playground/test/test-edit-dialog"; | ||
import { Button } from "~/components/ui/button"; | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardHeader, | ||
CardTitle, | ||
} from "~/components/ui/card"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "~/components/ui/dropdown-menu"; | ||
import { getTestWithTestJobs } from "~/lib/db/schema/test.query"; | ||
|
||
export default function TestInfo() { | ||
const { testId } = useParams<{ testId: string }>(); | ||
|
||
const { data, isLoading, error } = useQuery({ | ||
queryKey: ["tests", testId], | ||
queryFn: () => getTestWithTestJobs(+testId), | ||
}); | ||
|
||
const onOpenEditDialog = useTestEditDialog((state) => state.openDialog); | ||
|
||
if (!data) { | ||
return <div>{JSON.stringify(error, null, 2)}</div>; | ||
} | ||
|
||
return ( | ||
<div> | ||
<Card className="relative"> | ||
<CardHeader> | ||
<CardTitle>{data.name}</CardTitle> | ||
<CardDescription>{data.email}</CardDescription> | ||
</CardHeader> | ||
<CardContent> | ||
<CardDescription>ID {data.id}</CardDescription> | ||
<CardDescription>숫자 {data.number}</CardDescription> | ||
<CardDescription>테스트 작업 {data.jobs.length}개</CardDescription> | ||
</CardContent> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button | ||
variant="outline" | ||
size="icon" | ||
className="absolute bottom-5 right-4" | ||
> | ||
<GearIcon /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent> | ||
<DropdownMenuItem onClick={() => onOpenEditDialog(data)}> | ||
수정하기 | ||
</DropdownMenuItem> | ||
<DropdownMenuItem>삭제하기</DropdownMenuItem> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
</Card> | ||
<div>{data.jobs?.map((job) => <div key={job?.id}>{job?.id}</div>)}</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { | ||
dehydrate, | ||
HydrationBoundary, | ||
QueryClient, | ||
} from "@tanstack/react-query"; | ||
import { cache } from "react"; | ||
import { ALink, AMain } from "~/app/(playground)/playground/inner-tools"; | ||
import TestEditDialog from "~/app/(playground)/playground/test/test-edit-dialog"; | ||
import TestForm from "~/app/(playground)/playground/test/test-form"; | ||
import TestList from "~/app/(playground)/playground/test/test-list"; | ||
import { getTestWithTestJobCnt } from "~/lib/db/schema/test.query"; | ||
|
||
const getQueryClient = cache(() => new QueryClient()); | ||
|
||
export default async function Page() { | ||
const queryClient = getQueryClient(); | ||
|
||
await queryClient.prefetchQuery({ | ||
queryKey: ["tests"], | ||
queryFn: getTestWithTestJobCnt, | ||
}); | ||
|
||
return ( | ||
<HydrationBoundary state={dehydrate(queryClient)}> | ||
<AMain> | ||
<ALink href="/playground">playground</ALink> | ||
<TestForm /> | ||
<TestList /> | ||
<TestEditDialog /> | ||
</AMain> | ||
</HydrationBoundary> | ||
); | ||
} |
Oops, something went wrong.