Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@next/third-parties": "^16.1.6",
"@paypal/react-paypal-js": "^9.1.1",
"@sentry/nextjs": "^10.38.0",
"@spree/sdk": "^1.0.0",
"@spree/sdk": "^1.1.0",
"@stripe/react-stripe-js": "^5.6.0",
"@stripe/stripe-js": "^8.7.0",
"@swc/helpers": "^0.5.21",
Expand Down
42 changes: 19 additions & 23 deletions src/components/products/ProductCustomFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ interface ProductCustomFieldsProps {
customFields?: Array<CustomField>;
}

function normalizeType(type: string): string {
return type.split("::").pop() || type;
}

function renderBooleanValue(
value: unknown,
t: ReturnType<typeof useTranslations<"products">>,
Expand All @@ -18,19 +14,22 @@ function renderBooleanValue(

function renderValue(
field: CustomField,
normalizedType: string,
t: ReturnType<typeof useTranslations<"products">>,
): React.ReactNode {
switch (normalizedType) {
case "Boolean":
switch (field.field_type) {
case "boolean":
return renderBooleanValue(field.value, t);
case "Json":
case "json":
return typeof field.value === "string"
? field.value
: JSON.stringify(field.value);
case "RichText":
case "rich_text":
// Value is admin-authored HTML from the Spree CMS backend (trusted source)
return <span dangerouslySetInnerHTML={{ __html: field.value }} />;
return <span dangerouslySetInnerHTML={{ __html: field.value ?? "" }} />;
case "short_text":
case "long_text":
case "number":
return String(field.value);
default:
return String(field.value);
}
Expand All @@ -51,19 +50,16 @@ export function ProductCustomFields({
{t("properties")}
</h2>
<dl className="space-y-3">
{customFields.map((field) => {
const type = normalizeType(field.type);
return (
<div key={field.id} className="flex">
<dt className="w-32 shrink-0 text-gray-500 text-sm">
{field.label}
</dt>
<dd className="text-gray-900 text-sm min-w-0">
{renderValue(field, type, t)}
</dd>
</div>
);
})}
{customFields.map((field) => (
<div key={field.id} className="flex">
<dt className="w-32 shrink-0 text-gray-500 text-sm">
{field.label}
</dt>
<dd className="text-gray-900 text-sm min-w-0">
{renderValue(field, t)}
</dd>
</div>
))}
</dl>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/metadata/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export async function generateProductMetadata({
return { title: "Product Not Found" };
}

const title = product.name;
const title = product.meta_title || product.name;
const description = product.meta_description
? product.meta_description
: product.description
Expand Down
Loading