Skip to content

Commit

Permalink
when uploading new documents source should be always set to company
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Mar 19, 2024
1 parent ec016bc commit fc7a23c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 67 deletions.
68 changes: 3 additions & 65 deletions components/ui/doc-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import DocumentationService from 'services/documentationService';
import Form, { FormProvider } from 'components/form/Form';
import Field from 'components/form/Field';
import Input from 'components/form/Input';
import Select from 'components/form/SelectInput';
import Textarea from 'components/form/Textarea';
import File from 'components/form/File';
import SubmitButton from 'components/form/SubmitButton';
Expand All @@ -31,7 +30,7 @@ const TYPES = {
class DocModal extends React.Component {
constructor(props) {
super(props);
const { startDate, endDate, url, reason, source, sourceInfo } = props;
const { startDate, endDate, url, reason } = props;

this.state = {
formInitialState: {
Expand All @@ -43,9 +42,7 @@ class DocModal extends React.Component {
endDate && endDate !== '1970/01/01' && endDate.replace(/\//g, '-'),
file: {},
url,
reason,
source: source || 'company',
sourceInfo,
reason
}
};

Expand Down Expand Up @@ -84,11 +81,7 @@ class DocModal extends React.Component {
attributes: {
'start-date': form.startDate,
'expire-date': form.expireDate,
'source-type': form.source,
'source-info':
form.source === 'other_source'
? form.sourceInfo
: null,
'source-type': 'company',
...(form.file.base64 && {
attachment: form.file.base64,
}),
Expand Down Expand Up @@ -157,59 +150,6 @@ class DocModal extends React.Component {
</div>
</div>

{!notRequired && (
<div className="l-row row">
<div className="columns small-12">
<Field
validations={['required']}
className="-fluid"
options={[
{
label: intl.formatMessage({ id: 'company' }),
value: 'company',
},
{
label: intl.formatMessage({
id: 'forest_atlas',
}),
value: 'forest_atlas',
},
{
label: intl.formatMessage({
id: 'other_source',
}),
value: 'other_source',
},
]}
properties={{
name: 'source',
label: intl.formatMessage({ id: 'source' }),
required: true
}}
>
{Select}
</Field>
</div>
{form.source === 'other_source' && (
<div className="columns small-12">
<Field
validations={['required']}
className="-fluid"
properties={{
name: 'sourceInfo',
label: intl.formatMessage({
id: 'source-info',
}),
required: true
}}
>
{Input}
</Field>
</div>
)}
</div>
)}

{/* DOCUMENT */}
{(!notRequired ||
(form.file.base64 && !form.reason)) && (
Expand Down Expand Up @@ -279,8 +219,6 @@ DocModal.propTypes = {
status: PropTypes.string,
url: PropTypes.string,
reason: PropTypes.string,
source: PropTypes.string,
sourceInfo: PropTypes.string,
title: PropTypes.string,
requiredDocId: PropTypes.string,
type: PropTypes.string,
Expand Down
2 changes: 0 additions & 2 deletions e2e/cypress/e2e/operator.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ describe('Operator', function () {

cy.get('#input-startDate').type('2022-03-30');
cy.get('#input-expireDate').type('2030-03-30');
cy.selectOption('[name=source]', null, 'Other');
cy.get('#input-sourceInfo').clear().type('Here is example source info');
cy.get('input[type=file]').attachFile('test_document.docx');

cy.intercept('http://localhost:3000/operator-document-histories?*').as('documentsReload');
Expand Down

0 comments on commit fc7a23c

Please sign in to comment.