-
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.
- Loading branch information
Showing
15 changed files
with
329 additions
and
21 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
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,49 @@ | ||
'use client'; | ||
|
||
import { Label } from '@/components/ui/label'; | ||
import { ScrollArea } from '@/components/ui/scroll-area'; | ||
import { Project } from '@/db/types'; | ||
import { cn } from '@/lib/utils'; | ||
import { useState } from 'react'; | ||
|
||
type ProjectsProps = { | ||
projects: Project[]; | ||
}; | ||
|
||
export default function Projects({ projects }: ProjectsProps) { | ||
const [task, setTask] = useState({ selected: '' }); | ||
return ( | ||
<ScrollArea className="h-screen"> | ||
<Label>Projects</Label> | ||
|
||
<div className="flex flex-col gap-4 p-4"> | ||
{projects.map((item) => ( | ||
<button | ||
key={item.id} | ||
className={cn( | ||
'flex flex-col items-start gap-3 rounded-lg border p-3 text-left text-sm transition-all hover:bg-accent max-w-96 shadow-sm', | ||
task.selected === item.id && 'bg-muted', | ||
)} | ||
onClick={() => | ||
setTask({ | ||
...task, | ||
selected: item.id, | ||
}) | ||
} | ||
> | ||
<div className="flex w-full flex-col gap-1"> | ||
<div className="flex items-center"> | ||
<div className="flex items-center gap-2"> | ||
<div className="font-semibold">{item.name}</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="line-clamp-2 text-xs text-muted-foreground"> | ||
{item.description?.substring(0, 300)} | ||
</div> | ||
</button> | ||
))} | ||
</div> | ||
</ScrollArea> | ||
); | ||
} |
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,7 @@ | ||
export default function Projects() { | ||
return <div>Projects</div>; | ||
import { getAllProjects } from '@/db/queries'; | ||
import Projects from './_components/projects'; | ||
|
||
export default async function ProjectsPage() { | ||
const projects = await getAllProjects('fox', 50, 0); | ||
return <Projects projects={projects} />; | ||
} |
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,49 @@ | ||
'use client'; | ||
|
||
import { Label } from '@/components/ui/label'; | ||
import { ScrollArea } from '@/components/ui/scroll-area'; | ||
import { Task } from '@/db/types'; | ||
import { cn } from '@/lib/utils'; | ||
import { useState } from 'react'; | ||
|
||
type TasksProps = { | ||
tasks: Task[]; | ||
}; | ||
|
||
export default function Tasks({ tasks }: TasksProps) { | ||
const [task, setTask] = useState({ selected: '' }); | ||
return ( | ||
<ScrollArea className="h-screen"> | ||
<Label>Tasks</Label> | ||
|
||
<div className="flex flex-col gap-4 p-4"> | ||
{tasks.map((item) => ( | ||
<button | ||
key={item.id} | ||
className={cn( | ||
'flex flex-col items-start gap-3 rounded-lg border p-3 text-left text-sm transition-all hover:bg-accent max-w-96 shadow-sm', | ||
task.selected === item.id && 'bg-muted', | ||
)} | ||
onClick={() => | ||
setTask({ | ||
...task, | ||
selected: item.id, | ||
}) | ||
} | ||
> | ||
<div className="flex w-full flex-col gap-1"> | ||
<div className="flex items-center"> | ||
<div className="flex items-center gap-2"> | ||
<div className="font-semibold">{item.title}</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="line-clamp-2 text-xs text-muted-foreground"> | ||
{item.description?.substring(0, 300)} | ||
</div> | ||
</button> | ||
))} | ||
</div> | ||
</ScrollArea> | ||
); | ||
} |
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,7 @@ | ||
export default function Tasks() { | ||
return <div>Tasks</div>; | ||
import { getAllTasks } from '@/db/queries'; | ||
import Tasks from './_components/tasks'; | ||
|
||
export default async function TasksPage() { | ||
const tasks = await getAllTasks('fox', 50, 0); | ||
return <Tasks tasks={tasks} />; | ||
} |
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,48 @@ | ||
"use client" | ||
|
||
import * as React from "react" | ||
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const ScrollArea = React.forwardRef< | ||
React.ElementRef<typeof ScrollAreaPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> | ||
>(({ className, children, ...props }, ref) => ( | ||
<ScrollAreaPrimitive.Root | ||
ref={ref} | ||
className={cn("relative overflow-hidden", className)} | ||
{...props} | ||
> | ||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]"> | ||
{children} | ||
</ScrollAreaPrimitive.Viewport> | ||
<ScrollBar /> | ||
<ScrollAreaPrimitive.Corner /> | ||
</ScrollAreaPrimitive.Root> | ||
)) | ||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName | ||
|
||
const ScrollBar = React.forwardRef< | ||
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>, | ||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> | ||
>(({ className, orientation = "vertical", ...props }, ref) => ( | ||
<ScrollAreaPrimitive.ScrollAreaScrollbar | ||
ref={ref} | ||
orientation={orientation} | ||
className={cn( | ||
"flex touch-none select-none transition-colors", | ||
orientation === "vertical" && | ||
"h-full w-2.5 border-l border-l-transparent p-[1px]", | ||
orientation === "horizontal" && | ||
"h-2.5 flex-col border-t border-t-transparent p-[1px]", | ||
className | ||
)} | ||
{...props} | ||
> | ||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" /> | ||
</ScrollAreaPrimitive.ScrollAreaScrollbar> | ||
)) | ||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName | ||
|
||
export { ScrollArea, ScrollBar } |
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
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
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,31 @@ | ||
'use server'; | ||
|
||
import { eq } from 'drizzle-orm'; | ||
import { db } from './drizzle'; | ||
import { projects, tasks } from './schema'; | ||
|
||
export const getAllTasks = async ( | ||
userId: string, | ||
limit: number, | ||
offset: number, | ||
) => { | ||
return await db | ||
.select() | ||
.from(tasks) | ||
.limit(limit) | ||
.offset(offset) | ||
.where(eq(tasks.userId, userId)); | ||
}; | ||
|
||
export const getAllProjects = async ( | ||
userId: string, | ||
limit: number, | ||
offset: number, | ||
) => { | ||
return await db | ||
.select() | ||
.from(projects) | ||
.limit(limit) | ||
.offset(offset) | ||
.where(eq(projects.userId, userId)); | ||
}; |
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,4 @@ | ||
import { projects, tasks } from './schema'; | ||
|
||
export type Project = typeof projects.$inferSelect; | ||
export type Task = typeof tasks.$inferSelect; |
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
Oops, something went wrong.