shared with me page logic

This commit is contained in:
Ishaan Dey
2024-05-01 02:49:25 -04:00
parent d3698b9a50
commit 1066638e92
4 changed files with 62 additions and 16 deletions

View File

@ -3,28 +3,34 @@
import CustomButton from "@/components/ui/customButton"
import { Button } from "@/components/ui/button"
import {
Clock,
Code2,
Ellipsis,
FolderDot,
Globe,
HelpCircle,
Plus,
Settings,
Users,
} from "lucide-react"
import { useState } from "react"
import ProjectCard from "./projectCard"
import { Sandbox } from "@/lib/types"
import Image from "next/image"
import ProjectCardDropdown from "./projectCard/dropdown"
import DashboardProjects from "./projects"
import DashboardSharedWithMe from "./shared"
import NewProjectModal from "./newProject"
type TScreen = "projects" | "shared" | "settings" | "search"
export default function Dashboard({ sandboxes }: { sandboxes: Sandbox[] }) {
export default function Dashboard({
sandboxes,
shared,
}: {
sandboxes: Sandbox[]
shared: {
id: string
name: string
type: "react" | "node"
author: string
sharedOn: Date
}[]
}) {
const [screen, setScreen] = useState<TScreen>("projects")
const [newProjectModalOpen, setNewProjectModalOpen] = useState(false)
@ -95,7 +101,7 @@ export default function Dashboard({ sandboxes }: { sandboxes: Sandbox[] }) {
{screen === "projects" ? (
<DashboardProjects sandboxes={sandboxes} />
) : screen === "shared" ? (
<DashboardSharedWithMe sandboxes={sandboxes} />
<DashboardSharedWithMe shared={shared} />
) : screen === "settings" ? null : null}
</div>
</>

View File

@ -14,9 +14,15 @@ import { ChevronRight } from "lucide-react"
import Avatar from "../ui/avatar"
export default function DashboardSharedWithMe({
sandboxes,
shared,
}: {
sandboxes: Sandbox[]
shared: {
id: string
name: string
type: "react" | "node"
author: string
sharedOn: Date
}[]
}) {
return (
<div className="grow p-4 flex flex-col">
@ -32,7 +38,7 @@ export default function DashboardSharedWithMe({
</TableRow>
</TableHeader>
<TableBody>
{sandboxes.map((sandbox) => (
{shared.map((sandbox) => (
<TableRow>
<TableCell>
<div className="font-medium flex items-center">
@ -52,11 +58,11 @@ export default function DashboardSharedWithMe({
</TableCell>
<TableCell>
<div className="flex items-center">
<Avatar name="Ishaan Dey" className="mr-2" />
Ishaan Dey
<Avatar name={sandbox.author} className="mr-2" />
{sandbox.author}
</div>
</TableCell>
<TableCell>{new Date().toLocaleDateString()}</TableCell>
<TableCell>{sandbox.sharedOn.toLocaleDateString()}</TableCell>
<TableCell className="text-right">
<Button>
Open <ChevronRight className="w-4 h-4 ml-2" />