diff --git a/src/components/blocks/APIDataTable.js b/src/components/blocks/APIDataTable.js index 6ccf2860..98396e09 100644 --- a/src/components/blocks/APIDataTable.js +++ b/src/components/blocks/APIDataTable.js @@ -170,7 +170,7 @@ const APIDataTable = withTheme( let fullRecord = null; if (actions === 'Projects') { - fullRecord = projects.filter( + fullRecord = projects?.filter( project => project.warehouseProjectId === partialRecord.warehouseProjectId, )[0]; diff --git a/src/components/blocks/UnitsDetails.js b/src/components/blocks/UnitsDetails.js index adf07d96..0d4fe3d2 100644 --- a/src/components/blocks/UnitsDetails.js +++ b/src/components/blocks/UnitsDetails.js @@ -102,8 +102,7 @@ const UnitsDetails = ({ data, stagingData, changeColor }) => { - {data && - detailsViewData('data', data, 'unitBlockStart', changeColor)} + {data && detailsViewData('data', data, 'unitBlockStart', false)} {stagingData && detailsViewData( 'stagingData', diff --git a/src/components/forms/ProjectEditModal.js b/src/components/forms/ProjectEditModal.js index 9b09ed4f..c4fcb4ef 100644 --- a/src/components/forms/ProjectEditModal.js +++ b/src/components/forms/ProjectEditModal.js @@ -42,7 +42,7 @@ const ProjectEditModal = ({ }) => { const projectToBeEdited = useSelector( state => - state.climateWarehouse.projects.filter( + state?.climateWarehouse?.projects?.filter( project => project.warehouseProjectId === record.warehouseProjectId, )[0], ); diff --git a/src/components/forms/ProjectTransferModal.js b/src/components/forms/ProjectTransferModal.js index 71691c01..52f5ae1a 100644 --- a/src/components/forms/ProjectTransferModal.js +++ b/src/components/forms/ProjectTransferModal.js @@ -42,7 +42,7 @@ const ProjectTransferModal = ({ }) => { const projectToBeTransferred = useSelector( state => - state.climateWarehouse.projects.filter( + state?.climateWarehouse?.projects?.filter( project => project.warehouseProjectId === record.warehouseProjectId, )[0], ); diff --git a/src/components/forms/UnitCreateModal.js b/src/components/forms/UnitCreateModal.js index b5f798de..6274c2bb 100644 --- a/src/components/forms/UnitCreateModal.js +++ b/src/components/forms/UnitCreateModal.js @@ -38,8 +38,6 @@ const emptyUnit = { countryJurisdictionOfOwner: '', inCountryJurisdictionOfOwner: '', unitCount: 0, - unitBlockEnd: '', - unitBlockStart: '', marketplace: '', marketplaceLink: '', marketplaceIdentifier: '', diff --git a/src/components/forms/UnitDetailsForm.js b/src/components/forms/UnitDetailsForm.js index c404e0fc..8916e93f 100644 --- a/src/components/forms/UnitDetailsForm.js +++ b/src/components/forms/UnitDetailsForm.js @@ -36,7 +36,7 @@ import { SimpleSelectStateEnum, } from '..'; -const UnitDetailsForm = () => { +const UnitDetailsForm = ({ noUnitCount = false }) => { const intl = useIntl(); const { pickLists, myProjects, issuances } = useSelector( store => store.climateWarehouse, @@ -155,7 +155,8 @@ const UnitDetailsForm = () => { + })} + > @@ -211,7 +212,8 @@ const UnitDetailsForm = () => { + })} + > @@ -249,7 +251,8 @@ const UnitDetailsForm = () => { + })} + > @@ -274,108 +277,44 @@ const UnitDetailsForm = () => { - - - - - * - - - - - - - - setFieldValue('unitBlockStart', value)} - onBlur={handleBlur} - name="unitBlockStart" - /> - - - - - - - - * - - - - - - - - setFieldValue('unitBlockEnd', value)} - onBlur={handleBlur} - name="unitBlockEnd" - /> - - - - - - - - * - - - - - - - - setFieldValue('unitCount', value)} - onBlur={handleBlur} - name="unitCount" - /> - - - + {!noUnitCount && ( + + + + + * + + + + + + + + setFieldValue('unitCount', value)} + onBlur={handleBlur} + name="unitCount" + /> + + + + )} + @@ -385,7 +324,8 @@ const UnitDetailsForm = () => { + })} + > @@ -422,7 +362,8 @@ const UnitDetailsForm = () => { + })} + > @@ -453,7 +394,8 @@ const UnitDetailsForm = () => { + })} + > @@ -482,7 +424,8 @@ const UnitDetailsForm = () => { + })} + > @@ -512,7 +455,8 @@ const UnitDetailsForm = () => { + })} + > @@ -546,7 +490,8 @@ const UnitDetailsForm = () => { + })} + > @@ -579,7 +524,8 @@ const UnitDetailsForm = () => { + })} + > @@ -612,7 +558,8 @@ const UnitDetailsForm = () => { + })} + > @@ -646,7 +593,8 @@ const UnitDetailsForm = () => { + })} + > @@ -683,7 +631,8 @@ const UnitDetailsForm = () => { + })} + > @@ -717,7 +666,8 @@ const UnitDetailsForm = () => { + })} + > @@ -748,7 +698,8 @@ const UnitDetailsForm = () => { + })} + > @@ -783,7 +734,8 @@ const UnitDetailsForm = () => { + })} + > diff --git a/src/components/forms/UnitEditModal.js b/src/components/forms/UnitEditModal.js index 798124b4..cec3c649 100644 --- a/src/components/forms/UnitEditModal.js +++ b/src/components/forms/UnitEditModal.js @@ -134,6 +134,11 @@ const UnitEditModal = ({ onClose, record, modalSizeAndPosition }) => { if (dataToSend.serialNumberBlock) { delete dataToSend.serialNumberBlock; } + + delete dataToSend.unitCount; + delete dataToSend.unitBlockEnd; + delete dataToSend.unitBlockStart; + cleanObjectFromEmptyFieldsOrArrays(dataToSend); dispatch(updateUnitsRecord(dataToSend)); }} @@ -188,7 +193,7 @@ const UnitEditModal = ({ onClose, record, modalSizeAndPosition }) => { value={tabValue} index={0} > - + diff --git a/src/components/forms/UnitSplitForm.js b/src/components/forms/UnitSplitForm.js index 9680ba14..f2cc215e 100644 --- a/src/components/forms/UnitSplitForm.js +++ b/src/components/forms/UnitSplitForm.js @@ -118,80 +118,6 @@ const UnitSplitForm = ({ - - - - - * - - - - - - - - - setFieldValue(getFieldName('unitBlockStart'), value) - } - onBlur={handleBlur} - /> - - - - - - - - * - - - - - - - - - setFieldValue(getFieldName('unitBlockEnd'), value) - } - onBlur={handleBlur} - /> - - - diff --git a/src/components/forms/UnitSplitFormModal.js b/src/components/forms/UnitSplitFormModal.js index c03374f1..090eb4ac 100644 --- a/src/components/forms/UnitSplitFormModal.js +++ b/src/components/forms/UnitSplitFormModal.js @@ -29,8 +29,6 @@ const UnitSplitFormModal = ({ onClose, record }) => { unitOwner: '', countryJurisdictionOfOwner: '', inCountryJurisdictionOfOwner: '', - unitBlockStart: '', - unitBlockEnd: '', }), [], ); @@ -65,8 +63,6 @@ const UnitSplitFormModal = ({ onClose, record }) => { records: values.units.map(splittedUnit => { const newUnit = {}; newUnit.unitCount = splittedUnit.unitCount; - newUnit.unitBlockStart = splittedUnit.unitBlockStart; - newUnit.unitBlockEnd = splittedUnit.unitBlockEnd; if (splittedUnit.unitOwner !== '') { newUnit.unitOwner = splittedUnit.unitOwner; diff --git a/src/components/layout/Dashboard.js b/src/components/layout/Dashboard.js index 7f7a97c7..e251939e 100644 --- a/src/components/layout/Dashboard.js +++ b/src/components/layout/Dashboard.js @@ -36,7 +36,10 @@ const InnerContainer = styled('div')` const Dashboard = withTheme(({ children }) => { return (
- {window.self === window.top &&
} +
+
+
+ diff --git a/src/components/layout/Header.js b/src/components/layout/Header.js index 4d08bb16..48812a16 100644 --- a/src/components/layout/Header.js +++ b/src/components/layout/Header.js @@ -57,7 +57,7 @@ const Header = () => { )} - {window.self === window.top && } + diff --git a/src/store/validations/unit.validations.js b/src/store/validations/unit.validations.js index 3d53232b..e05a5d1c 100644 --- a/src/store/validations/unit.validations.js +++ b/src/store/validations/unit.validations.js @@ -8,8 +8,6 @@ export const unitsSchema = yup.object().shape({ .string() .required('yup-validation-field-required'), inCountryJurisdictionOfOwner: yup.string().optional(), - unitBlockEnd: yup.string().required('yup-validation-field-required'), - unitBlockStart: yup.string().required('yup-validation-field-required'), unitCount: yup .number() .positive('yup-validation-positive-number') @@ -54,14 +52,6 @@ export const splitUnitsValidationSchema = yup.object().shape({ .string() .optional() .typeError('yup-validation-valid-string'), - unitBlockStart: yup - .string() - .required('yup-validation-field-required') - .typeError('yup-validation-valid-string'), - unitBlockEnd: yup - .string() - .required('yup-validation-field-required') - .typeError('yup-validation-valid-string'), countryJurisdictionOfOwner: yup .string() .optional() diff --git a/src/utils/functionUtils.js b/src/utils/functionUtils.js index c27a8bd4..2c083a4f 100644 --- a/src/utils/functionUtils.js +++ b/src/utils/functionUtils.js @@ -314,8 +314,12 @@ const stagingDetailsViewLinkInfo = (info, dataType, changeColor) => { }; export const detailsViewData = (type, detailData, dataType, changeColor) => { - //all detail view data corresponding to dates + if (detailData[dataType].changes[0] === null) { + return {'---'}; + } + if (type === 'data' && dataType.toLowerCase().includes('date')) { + //all detail view data corresponding to dates return ( {detailData[dataType] ? getISODate(detailData[dataType]) : '---'}