mirror of
https://github.com/sakaljurgis/best-choice.git
synced 2026-07-08 21:47:40 +00:00
images
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user