Feature: Split products catalog into Plain and Ready-Made
Replaces generic 'showOnProducts' boolean with separate catalog options: - showAsPlain: for blank/unprinted items (/products/plain) - showAsReadyMade: for pre-finished items (/products/ready-made) Changes: - Updated Product schema to replace showOnProducts with new fields - Updated product creation and edit forms with new checkboxes - Updated product listing pages to use showAsReadyMade filter - Updated ProductDTO type to reflect new catalog flags Products can now be precisely categorized by type with unique pricing for each. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
5bd6f3de39
commit
8fe99d9d35
@@ -48,15 +48,25 @@ export default async function EditProductPage({ params }: { params: { id: string
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="showOnProducts"
|
||||
name="showAsPlain"
|
||||
value="1"
|
||||
defaultChecked={product.showOnProducts}
|
||||
defaultChecked={product.showAsPlain}
|
||||
className="h-4 w-4 accent-clay"
|
||||
/>
|
||||
Products catalog (/products) — same photos, browse and buy as-is
|
||||
Plain catalog (/products/plain) — blank/unprinted items
|
||||
</label>
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
name="showAsReadyMade"
|
||||
value="1"
|
||||
defaultChecked={product.showAsReadyMade}
|
||||
className="h-4 w-4 accent-clay"
|
||||
/>
|
||||
Ready-Made catalog (/products/ready-made) — pre-finished items
|
||||
</label>
|
||||
</div>
|
||||
<p className="mt-1 text-xs text-muted">Check both to list the same product on both pages.</p>
|
||||
<p className="mt-1 text-xs text-muted">Select which catalog(s) this product appears in.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -76,7 +76,8 @@ export async function createProduct(formData: FormData) {
|
||||
const imageBackFile = formData.get('imageBack') as File | null;
|
||||
const photoRecolorable = String(formData.get('photoRecolorable') ?? '') === '1';
|
||||
const showOnPersonalised = String(formData.get('showOnPersonalised') ?? '') === '1';
|
||||
const showOnProducts = String(formData.get('showOnProducts') ?? '') === '1';
|
||||
const showAsPlain = String(formData.get('showAsPlain') ?? '') === '1';
|
||||
const showAsReadyMade = String(formData.get('showAsReadyMade') ?? '') === '1';
|
||||
const collectionIds = formData.getAll('collections').map((v) => String(v));
|
||||
|
||||
if (!name || !category || !priceDollars) {
|
||||
@@ -151,7 +152,8 @@ export async function createProduct(formData: FormData) {
|
||||
imageUrlBack,
|
||||
photoRecolorable,
|
||||
showOnPersonalised,
|
||||
showOnProducts,
|
||||
showAsPlain,
|
||||
showAsReadyMade,
|
||||
collections: { connect: collectionIds.map((id) => ({ id })) },
|
||||
},
|
||||
});
|
||||
@@ -174,7 +176,8 @@ export async function updateProduct(formData: FormData) {
|
||||
const imageBackFile = formData.get('imageBack') as File | null;
|
||||
const photoRecolorable = String(formData.get('photoRecolorable') ?? '') === '1';
|
||||
const showOnPersonalised = String(formData.get('showOnPersonalised') ?? '') === '1';
|
||||
const showOnProducts = String(formData.get('showOnProducts') ?? '') === '1';
|
||||
const showAsPlain = String(formData.get('showAsPlain') ?? '') === '1';
|
||||
const showAsReadyMade = String(formData.get('showAsReadyMade') ?? '') === '1';
|
||||
const collectionIds = formData.getAll('collections').map((v) => String(v));
|
||||
const referenceWidthCmInput = String(formData.get('referenceWidthCm') ?? '').trim();
|
||||
const referenceHeightCmInput = String(formData.get('referenceHeightCm') ?? '').trim();
|
||||
@@ -267,7 +270,8 @@ export async function updateProduct(formData: FormData) {
|
||||
mockup: string;
|
||||
photoRecolorable: boolean;
|
||||
showOnPersonalised: boolean;
|
||||
showOnProducts: boolean;
|
||||
showAsPlain: boolean;
|
||||
showAsReadyMade: boolean;
|
||||
referenceWidthCm: number | null;
|
||||
referenceHeightCm: number | null;
|
||||
weightGrams: number | null;
|
||||
@@ -290,7 +294,8 @@ export async function updateProduct(formData: FormData) {
|
||||
mockup,
|
||||
photoRecolorable,
|
||||
showOnPersonalised,
|
||||
showOnProducts,
|
||||
showAsPlain,
|
||||
showAsReadyMade,
|
||||
referenceWidthCm,
|
||||
referenceHeightCm,
|
||||
weightGrams,
|
||||
|
||||
@@ -30,11 +30,15 @@ export default async function NewProductPage() {
|
||||
Personalised catalog (/made-to-order) — customers design their own
|
||||
</label>
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name="showOnProducts" value="1" className="h-4 w-4 accent-clay" />
|
||||
Products catalog (/products) — same photos, browse and buy as-is
|
||||
<input type="checkbox" name="showAsPlain" value="1" className="h-4 w-4 accent-clay" />
|
||||
Plain catalog (/products/plain) — blank/unprinted items
|
||||
</label>
|
||||
<label className="flex items-center gap-2 text-sm">
|
||||
<input type="checkbox" name="showAsReadyMade" value="1" className="h-4 w-4 accent-clay" />
|
||||
Ready-Made catalog (/products/ready-made) — pre-finished items
|
||||
</label>
|
||||
</div>
|
||||
<p className="mt-1 text-xs text-muted">Check both to list the same product on both pages.</p>
|
||||
<p className="mt-1 text-xs text-muted">Select which catalog(s) this product appears in.</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
@@ -47,7 +47,7 @@ export default async function ReadyMadeProductsPage({ searchParams }: { searchPa
|
||||
}
|
||||
const palette = Array.from(paletteSet);
|
||||
|
||||
const where: Prisma.ProductWhereInput = { showOnProducts: true };
|
||||
const where: Prisma.ProductWhereInput = { showAsReadyMade: true };
|
||||
if (selectedCategories.length) {
|
||||
where.category = { in: selectedCategories };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user