This commit is contained in:
Jurgis Sakalauskas
2025-10-16 09:56:11 +03:00
parent 9cdcd23fd9
commit 91ded3de2d
+12 -1
View File
@@ -181,12 +181,22 @@ export const importItemFromUrl = async (req: Request, res: Response) => {
lastPathSegment?.replace(/[-_]/g, ' ').replace(/\s+/g, ' ').trim() ?? 'Item'; lastPathSegment?.replace(/[-_]/g, ' ').replace(/\s+/g, ' ').trim() ?? 'Item';
const model = cleanedSegment.length ? cleanedSegment : 'Imported Item'; const model = cleanedSegment.length ? cleanedSegment : 'Imported Item';
const imageSeedBase = cleanedSegment.length
? cleanedSegment.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '')
: manufacturer.toLowerCase();
const normalizedSeed = imageSeedBase.length ? imageSeedBase : 'imported-item';
const imageSeeds = Array.from({ length: 3 }, (_, index) => `${normalizedSeed}-${index + 1}`);
const images = imageSeeds.map((seed) => ({
url: `https://picsum.photos/seed/${encodeURIComponent(seed)}/800/600`
}));
const attributes: Record<string, unknown> = { const attributes: Record<string, unknown> = {
originUrl: url, originUrl: url,
importedAt: new Date().toISOString(), importedAt: new Date().toISOString(),
condition: 'New', condition: 'New',
availability: 'In stock', availability: 'In stock',
dpi: 1200, dpi: 1200,
imageCount: images.length
}; };
if (hostname) { if (hostname) {
@@ -198,7 +208,8 @@ export const importItemFromUrl = async (req: Request, res: Response) => {
manufacturer, manufacturer,
model, model,
note: null, note: null,
attributes attributes,
images
} }
}); });
}; };