From ae5da14ce2872c7336320ab9ec725bbdbc1c9086 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 6 Sep 2023 16:42:55 -0400 Subject: [PATCH 1/4] feat: handle auto serial number --- src/components/blocks/APIDataTable.js | 2 +- src/components/blocks/UnitsDetails.js | 54 ------ src/components/forms/ProjectEditModal.js | 2 +- src/components/forms/ProjectTransferModal.js | 2 +- src/components/forms/UnitCreateModal.js | 2 - src/components/forms/UnitDetailsForm.js | 190 +++++++------------ src/components/forms/UnitEditModal.js | 7 +- src/components/forms/UnitSplitForm.js | 74 -------- src/components/forms/UnitSplitFormModal.js | 4 - src/components/layout/Dashboard.js | 5 +- src/components/layout/Header.js | 2 +- src/store/validations/unit.validations.js | 10 - 12 files changed, 85 insertions(+), 269 deletions(-) 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..da14e22a 100644 --- a/src/components/blocks/UnitsDetails.js +++ b/src/components/blocks/UnitsDetails.js @@ -98,60 +98,6 @@ const UnitsDetails = ({ data, stagingData, changeColor }) => { changeColor, )} - - - - - {data && - detailsViewData('data', data, 'unitBlockStart', changeColor)} - {stagingData && - detailsViewData( - 'stagingData', - stagingData, - 'unitBlockStart', - changeColor, - )} - - - - - - {data && detailsViewData('data', data, 'unitBlockEnd', changeColor)} - {stagingData && - detailsViewData( - 'stagingData', - stagingData, - 'unitBlockEnd', - changeColor, - )} - - - - - - {data && detailsViewData('data', data, 'unitCount', changeColor)} - {stagingData && - detailsViewData( - 'stagingData', - stagingData, - 'unitCount', - changeColor, - )} - - - - - - {data && - detailsViewData('data', data, 'serialNumberBlock', changeColor)} - {stagingData && - detailsViewData( - 'stagingData', - stagingData, - 'serialNumberBlock', - changeColor, - )} - 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() From 7eb9e351222eac6f73a2018729b75894f820f2b0 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 6 Sep 2023 17:02:26 -0400 Subject: [PATCH 2/4] fix: coloring for diff --- src/components/blocks/UnitsDetails.js | 53 +++++++++++++++++++++++++++ src/utils/functionUtils.js | 6 ++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/components/blocks/UnitsDetails.js b/src/components/blocks/UnitsDetails.js index da14e22a..0d4fe3d2 100644 --- a/src/components/blocks/UnitsDetails.js +++ b/src/components/blocks/UnitsDetails.js @@ -98,6 +98,59 @@ const UnitsDetails = ({ data, stagingData, changeColor }) => { changeColor, )} + + + + + {data && detailsViewData('data', data, 'unitBlockStart', false)} + {stagingData && + detailsViewData( + 'stagingData', + stagingData, + 'unitBlockStart', + changeColor, + )} + + + + + + {data && detailsViewData('data', data, 'unitBlockEnd', changeColor)} + {stagingData && + detailsViewData( + 'stagingData', + stagingData, + 'unitBlockEnd', + changeColor, + )} + + + + + + {data && detailsViewData('data', data, 'unitCount', changeColor)} + {stagingData && + detailsViewData( + 'stagingData', + stagingData, + 'unitCount', + changeColor, + )} + + + + + + {data && + detailsViewData('data', data, 'serialNumberBlock', changeColor)} + {stagingData && + detailsViewData( + 'stagingData', + stagingData, + 'serialNumberBlock', + changeColor, + )} + 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]) : '---'} From 41229b4894469d02deb25b364dace88c106d59b8 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 7 Sep 2023 09:03:49 -0400 Subject: [PATCH 3/4] chore: bump to 1.2.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 49a435c3..464205b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "core-registry-cadt-ui", - "version": "1.2.6", + "version": "1.2.7", "private": true, "author": "Chia Network Inc. ", "homepage": "./", From faadf88d110321a9ec5e21f24fa4d2da46e210a5 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 7 Sep 2023 09:59:16 -0400 Subject: [PATCH 4/4] feat: additional prefix support --- package.json | 2 +- src/components/forms/OrgCreateFormModal.js | 29 ++++++++++++++++++ src/components/forms/OrgEditFormModal.js | 30 ++++++++++++++++++- src/pages/Organization/index.js | 18 +++++++++++ src/store/actions/climateWarehouseActions.js | 2 ++ .../validations/organization.validation.js | 1 + src/translations/tokens/en-US.json | 2 ++ 7 files changed, 82 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 464205b4..7f6c97d2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "core-registry-cadt-ui", - "version": "1.2.7", + "version": "1.2.8", "private": true, "author": "Chia Network Inc. ", "homepage": "./", diff --git a/src/components/forms/OrgCreateFormModal.js b/src/components/forms/OrgCreateFormModal.js index 7bad9f62..9c780d11 100644 --- a/src/components/forms/OrgCreateFormModal.js +++ b/src/components/forms/OrgCreateFormModal.js @@ -40,11 +40,13 @@ const OrgCreateFormModal = ({ onClose }) => { const [formData, setFormData] = useState({ name: '', png: null, + prefix: '', }); const [importedOrgUid, setImportedOrgUid] = useState(''); const [tabValue, setTabValue] = useState(0); const nameIsValid = formData?.name?.length > 0; + const prefixIsValid = formData?.prefix?.length > 0; const isOrgUidValid = importedOrgUid?.length > 4; const handleTabChange = (event, newValue) => { @@ -113,6 +115,33 @@ const OrgCreateFormModal = ({ onClose }) => { )} + + + + * + + + + + setFormData(prevState => ({ + ...prevState, + prefix: value, + })) + } + /> + + {!prefixIsValid && ( + + {intl.formatMessage({ + id: 'add-valid-organization-prefix', + })} + + )} + diff --git a/src/components/forms/OrgEditFormModal.js b/src/components/forms/OrgEditFormModal.js index f037bc0c..6b77d661 100644 --- a/src/components/forms/OrgEditFormModal.js +++ b/src/components/forms/OrgEditFormModal.js @@ -17,12 +17,13 @@ import { } from '..'; import { editExistingOrg } from '../../store/actions/climateWarehouseActions'; -const OrgEditFormModal = ({ onClose, name, icon }) => { +const OrgEditFormModal = ({ onClose, name, prefix, icon }) => { const intl = useIntl(); const dispatch = useDispatch(); const { notification } = useSelector(state => state.app); const [formData, setFormData] = useState({ name, + prefix, png: icon, }); @@ -81,6 +82,33 @@ const OrgEditFormModal = ({ onClose, name, icon }) => { )} + + + + * + + + + + setFormData(prevState => ({ + ...prevState, + prefix: value, + })) + } + /> + + {!nameIsValid && ( + + {intl.formatMessage({ + id: 'add-valid-organization-prefix', + })} + + )} + diff --git a/src/pages/Organization/index.js b/src/pages/Organization/index.js index d84b5e28..475d43fb 100644 --- a/src/pages/Organization/index.js +++ b/src/pages/Organization/index.js @@ -97,6 +97,23 @@ const Organization = () => { + + + + + + {myOrganization.prefix} + + { + navigator.clipboard.writeText(myOrganization.prefix); + }} + /> + + + @@ -207,6 +224,7 @@ const Organization = () => { onClose={() => setIsEditModalOpen(false)} name={myOrganization?.name} icon={myOrganization?.icon} + prefix={myOrganization?.prefix} /> )} {isDeleteModalOpen && ( diff --git a/src/store/actions/climateWarehouseActions.js b/src/store/actions/climateWarehouseActions.js index 4dd0ca17..b776c306 100644 --- a/src/store/actions/climateWarehouseActions.js +++ b/src/store/actions/climateWarehouseActions.js @@ -1847,6 +1847,7 @@ export const postNewOrg = data => { const formData = new FormData(); formData.append('file', data.png); formData.append('name', data.name); + formData.append('prefix', data.prefix); const url = `${constants.API_HOST}/organizations/create`; const payload = { @@ -1896,6 +1897,7 @@ export const editExistingOrg = data => { const formData = new FormData(); formData.append('file', data.png); formData.append('name', data.name); + formData.append('prefix', data.prefix); const url = `${constants.API_HOST}/organizations/edit`; const payload = { diff --git a/src/store/validations/organization.validation.js b/src/store/validations/organization.validation.js index 93a1b053..d2a542b1 100644 --- a/src/store/validations/organization.validation.js +++ b/src/store/validations/organization.validation.js @@ -3,6 +3,7 @@ import { validateUrl } from '../../utils/urlUtils'; export const organizationSchema = yup.object().shape({ name: yup.string().required('Required Field'), + prefix: yup.string().optional(), icon: yup .string() .test({ diff --git a/src/translations/tokens/en-US.json b/src/translations/tokens/en-US.json index e3beb234..f7f33e42 100644 --- a/src/translations/tokens/en-US.json +++ b/src/translations/tokens/en-US.json @@ -293,6 +293,7 @@ "create-organization": "Create Organization", "you-need-to-create-organization": "You need to create your Organization to have full access to the Registry.", "organization-name": "Organization Name", + "organization-prefix": "Organization Prefix", "organization-icon": "Organization Icon", "organization-website": "Organization Website", "organization-created": "Your organization was successfully added.", @@ -327,6 +328,7 @@ "add-valid-server-address": "Add a valid server address", "add-valid-api-key": "Add a valid Api key", "add-valid-organization-name": "Add a valid organization name", + "add-valid-organization-prefix": "Add a valid organization prefix", "project-one": "Project 1", "project-two": "Project 2", "first-project": "First Project",