Add auth
This commit is contained in:
53
src/app/(admin)/artworks/[id]/page.tsx
Normal file
53
src/app/(admin)/artworks/[id]/page.tsx
Normal file
@ -0,0 +1,53 @@
|
||||
import ArtworkColors from "@/components/artworks/single/ArtworkColors";
|
||||
import ArtworkVariants from "@/components/artworks/single/ArtworkVariants";
|
||||
import DeleteArtworkButton from "@/components/artworks/single/DeleteArtworkButton";
|
||||
import EditArtworkForm from "@/components/artworks/single/EditArtworkForm";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export default async function ArtworkSinglePage({ params }: { params: { id: string } }) {
|
||||
const { id } = await params;
|
||||
|
||||
const item = await prisma.artwork.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
// album: true,
|
||||
// type: true,
|
||||
file: true,
|
||||
gallery: true,
|
||||
metadata: true,
|
||||
albums: true,
|
||||
categories: true,
|
||||
colors: { include: { color: true } },
|
||||
// sortContexts: true,
|
||||
tags: true,
|
||||
variants: true
|
||||
}
|
||||
})
|
||||
|
||||
const categories = await prisma.artCategory.findMany({ include: { tags: true }, orderBy: { sortIndex: "asc" } });
|
||||
const tags = await prisma.artTag.findMany({ orderBy: { sortIndex: "asc" } });
|
||||
|
||||
if (!item) return <div>Artwork with this id not found</div>
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold mb-4">Edit artwork</h1>
|
||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
|
||||
<div>
|
||||
{item ? <EditArtworkForm artwork={item} tags={tags} categories={categories} /> : 'Artwork not found...'}
|
||||
<div className="mt-6">
|
||||
{item && <DeleteArtworkButton artworkId={item.id} />}
|
||||
</div>
|
||||
<div>
|
||||
{item && <ArtworkVariants variants={item.variants} />}
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
{item && <ArtworkColors colors={item.colors} artworkId={item.id} />}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
92
src/app/(admin)/artworks/page.tsx
Normal file
92
src/app/(admin)/artworks/page.tsx
Normal file
@ -0,0 +1,92 @@
|
||||
import { ArtworkColorProcessor } from "@/components/artworks/ArtworkColorProcessor";
|
||||
import { ArtworksTable } from "@/components/artworks/ArtworksTable";
|
||||
import { getArtworksPage } from "@/lib/queryArtworks";
|
||||
|
||||
export default async function ArtworksPage({
|
||||
searchParams
|
||||
}: {
|
||||
searchParams?: {
|
||||
// type?: string;
|
||||
published?: string;
|
||||
// groupBy?: string;
|
||||
// year?: string;
|
||||
// album?: string;
|
||||
cursor?: string;
|
||||
}
|
||||
}) {
|
||||
const {
|
||||
// type = "all",
|
||||
published = "all",
|
||||
// groupBy = "year",
|
||||
// year,
|
||||
// album,
|
||||
cursor = undefined
|
||||
} = await searchParams ?? {};
|
||||
// const groupMode = groupBy === "album" ? "album" : "year";
|
||||
// const groupId = groupMode === "album" ? album ?? "all" : year ?? "all";
|
||||
|
||||
// Filter by type
|
||||
// if (type !== "all") {
|
||||
// where.typeId = type === "none" ? null : type;
|
||||
// }
|
||||
|
||||
// Filter by published status
|
||||
// if (published === "published") {
|
||||
// where.published = true;
|
||||
// } else if (published === "unpublished") {
|
||||
// where.published = false;
|
||||
// } else if (published === "needsWork") {
|
||||
// where.needsWork = true;
|
||||
// }
|
||||
|
||||
// Filter by group (year or album)
|
||||
// if (groupMode === "year" && groupId !== "all") {
|
||||
// where.year = parseInt(groupId);
|
||||
// } else if (groupMode === "album" && groupId !== "all") {
|
||||
// where.albumId = groupId;
|
||||
// }
|
||||
|
||||
const { items, nextCursor } = await getArtworksPage(
|
||||
{
|
||||
published,
|
||||
cursor,
|
||||
take: 48
|
||||
}
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-bold">Artworks</h1>
|
||||
{/* <ProcessArtworkColorsButton /> */}
|
||||
<ArtworkColorProcessor />
|
||||
<ArtworksTable />
|
||||
</div>
|
||||
// <div>
|
||||
// <div className="flex justify-between pb-4 items-end">
|
||||
// <h1 className="text-2xl font-bold mb-4">Artworks</h1>
|
||||
// <Link href="/uploads/single" className="flex gap-2 items-center cursor-pointer bg-primary hover:bg-primary/90 text-primary-foreground px-4 py-2 rounded">
|
||||
// <PlusCircleIcon className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all text-primary-foreground" /> Upload new artwork
|
||||
// </Link>
|
||||
// <Link href="/uploads/bulk" className="flex gap-2 items-center cursor-pointer bg-primary hover:bg-primary/90 text-primary-foreground px-4 py-2 rounded">
|
||||
// <PlusCircleIcon className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all text-primary-foreground" /> Upload many artwork
|
||||
// </Link>
|
||||
// </div>
|
||||
// <FilterBar
|
||||
// // types={types}
|
||||
// // albums={albums}
|
||||
// // years={years}
|
||||
// // currentType={type}
|
||||
// currentPublished={published}
|
||||
// // groupBy={groupMode}
|
||||
// // groupId={groupId}
|
||||
// />
|
||||
// <div className="mt-6">
|
||||
// {items.length > 0 ? (
|
||||
// <ArtworkGallery initialArtworks={items} initialCursor={nextCursor} />
|
||||
// ) : (
|
||||
// <p className="text-muted-foreground italic">No artworks found.</p>
|
||||
// )}
|
||||
// </div>
|
||||
// </div >
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user