Skip to content

Commit

Permalink
Merge pull request #9 from Chia-Network/feat/autoserialnumber
Browse files Browse the repository at this point in the history
Feat/autoserialnumber
  • Loading branch information
TheLastCicada authored Sep 6, 2023
2 parents 813ddac + 7eb9e35 commit 549fdd1
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 218 deletions.
2 changes: 1 addition & 1 deletion src/components/blocks/APIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 1 addition & 2 deletions src/components/blocks/UnitsDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ const UnitsDetails = ({ data, stagingData, changeColor }) => {
<Body size="Bold" width="100%">
<FormattedMessage id="unit-block-start" />
</Body>
{data &&
detailsViewData('data', data, 'unitBlockStart', changeColor)}
{data && detailsViewData('data', data, 'unitBlockStart', false)}
{stagingData &&
detailsViewData(
'stagingData',
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/ProjectEditModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ProjectEditModal = ({
}) => {
const projectToBeEdited = useSelector(
state =>
state.climateWarehouse.projects.filter(
state?.climateWarehouse?.projects?.filter(
project => project.warehouseProjectId === record.warehouseProjectId,
)[0],
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/ProjectTransferModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ProjectTransferModal = ({
}) => {
const projectToBeTransferred = useSelector(
state =>
state.climateWarehouse.projects.filter(
state?.climateWarehouse?.projects?.filter(
project => project.warehouseProjectId === record.warehouseProjectId,
)[0],
);
Expand Down
2 changes: 0 additions & 2 deletions src/components/forms/UnitCreateModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ const emptyUnit = {
countryJurisdictionOfOwner: '',
inCountryJurisdictionOfOwner: '',
unitCount: 0,
unitBlockEnd: '',
unitBlockStart: '',
marketplace: '',
marketplaceLink: '',
marketplaceIdentifier: '',
Expand Down
190 changes: 71 additions & 119 deletions src/components/forms/UnitDetailsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
SimpleSelectStateEnum,
} from '..';

const UnitDetailsForm = () => {
const UnitDetailsForm = ({ noUnitCount = false }) => {
const intl = useIntl();
const { pickLists, myProjects, issuances } = useSelector(
store => store.climateWarehouse,
Expand Down Expand Up @@ -155,7 +155,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'select-existing-project',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -211,7 +212,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-project-location-id-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -249,7 +251,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-owner-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand All @@ -274,108 +277,44 @@ const UnitDetailsForm = () => {
</InputContainer>
<FormikError name="unitOwner" />
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
<LabelContainer>
*<FormattedMessage id="unit-block-start" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-block-start-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={
errors.unitBlockStart && touched.unitBlockStart
? InputVariantEnum.error
: undefined
}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'unit-block-start',
})}
state={InputStateEnum.default}
value={values.unitBlockStart}
onChange={value => setFieldValue('unitBlockStart', value)}
onBlur={handleBlur}
name="unitBlockStart"
/>
</InputContainer>
<FormikError name="unitBlockStart" />
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
<LabelContainer>
*<FormattedMessage id="unit-block-end" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-block-end-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={
errors.unitBlockEnd && touched.unitBlockEnd
? InputVariantEnum.error
: undefined
}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'unit-block-end',
})}
state={InputStateEnum.default}
value={values.unitBlockEnd}
onChange={value => setFieldValue('unitBlockEnd', value)}
onBlur={handleBlur}
name="unitBlockEnd"
/>
</InputContainer>
<FormikError name="unitBlockEnd" />
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
<LabelContainer>
*<FormattedMessage id="unit-count" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-count-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={
errors.unitCount && touched.unitCount
? InputVariantEnum.error
: undefined
}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'unit-count',
})}
state={InputStateEnum.default}
value={values.unitCount}
onChange={value => setFieldValue('unitCount', value)}
onBlur={handleBlur}
name="unitCount"
/>
</InputContainer>
<FormikError name="unitCount" />
</StyledFieldContainer>
{!noUnitCount && (
<StyledFieldContainer>
<StyledLabelContainer>
<Body>
<LabelContainer>
*<FormattedMessage id="unit-count" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-count-description',
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
variant={
errors.unitCount && touched.unitCount
? InputVariantEnum.error
: undefined
}
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'unit-count',
})}
state={InputStateEnum.default}
value={values.unitCount}
onChange={value => setFieldValue('unitCount', value)}
onBlur={handleBlur}
name="unitCount"
/>
</InputContainer>
<FormikError name="unitCount" />
</StyledFieldContainer>
)}

<StyledFieldContainer>
<StyledLabelContainer>
<Body>
Expand All @@ -385,7 +324,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-in-country-jurisdiction-of-owner-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -422,7 +362,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-country-jurisdiction-of-owner-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -453,7 +394,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-type-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -482,7 +424,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-status-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -512,7 +455,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-status-reason-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -546,7 +490,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-registry-link-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -579,7 +524,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-vintage-year-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -612,7 +558,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-marketplace-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -646,7 +593,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-marketplace-identifier-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -683,7 +631,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-marketplace-link-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -717,7 +666,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-corresponding-adjustment-declaration-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -748,7 +698,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-corresponding-adjustment-status-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down Expand Up @@ -783,7 +734,8 @@ const UnitDetailsForm = () => {
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'units-unit-tags-description',
})}>
})}
>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
Expand Down
7 changes: 6 additions & 1 deletion src/components/forms/UnitEditModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}}
Expand Down Expand Up @@ -188,7 +193,7 @@ const UnitEditModal = ({ onClose, record, modalSizeAndPosition }) => {
value={tabValue}
index={0}
>
<UnitDetailsForm />
<UnitDetailsForm noUnitCount={true} />
</TabPanel>
<TabPanel value={tabValue} index={1}>
<UnitIssuanceForm />
Expand Down
Loading

0 comments on commit 549fdd1

Please sign in to comment.