diff --git a/frontend/public/clone.svg b/frontend/public/clone.svg new file mode 100644 index 0000000..cfad09a --- /dev/null +++ b/frontend/public/clone.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/components/format/FormatCard.jsx b/frontend/src/components/format/FormatCard.jsx index f18856c..be04495 100644 --- a/frontend/src/components/format/FormatCard.jsx +++ b/frontend/src/components/format/FormatCard.jsx @@ -1,12 +1,25 @@ import PropTypes from 'prop-types'; -function FormatCard({ format, onEdit, showDate, formatDate }) { +function FormatCard({ format, onEdit, onClone, showDate, formatDate }) { return (
onEdit(format)} > -

{format.name}

+
+

+ {format.name} +

+ +

{format.description}

{showDate && (

@@ -52,8 +65,9 @@ FormatCard.propTypes = { tags: PropTypes.arrayOf(PropTypes.string), }).isRequired, onEdit: PropTypes.func.isRequired, + onClone: PropTypes.func.isRequired, // New prop for cloning showDate: PropTypes.bool.isRequired, formatDate: PropTypes.func.isRequired, }; -export default FormatCard; \ No newline at end of file +export default FormatCard; diff --git a/frontend/src/components/format/FormatManager.jsx b/frontend/src/components/format/FormatManager.jsx index 7a87dc4..b58d5b5 100644 --- a/frontend/src/components/format/FormatManager.jsx +++ b/frontend/src/components/format/FormatManager.jsx @@ -45,6 +45,11 @@ function FormatManager() { handleCloseModal(); }; + const handleCloneFormat = (format) => { + const clonedFormat = { ...format, id: 0, name: `${format.name} [COPY]` }; + handleOpenModal(clonedFormat); + }; + const formatDate = (dateString) => { return new Date(dateString).toLocaleString(); }; @@ -87,6 +92,7 @@ function FormatManager() { key={format.id} format={format} onEdit={() => handleOpenModal(format)} + onClone={handleCloneFormat} // Pass the clone handler showDate={sortBy !== 'title'} formatDate={formatDate} /> @@ -104,4 +110,4 @@ function FormatManager() { ); } -export default FormatManager; \ No newline at end of file +export default FormatManager;