fix: logo style.

fix: page forms style.
feat: auto-fill items entries from item details.
fix: hiding dashboard copyright bar.
This commit is contained in:
a.bouhuolia
2021-02-25 10:51:27 +02:00
parent 5a58e9bafd
commit 9e2c995813
84 changed files with 1019 additions and 682 deletions

View File

@@ -1,15 +1,11 @@
import React, { useMemo } from 'react';
import React, { useMemo } from 'react';
import * as Yup from 'yup';
import { useFormik } from 'formik';
import { Row, Col, ErrorMessage } from 'components';
import { Formik, Form } from 'formik';
import { FormattedMessage as T } from 'react-intl';
import {
Button,
Classes,
FormGroup,
InputGroup,
Intent,
} from '@blueprintjs/core';
import { Button, Classes } from '@blueprintjs/core';
import { Intent } from '@blueprintjs/core';
import { saveInvoke } from 'utils';
import ReferenceNumberFormContent from './ReferenceNumberFormContent';
/**
* Reference number form.
@@ -21,6 +17,7 @@ export default function ReferenceNumberForm({
initialNumber,
}) {
const validationSchema = Yup.object().shape({
// mode: Yup.string(),
number_prefix: Yup.string(),
next_number: Yup.number(),
});
@@ -33,85 +30,44 @@ export default function ReferenceNumberForm({
[initialPrefix, initialNumber],
);
const {
errors,
touched,
handleSubmit,
isSubmitting,
getFieldProps,
} = useFormik({
enableReinitialize: true,
initialValues: {
...initialValues,
},
validationSchema,
onSubmit: (values, { setSubmitting, setErrors }) => {
onSubmit(values, { setSubmitting, setErrors });
},
});
return (
<div>
<form onSubmit={handleSubmit}>
<div className={Classes.DIALOG_BODY}>
<p className="paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
tincidunt porta quam,
</p>
<Row>
{/* ------------- Prefix ------------- */}
<Col xs={6}>
<FormGroup
label={<T id={'prefix'} />}
className={'form-group--'}
intent={errors.number_prefix && touched.number_prefix && Intent.DANGER}
helperText={
<ErrorMessage name={'prefix'} {...{ errors, touched }} />
}
>
<InputGroup
intent={errors.number_prefix && touched.number_prefix && Intent.DANGER}
{...getFieldProps('number_prefix')}
/>
</FormGroup>
</Col>
const handleSubmit = (values) => {
debugger;
saveInvoke(onSubmit, values);
};
{/* ------------- Next number ------------- */}
<Col xs={6}>
<FormGroup
label={<T id={'next_number'} />}
className={'form-group--'}
intent={
errors.next_number && touched.next_number && Intent.DANGER
}
helperText={
<ErrorMessage name={'next_number'} {...{ errors, touched }} />
}
>
<InputGroup
intent={
errors.next_number && touched.next_number && Intent.DANGER
}
{...getFieldProps('next_number')}
/>
</FormGroup>
</Col>
</Row>
</div>
<div className={Classes.DIALOG_FOOTER}>
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
<Button onClick={onClose}>
<T id={'cancel'} />
</Button>
<Button
intent={Intent.PRIMARY}
type="submit"
disabled={isSubmitting}
>
<T id={'submit'} />
</Button>
return (
<Formik
initialValues={initialValues}
validationSchema={validationSchema}
onSubmit={handleSubmit}
>
{({ isSubmitting }) => (
<Form>
<div className={Classes.DIALOG_BODY}>
<p className="paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce
tincidunt porta quam,
</p>
<ReferenceNumberFormContent />
</div>
</div>
</form>
</div>
<div className={Classes.DIALOG_FOOTER}>
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
<Button onClick={onClose}>
<T id={'cancel'} />
</Button>
<Button
intent={Intent.PRIMARY}
type="submit"
disabled={isSubmitting}
>
<T id={'submit'} />
</Button>
</div>
</div>
</Form>
)}
</Formik>
);
}
}

View File

@@ -0,0 +1,71 @@
import React from 'react';
import { FastField } from 'formik';
import { FormattedMessage as T } from 'react-intl';
import { FormGroup, InputGroup, Radio } from '@blueprintjs/core';
import { Row, Col, ErrorMessage } from 'components';
import { inputIntent } from 'utils';
/**
* Reference number form content.
*/
export default function ReferenceNumberFormContent() {
return (
<>
<FastField name={'mode'}>
{({ form, field, meta: { error, touched } }) => (
<Radio
label="Auto-incrementing invoice number."
value="auto-increment"
{...field}
/>
)}
</FastField>
<Row>
{/* ------------- Prefix ------------- */}
<Col xs={6}>
<FastField name={'prefix'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'prefix'} />}
className={'form-group--'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'prefix'} />}
>
<InputGroup
intent={inputIntent({ error, touched })}
{...field}
/>
</FormGroup>
)}
</FastField>
</Col>
{/* ------------- Next number ------------- */}
<Col xs={6}>
<FastField name={'next_number'}>
{({ form, field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'next_number'} />}
className={'form-group--'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name={'next_number'} />}
>
<InputGroup
intent={inputIntent({ error, touched })}
{...field}
/>
</FormGroup>
)}
</FastField>
</Col>
</Row>
<FastField name={'mode'}>
{({ form, field, meta: { error, touched } }) => (
<Radio label="Manual entring for this transaction." value="manual" {...field} />
)}
</FastField>
</>
);
}