94 lines
2.8 KiB
TypeScript
Raw Normal View History

2024-04-18 14:42:47 -04:00
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
2024-10-21 13:57:45 -06:00
} from "@/components/ui/table"
2024-11-17 12:35:56 -05:00
import { projectTemplates } from "@/lib/data"
2024-10-21 13:57:45 -06:00
import { ChevronRight } from "lucide-react"
import Image from "next/image"
import Link from "next/link"
import Avatar from "../ui/avatar"
import Button from "../ui/customButton"
2024-04-18 14:42:47 -04:00
export default function DashboardSharedWithMe({
2024-05-01 02:49:25 -04:00
shared,
2024-04-18 14:42:47 -04:00
}: {
2024-05-01 02:49:25 -04:00
shared: {
2024-10-21 13:57:45 -06:00
id: string
name: string
type: string
2024-10-21 13:57:45 -06:00
author: string
authorAvatarUrl: string
2024-10-21 13:57:45 -06:00
sharedOn: Date
}[]
2024-04-18 14:42:47 -04:00
}) {
return (
<div className="grow p-4 flex flex-col">
<div className="text-xl font-medium mb-8">Shared With Me</div>
2024-05-07 21:19:32 -07:00
{shared.length > 0 ? (
<div className="grow w-full">
<Table>
<TableHeader>
<TableRow className="hover:bg-background">
<TableHead>Sandbox Name</TableHead>
<TableHead>Shared By</TableHead>
<TableHead>Sent On</TableHead>
<TableHead className="text-right"></TableHead>
2024-04-18 14:42:47 -04:00
</TableRow>
2024-05-07 21:19:32 -07:00
</TableHeader>
<TableBody>
{shared.map((sandbox) => (
<TableRow>
<TableCell>
<div className="font-medium flex items-center">
<Image
alt=""
src={
2024-11-17 12:35:56 -05:00
projectTemplates.find((p) => p.id === sandbox.type)
?.icon ?? "/project-icons/node.svg"
2024-05-07 21:19:32 -07:00
}
width={20}
height={20}
className="mr-2"
/>
{sandbox.name}
</div>
</TableCell>
<TableCell>
<div className="flex items-center">
2024-11-17 12:35:56 -05:00
<Avatar
name={sandbox.author}
avatarUrl={sandbox.authorAvatarUrl}
className="mr-2"
/>
2024-05-07 21:19:32 -07:00
{sandbox.author}
</div>
</TableCell>
<TableCell>
{new Date(sandbox.sharedOn).toLocaleDateString()}
</TableCell>
<TableCell className="text-right">
<Link href={`/code/${sandbox.id}`}>
<Button>
Open <ChevronRight className="w-4 h-4 ml-2" />
</Button>
</Link>
</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
) : (
<div className="text-muted-foreground text-sm">
No sandboxes here. Get a friend to share one with you, and try out
live collaboration!
</div>
)}
2024-04-18 14:42:47 -04:00
</div>
2024-10-21 13:57:45 -06:00
)
2024-04-18 14:42:47 -04:00
}