From 6d5c6ffaa768c774436f40a9df9c36e1351687b5 Mon Sep 17 00:00:00 2001 From: Dmitriy-Litvinenko Date: Mon, 16 Dec 2024 15:08:39 +0200 Subject: [PATCH] UICIRC-1080: React v19: refactor away from default props for functional components (#1185) Co-authored-by: Artem Blazhko --- CHANGELOG.md | 2 ++ .../ReminderFeesSection/ReminderFeesFields.js | 18 +++++------------- .../GeneralSection/GeneralSection.js | 9 ++------- src/settings/PatronNotices/PatronNoticeForm.js | 11 ++++------- src/settings/StaffSlips/StaffSlipForm.js | 6 +----- .../components/CancelButton/CancelButton.js | 6 +----- .../components/FooterPane/FooterPane.js | 6 +----- 7 files changed, 16 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b80e2c34..83f862655 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## 10.1.0 IN PROGRESS +* React v19: refactor away from default props for functional components. Refs UICIRC-1080. + ## [10.0.1](https://github.com/folio-org/ui-circulation/tree/v10.0.1) (2024-12-04) [Full Changelog](https://github.com/folio-org/ui-circulation/compare/v10.0.0...v10.0.1) diff --git a/src/settings/FinePolicy/components/EditSections/ReminderFeesSection/ReminderFeesFields.js b/src/settings/FinePolicy/components/EditSections/ReminderFeesSection/ReminderFeesFields.js index 7519f4054..40d899823 100644 --- a/src/settings/FinePolicy/components/EditSections/ReminderFeesSection/ReminderFeesFields.js +++ b/src/settings/FinePolicy/components/EditSections/ReminderFeesSection/ReminderFeesFields.js @@ -21,11 +21,11 @@ import { timeUnits, noticeMethods } from '../../../../../constants'; const ReminderFeesFields = props => { const { formatMessage } = useIntl(); const { - canAdd, - canEdit, - canDelete, - noticeTemplates, - blockTemplates, + canAdd = true, + canEdit = true, + canDelete = true, + noticeTemplates = [], + blockTemplates = [], } = props; const sequenceLabel = formatMessage({ id: 'ui-circulation.settings.finePolicy.reminderFees.sequence' }); const intervalLabel = formatMessage({ id: 'ui-circulation.settings.finePolicy.reminderFees.interval' }); @@ -194,12 +194,4 @@ ReminderFeesFields.propTypes = { blockTemplates: PropTypes.arrayOf(PropTypes.object), }; -ReminderFeesFields.defaultProps = { - canAdd: true, - canEdit: true, - canDelete: true, - noticeTemplates: [], - blockTemplates: [], -}; - export default ReminderFeesFields; diff --git a/src/settings/NoticePolicy/components/DetailSections/GeneralSection/GeneralSection.js b/src/settings/NoticePolicy/components/DetailSections/GeneralSection/GeneralSection.js index 75c2125f2..4de092125 100644 --- a/src/settings/NoticePolicy/components/DetailSections/GeneralSection/GeneralSection.js +++ b/src/settings/NoticePolicy/components/DetailSections/GeneralSection/GeneralSection.js @@ -16,8 +16,8 @@ const GeneralSection = (props) => { connect, metadata, policyName, - isPolicyActive, - policyDescription, + isPolicyActive = false, + policyDescription = '', } = props; const active = isPolicyActive @@ -81,9 +81,4 @@ GeneralSection.propTypes = { connect: PropTypes.func.isRequired, }; -GeneralSection.defaultProps = { - policyDescription: '', - isPolicyActive: false, -}; - export default GeneralSection; diff --git a/src/settings/PatronNotices/PatronNoticeForm.js b/src/settings/PatronNotices/PatronNoticeForm.js index 325aaa839..e6cd28ff6 100644 --- a/src/settings/PatronNotices/PatronNoticeForm.js +++ b/src/settings/PatronNotices/PatronNoticeForm.js @@ -39,10 +39,10 @@ import css from './PatronNoticeForm.css'; const PatronNoticeForm = (props) => { const { handleSubmit, - initialValues, + initialValues = {}, initialValues: { id: initialId, - }, + } = {}, location: { search, }, @@ -88,8 +88,8 @@ const PatronNoticeForm = (props) => { initialValues: notice, } = props; - return notice.id - ? notice.name + return notice?.id + ? notice?.name : formatMessage({ id: 'ui-circulation.settings.patronNotices.newLabel' }); }; @@ -190,9 +190,6 @@ PatronNoticeForm.propTypes = { stripes: stripesShape.isRequired, }; -PatronNoticeForm.defaultProps = { - initialValues: {}, -}; export default stripesFinalForm({ navigationCheck: true, validate: validatePatronNoticeTemplate, diff --git a/src/settings/StaffSlips/StaffSlipForm.js b/src/settings/StaffSlips/StaffSlipForm.js index f7d9cff5b..c2944ccae 100644 --- a/src/settings/StaffSlips/StaffSlipForm.js +++ b/src/settings/StaffSlips/StaffSlipForm.js @@ -31,7 +31,7 @@ const StaffSlipForm = (props) => { const { stripes, handleSubmit, - initialValues, + initialValues = {}, pristine, submitting, onCancel, @@ -118,10 +118,6 @@ StaffSlipForm.propTypes = { intl: PropTypes.object.isRequired, }; -StaffSlipForm.defaultProps = { - initialValues: {}, -}; - export default stripesFinalForm({ navigationCheck: true, })(injectIntl(StaffSlipForm)); diff --git a/src/settings/components/CancelButton/CancelButton.js b/src/settings/components/CancelButton/CancelButton.js index a6e0cd441..5b34e37b0 100644 --- a/src/settings/components/CancelButton/CancelButton.js +++ b/src/settings/components/CancelButton/CancelButton.js @@ -9,7 +9,7 @@ import { const CancelButton = ({ onCancel, - labelKey, + labelKey = 'ui-circulation.settings.common.closeEntryDialog', }) => ( @@ -32,8 +32,4 @@ CancelButton.propTypes = { labelKey: PropTypes.string, }; -CancelButton.defaultProps = { - labelKey: 'ui-circulation.settings.common.closeEntryDialog', -}; - export default CancelButton; diff --git a/src/settings/components/FooterPane/FooterPane.js b/src/settings/components/FooterPane/FooterPane.js index 2faa014b3..4f8d03001 100644 --- a/src/settings/components/FooterPane/FooterPane.js +++ b/src/settings/components/FooterPane/FooterPane.js @@ -12,7 +12,7 @@ import css from './FooterPane.css'; const FooterPane = (props) => { const { isSaveButtonDisabled, - isSaveButtonAvailable, + isSaveButtonAvailable = true, onCancel, } = props; @@ -49,8 +49,4 @@ FooterPane.propTypes = { onCancel: PropTypes.func.isRequired, }; -FooterPane.defaultProps = { - isSaveButtonAvailable: true, -}; - export default FooterPane;