UNPKG

payloadcms-import-export-plugin

Version:

A comprehensive Payload CMS plugin that enables seamless import and export of collection data with support for CSV and JSON formats, featuring advanced field mapping, duplicate handling, and batch processing capabilities.

54 lines (53 loc) 2.22 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import React from 'react'; import { useFormFields } from '@payloadcms/ui'; import { detectFileFormat } from '../../import/parsers.js'; const baseClass = 'file-format-info'; export const FileFormatInfo = ()=>{ const file = useFormFields(([fields])=>fields?.file?.value); const filename = file?.filename || ''; if (!filename) { return null; } const format = detectFileFormat(filename); return /*#__PURE__*/ _jsxs("div", { className: baseClass, children: [ /*#__PURE__*/ _jsxs("div", { className: `${baseClass}__format`, children: [ /*#__PURE__*/ _jsx("strong", { children: "Detected format:" }), ' ', format === 'unknown' ? /*#__PURE__*/ _jsx("span", { style: { color: 'red' }, children: "Unsupported format. Please upload a .csv or .json file." }) : /*#__PURE__*/ _jsx("span", { style: { color: 'green' }, children: format.toUpperCase() }) ] }), format !== 'unknown' && /*#__PURE__*/ _jsx("div", { className: `${baseClass}__info`, children: /*#__PURE__*/ _jsxs("small", { children: [ format === 'csv' && /*#__PURE__*/ _jsx(_Fragment, { children: "Expected CSV format: First row should contain column headers that match your collection field names." }), format === 'json' && /*#__PURE__*/ _jsx(_Fragment, { children: "Expected JSON format: Array of objects or single object. Object keys should match your collection field names." }) ] }) }) ] }); }; //# sourceMappingURL=index.js.map