feat(create): wizard uploads render as images in display and exports (imageUrl/fileUrl)

This commit is contained in:
adilallo
2026-05-08 21:38:18 -06:00
parent 026a1e6d71
commit 89fd5f3ade
7 changed files with 170 additions and 13 deletions
+26 -2
View File
@@ -7,6 +7,15 @@ import type { PublishedMethodSelections } from "./buildPublishPayload";
import type { CustomMethodCardFieldBlock } from "./customMethodCardFieldBlocks";
import { templateCategoryToGroupKey } from "./templateReviewMapping";
/** Uses filename extension and/or URL path so uploads render as `<img>` vs file link on read-only surfaces. */
export function wizardUploadDisplaysAsImage(
fileName: string | null,
assetUrl: string | null,
): boolean {
if (fileName && /\.(jpe?g|png|gif|webp)$/i.test(fileName)) return true;
if (assetUrl && /\.(jpe?g|png|gif|webp)(\?|#|$)/i.test(assetUrl)) return true;
return false;
}
/**
* Serialize wizard-authored field blocks into Community Rule labeled rows for
* read-only surfaces (completed step, exported views). Matches how those blocks
@@ -32,8 +41,23 @@ export function labeledBlocksFromCustomMethodCardFieldBlocks(
case "upload": {
const name = nonEmptyTrimmed(b.fileName);
const url = nonEmptyTrimmed(b.assetUrl);
const body = name ?? url;
if (body) out.push({ label: b.blockTitle, body });
if (url) {
if (wizardUploadDisplaysAsImage(name, url)) {
out.push({
label: b.blockTitle,
body: "",
imageUrl: url,
});
} else {
out.push({
label: b.blockTitle,
body: name ?? url,
fileUrl: url,
});
}
} else if (name) {
out.push({ label: b.blockTitle, body: name });
}
break;
}
case "proportion":