Skip to content

Commit

Permalink
fix: adjusted edit Units/Projects
Browse files Browse the repository at this point in the history
  • Loading branch information
SPageot committed Jan 31, 2022
1 parent c5903a4 commit 786d213
Show file tree
Hide file tree
Showing 17 changed files with 461 additions and 173 deletions.
3 changes: 2 additions & 1 deletion src/components/blocks/YearSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const YearSelect = ({ size, yearValue, setYearValue }) => {
<DatePicker
views={['year']}
label="Year"
value={yearValue}
value={yearValue ? `${yearValue}`: yearValue}
onChange={newValue => {
setYearValue(`${newValue.$y}`);
}}
Expand All @@ -76,6 +76,7 @@ const YearSelect = ({ size, yearValue, setYearValue }) => {
);
}}
/>
{console.log(yearValue)}
</LocalizationProvider>
);
};
Expand Down
181 changes: 181 additions & 0 deletions src/components/forms/CreateEstimationsForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import u from 'updeep';
import React from 'react';
import styled from 'styled-components';
import { useIntl, FormattedMessage } from 'react-intl';

import {
StandardInput,
InputSizeEnum,
InputStateEnum,
Divider,
ModalFormContainerStyle,
FormContainerStyle,
BodyContainer,
Body,
DescriptionIcon,
ToolTipContainer,
DateSelect,
} from '..';
import { LabelContainer } from '../../utils/compUtils';

const StyledLabelContainer = styled('div')`
margin-bottom: 0.5rem;
`;

const StyledFieldContainer = styled('div')`
padding-bottom: 1.25rem;
`;

const InputContainer = styled('div')`
width: 20rem;
`;

const CreateEstimationsForm = ({ value, onChange }) => {
console.log(value);
const intl = useIntl();
const onInputChange = (field, changeValue) => {
onChange(u({ [field]: changeValue }, value));
};

return (
<ModalFormContainerStyle>
<FormContainerStyle>
<BodyContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="crediting-period-start" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'estimations-crediting-period-start-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<DateSelect
size="large"
dateValue={value.creditingPeriodStart}
setDateValue={changeValue =>
onInputChange('creditingPeriodStart', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="crediting-period-end" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'estimations-crediting-period-end-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<DateSelect
size="large"
dateValue={value.creditingPeriodEnd}
setDateValue={changeValue =>
onInputChange('creditingPeriodEnd', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="unit-count" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'ratings-unit-count-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'unit-count',
})}
state={InputStateEnum.default}
value={value.unitCount}
onChange={changeValue =>
onInputChange('unitCount', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>
</BodyContainer>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="verification-date" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'ratings-verification-date-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<DateSelect
size="large"
dateValue={value.verificationDate}
setDateValue={changeValue =>
onInputChange('verificationDate', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="verification-body" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'ratings-verification-body-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'verification-body',
})}
state={InputStateEnum.default}
value={value.verificationBody}
onChange={changeValue =>
onInputChange('verificationBody', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>
</div>
</FormContainerStyle>
<Divider />
</ModalFormContainerStyle>
);
};

export { CreateEstimationsForm };
9 changes: 4 additions & 5 deletions src/components/forms/CreateIssuanceForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ const CreateIssuanceForm = ({ value, onChange }) => {
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="verification-date" />
<FormattedMessage id="verification-report-date" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'issuances-verification-date-description',
id: 'issuances-verification-report-date-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
Expand All @@ -136,14 +136,13 @@ const CreateIssuanceForm = ({ value, onChange }) => {
<InputContainer>
<DateSelect
size="large"
dateValue={value.verificationDate}
dateValue={value.verificationReportDate}
setDateValue={changeValue =>
onInputChange('verificationDate', changeValue)
onInputChange('verificationReportDate', changeValue)
}
/>
</InputContainer>
</StyledFieldContainer>

<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
Expand Down
28 changes: 28 additions & 0 deletions src/components/forms/CreateLabelsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,34 @@ const CreateLabelsForm = ({ value, onChange }) => {
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
<LabelContainer>
<FormattedMessage id="label-type" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'labels-label-type-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'label-type',
})}
state={InputStateEnum.default}
value={value.labelType}
onChange={event => {
onChange({ ...value, labelType: event });
}}
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
Expand Down
38 changes: 3 additions & 35 deletions src/components/forms/CreateProjectForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const CreateProjectForm = withRouter(({ onClose }) => {
};

const [newProject, setNewProject] = useState({
currentRegistry: '',
projectId: '',
registryOfOrigin: '',
program: '',
Expand Down Expand Up @@ -109,7 +108,7 @@ const CreateProjectForm = withRouter(({ onClose }) => {
if (!_.isEmpty(newRelatedProjects)) {
dataToSend.relatedProjects = newRelatedProjects;
}

console.log(dataToSend);
dispatch(postNewProject(dataToSend));
};

Expand Down Expand Up @@ -177,37 +176,6 @@ const CreateProjectForm = withRouter(({ onClose }) => {
<ModalFormContainerStyle>
<FormContainerStyle>
<BodyContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body color={'#262626'}>
<LabelContainer>
<FormattedMessage id="current-registry" />
</LabelContainer>
<ToolTipContainer
tooltip={intl.formatMessage({
id: 'projects-current-registry-description',
})}>
<DescriptionIcon height="14" width="14" />
</ToolTipContainer>
</Body>
</StyledLabelContainer>
<InputContainer>
<StandardInput
size={InputSizeEnum.large}
placeholderText={intl.formatMessage({
id: 'current-registry',
})}
state={InputStateEnum.default}
value={newProject.currentRegistry}
onChange={value =>
setNewProject(prev => ({
...prev,
currentRegistry: value,
}))
}
/>
</InputContainer>
</StyledFieldContainer>
<StyledFieldContainer>
<StyledLabelContainer>
<Body style={{ color: '#262626' }}>
Expand Down Expand Up @@ -742,8 +710,8 @@ const CreateProjectForm = withRouter(({ onClose }) => {
</TabPanel>
<TabPanel value={tabValue} index={4}>
<LocationsRepeater
projectLocationsState={newProjectLocations}
setProjectLocationsState={setNewProjectLocations}
locationsState={newProjectLocations}
setLocationsState={setNewProjectLocations}
/>
</TabPanel>
<TabPanel value={tabValue} index={5}>
Expand Down
1 change: 0 additions & 1 deletion src/components/forms/CreateUnitsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const CreateUnitsForm = withRouter(({ onClose }) => {
selectedCorrespondingAdjustmentDeclaration[0].value;
}
if (!_.isEmpty(year)) {
console.log(year);
dataToSend.vintageYear = year;
}
if (!_.isEmpty(selectedCorrespondingAdjustmentStatus)) {
Expand Down

0 comments on commit 786d213

Please sign in to comment.