Skip to content

Commit

Permalink
Move renderPaneFooter out into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeTaylor committed Jul 5, 2023
1 parent cfca642 commit 2204d1c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 33 deletions.
38 changes: 5 additions & 33 deletions src/settings/StorageForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import React from 'react';
import PropTypes from 'prop-types';
import { useIntl, FormattedMessage } from 'react-intl';
import arrayMutators from 'final-form-arrays';
import { Button, Pane, PaneFooter, Row, Select, Checkbox, TextArea } from '@folio/stripes/components';
import { Pane, Row, Select, Checkbox, TextArea } from '@folio/stripes/components';
import { TitleManager } from '@folio/stripes/core';
import stripesFinalForm from '@folio/stripes/final-form';
import { isEqual } from 'lodash';
import setFieldData from 'final-form-set-field-data'; // XXX do we need this?
import { RCF, CF } from '../components/CF';
import renderPaneFooter from './renderPaneFooter';


function validate(values) {
Expand Down Expand Up @@ -42,47 +43,18 @@ const StorageForm = (props) => {
};
const types = ['inventoryStorage', 'solrStorage'].map(x => ({ value: x, label: x }));

function renderPaneFooter() {
return (
<PaneFooter
renderStart={(
<Button
buttonStyle="default mega"
id="clickable-cancel"
marginBottom0
onClick={onCancel}
>
<FormattedMessage id="stripes-components.cancel" />
</Button>
)}
renderEnd={(
<Button
buttonStyle="primary mega"
disabled={pristine || submitting}
id="clickable-update-harvestable"
marginBottom0
onClick={handleSubmit}
type="submit"
>
<FormattedMessage id="stripes-components.saveAndClose" />
</Button>
)}
/>
);
}

const title = props.initialValues.name;

return (
<Pane
centerContent
defaultWidth="60%"
footer={renderPaneFooter()}
id="pane-harvestable-form"
footer={renderPaneFooter(handleSubmit, onCancel, pristine, submitting)}
id="pane-storage-form"
paneTitle={title}
>
<TitleManager record={title}>
<form id="form-course">
<form id="form-storage">
<Row>
<CF tag="id" xs={2} disabled />
<CF tag="type" domain="storage" xs={2} component={Select} dataOptions={[noValue].concat(types)} required />
Expand Down
36 changes: 36 additions & 0 deletions src/settings/renderPaneFooter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { Button, PaneFooter } from '@folio/stripes/components';
import { FormattedMessage } from 'react-intl';


function renderPaneFooter(handleSubmit, onCancel, pristine, submitting) {
return (
<PaneFooter
renderStart={(
<Button
buttonStyle="default mega"
id="clickable-cancel"
marginBottom0
onClick={onCancel}
>
<FormattedMessage id="stripes-components.cancel" />
</Button>
)}
renderEnd={(
<Button
buttonStyle="primary mega"
disabled={pristine || submitting}
id="clickable-update-harvestable"
marginBottom0
onClick={handleSubmit}
type="submit"
>
<FormattedMessage id="stripes-components.saveAndClose" />
</Button>
)}
/>
);
}


export default renderPaneFooter;

0 comments on commit 2204d1c

Please sign in to comment.