Files
klz-cables.com/.pnpm-store/v10/files/de/07396b66642c242b1bc5b2c36770ff581192fa4cc5302ce4017e110cf812a0eb39cf371ac8afea5d7ae848b087231e99154fdae85190305bc9d7d5201f8fdb
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

95 lines
2.9 KiB
Plaintext

'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { formatAdminURL } from 'payload/shared';
import React, { useEffect } from 'react';
// eslint-disable-next-line payload/no-imports-from-exports-dir
import { MoveDocToFolderButton, useConfig, useTranslation } from '../../../exports/client/index.js';
export const FolderTableCellClient = ({
collectionSlug,
data,
docTitle,
folderCollectionSlug,
folderFieldName,
viewType
}) => {
const docID = data.id;
const intialFolderID = data?.[folderFieldName];
const {
config
} = useConfig();
const {
t
} = useTranslation();
const [fromFolderName, setFromFolderName] = React.useState(() => intialFolderID ? `${t('general:loading')}...` : t('folder:noFolder'));
const [fromFolderID, setFromFolderID] = React.useState(intialFolderID);
const hasLoadedFolderName = React.useRef(false);
const onConfirm = React.useCallback(async ({
id,
name
}) => {
try {
await fetch(formatAdminURL({
apiRoute: config.routes.api,
path: `/${collectionSlug}/${docID}`
}), {
body: JSON.stringify({
[folderFieldName]: id
}),
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
method: 'PATCH'
});
setFromFolderID(id);
setFromFolderName(name || t('folder:noFolder'));
} catch (error) {
// eslint-disable-next-line no-console
console.error('Error moving document to folder', error);
}
}, [config.routes.api, collectionSlug, docID, folderFieldName, t]);
useEffect(() => {
const loadFolderName = async () => {
try {
const req = await fetch(formatAdminURL({
apiRoute: config.routes.api,
path: `/${folderCollectionSlug}${intialFolderID ? `/${intialFolderID}` : ''}`
}), {
credentials: 'include',
headers: {
'Content-Type': 'application/json'
},
method: 'GET'
});
const res = await req.json();
setFromFolderName(res?.name || t('folder:noFolder'));
} catch (error_0) {
// eslint-disable-next-line no-console
console.error('Error moving document to folder', error_0);
}
};
if (!hasLoadedFolderName.current) {
void loadFolderName();
hasLoadedFolderName.current = true;
}
}, [config.routes.api, folderCollectionSlug, intialFolderID, t]);
return /*#__PURE__*/_jsx(MoveDocToFolderButton, {
buttonProps: {
disabled: viewType === 'trash',
size: 'small'
},
collectionSlug: collectionSlug,
docData: data,
docID: docID,
docTitle: docTitle,
folderCollectionSlug: folderCollectionSlug,
folderFieldName: folderFieldName,
fromFolderID: fromFolderID,
fromFolderName: fromFolderName,
modalSlug: `move-doc-to-folder-cell--${docID}`,
onConfirm: onConfirm,
skipConfirmModal: false
});
};
//# sourceMappingURL=index.client.js.map