Working sorting kinda?

This commit is contained in:
2025-07-26 19:00:19 +02:00
parent 3c0e191cd9
commit ef281ef70f
21 changed files with 586 additions and 169 deletions

View File

@ -9,15 +9,18 @@ export default async function PortfolioImagesEditPage({ params }: { params: { id
const image = await prisma.portfolioImage.findUnique({
where: { id },
include: {
album: true,
type: true,
metadata: true,
categories: true,
colors: { include: { color: true } },
sortContexts: true,
tags: true,
variants: true
}
})
const albums = await prisma.portfolioAlbum.findMany({ orderBy: { sortIndex: "asc" } });
const categories = await prisma.portfolioCategory.findMany({ orderBy: { sortIndex: "asc" } });
const tags = await prisma.portfolioTag.findMany({ orderBy: { sortIndex: "asc" } });
const types = await prisma.portfolioType.findMany({ orderBy: { sortIndex: "asc" } });
@ -29,7 +32,7 @@ export default async function PortfolioImagesEditPage({ params }: { params: { id
<h1 className="text-2xl font-bold mb-4">Edit image</h1>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-8">
<div>
{image ? <EditImageForm image={image} tags={tags} categories={categories} types={types} /> : 'Image not found...'}
{image ? <EditImageForm image={image} albums={albums} tags={tags} categories={categories} types={types} /> : 'Image not found...'}
<div className="mt-6">
{image && <DeleteImageButton imageId={image.id} />}
</div>

View File

@ -40,6 +40,8 @@ export default async function PortfolioImagesPage({
where.published = true;
} else if (published === "unpublished") {
where.published = false;
} else if (published === "needsWork") {
where.needsWork = true;
}
// Filter by group (year or album)

View File

@ -1,6 +1,5 @@
import { getImageSort } from "@/actions/portfolio/images/getImageSort";
import ImageSortGallery from "@/components/portfolio/images/ImageSortGallery";
import { Prisma } from "@/generated/prisma";
import prisma from "@/lib/prisma";
export default async function PortfolioImagesSortPage({
searchParams
@ -24,50 +23,15 @@ export default async function PortfolioImagesSortPage({
const groupMode = groupBy === "album" ? "album" : "year";
const groupId = groupMode === "album" ? album ?? "all" : year ?? "all";
const where: Prisma.PortfolioImageWhereInput = {};
// 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;
}
// 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 images = await prisma.portfolioImage.findMany(
{
where,
orderBy: [{ sortIndex: 'asc' }],
}
)
const imageGroups = await getImageSort({ type, published, groupMode, groupId });
return (
<div>
<div className="mt-6">
{/* {images && images.length > 0 ? <MosaicGallery
images={images.map((img) => ({
...img,
width: 400,
height: 300,
}))}
/> : <p className="text-muted-foreground italic">No images found.</p>} */}
{images && images.length > 0 ?
<ImageSortGallery images={images} />
:
<p className="text-muted-foreground italic">No images found.</p>
}
</div>
<div className="mt-6">
{Object.values(imageGroups).flat().length > 0 ? (
<ImageSortGallery images={imageGroups} />
) : (
<p className="text-muted-foreground italic">No images found.</p>
)}
</div>
);
}
}