Files
klz-cables.com/.pnpm-store/v10/files/4a/02c0bdfd4af55812d54a58342b80a7ff24fd9ab720e42970c57736df0d2414412e3dfccd923ae4c7aa102d2d4fd708e72d74ac4c5a72897829ec1bbf7e2b17
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

57 lines
2.0 KiB
Plaintext

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { toWords } from 'payload/shared';
import React, { useMemo } from 'react';
import { useAuth } from '../../../../providers/Auth/index.js';
import { useConfig } from '../../../../providers/Config/index.js';
import { useTranslation } from '../../../../providers/Translation/index.js';
import { reduceFieldsToOptions } from '../../../../utilities/reduceFieldsToOptions.js';
export const QueryPresetsGroupByCell = ({
cellData,
rowData
}) => {
const {
i18n
} = useTranslation();
const {
permissions
} = useAuth();
const {
config
} = useConfig();
// Get the related collection from the row data
const relatedCollection = rowData?.relatedCollection;
// Get the collection config for the related collection
const collectionConfig = useMemo(() => {
if (!relatedCollection) {
return null;
}
return config.collections?.find(col => col.slug === relatedCollection);
}, [relatedCollection, config.collections]);
// Reduce fields to options to get proper labels
const reducedFields = useMemo(() => {
if (!collectionConfig) {
return [];
}
const fieldPermissions = permissions?.collections?.[relatedCollection]?.fields;
return reduceFieldsToOptions({
fieldPermissions,
fields: collectionConfig.fields,
i18n
});
}, [collectionConfig, permissions, relatedCollection, i18n]);
if (!cellData || typeof cellData !== 'string') {
return /*#__PURE__*/_jsx("div", {
children: "No group by selected"
});
}
const isDescending = cellData.startsWith('-');
const fieldName = isDescending ? cellData.slice(1) : cellData;
const direction = isDescending ? 'descending' : 'ascending';
// Find the field option to get the proper label
const fieldOption = reducedFields.find(field => field.value === fieldName);
const displayLabel = fieldOption?.label || toWords(fieldName);
return /*#__PURE__*/_jsxs("div", {
children: [displayLabel, " (", direction, ")"]
});
};
//# sourceMappingURL=index.js.map