Allow artworks to have one primary category and extra secondaries.
Keep artwork_category as membership, store a deterministic primary_category_id, and let upload plus studio pick up to five additional same-type categories without changing canonical URLs.
This commit is contained in:
@@ -374,10 +374,17 @@ export default function useUploadMachine({
|
||||
String(titleSourceFile?.name || '').replace(/\.[^.]+$/, '') ||
|
||||
'Untitled upload'
|
||||
|
||||
const draftCategoryId = metadata.subCategoryId || metadata.rootCategoryId || null
|
||||
const draftSecondaryIds = (Array.isArray(metadata.additionalCategoryIds) ? metadata.additionalCategoryIds : [])
|
||||
.map((id) => Number(id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0 && String(id) !== String(draftCategoryId || ''))
|
||||
|
||||
const draftResponse = await window.axios.post('/api/artworks', {
|
||||
title: derivedTitle,
|
||||
description: String(metadata.description || '').trim() || null,
|
||||
category: metadata.subCategoryId || metadata.rootCategoryId || null,
|
||||
category: draftCategoryId,
|
||||
primary_category_id: draftCategoryId ? Number(draftCategoryId) : null,
|
||||
secondary_category_ids: draftSecondaryIds,
|
||||
tags: Array.isArray(metadata.tags) ? metadata.tags.join(', ') : '',
|
||||
license: Boolean(metadata.rightsAccepted),
|
||||
is_mature: Boolean(metadata.isMature),
|
||||
@@ -560,11 +567,16 @@ export default function useUploadMachine({
|
||||
const { mode = 'now', publishAt = null, timezone = null, visibility = 'public', action = 'publish' } = opts
|
||||
|
||||
const resolvedCategoryId = metadata.subCategoryId || metadata.rootCategoryId || null
|
||||
const secondaryCategoryIds = (Array.isArray(metadata.additionalCategoryIds) ? metadata.additionalCategoryIds : [])
|
||||
.map((id) => Number(id))
|
||||
.filter((id) => Number.isFinite(id) && id > 0 && String(id) !== String(resolvedCategoryId || ''))
|
||||
|
||||
const buildPayload = () => ({
|
||||
title: String(metadata.title || '').trim() || undefined,
|
||||
description: String(metadata.description || '').trim() || null,
|
||||
category: resolvedCategoryId ? String(resolvedCategoryId) : null,
|
||||
primary_category_id: resolvedCategoryId ? Number(resolvedCategoryId) : null,
|
||||
secondary_category_ids: secondaryCategoryIds,
|
||||
tags: Array.isArray(metadata.tags) ? metadata.tags : [],
|
||||
is_mature: Boolean(metadata.isMature),
|
||||
group: String(metadata.group || '').trim() || null,
|
||||
|
||||
Reference in New Issue
Block a user