mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat(warehouse): add warehouse.
This commit is contained in:
@@ -34,6 +34,7 @@ import UnlockingTransactionsDialog from '../containers/Dialogs/UnlockingTransact
|
||||
import UnlockingPartialTransactionsDialog from '../containers/Dialogs/UnlockingPartialTransactionsDialog';
|
||||
import CreditNotePdfPreviewDialog from '../containers/Dialogs/CreditNotePdfPreviewDialog';
|
||||
import PaymentReceivePdfPreviewDialog from '../containers/Dialogs/PaymentReceivePdfPreviewDialog';
|
||||
import WarehouseFormDialog from '../containers/Dialogs/WarehouseFormDialog';
|
||||
|
||||
/**
|
||||
* Dialogs container.
|
||||
@@ -78,6 +79,7 @@ export default function DialogsContainer() {
|
||||
/>
|
||||
<CreditNotePdfPreviewDialog dialogName={'credit-note-pdf-preview'} />
|
||||
<PaymentReceivePdfPreviewDialog dialogName={'payment-pdf-preview'} />
|
||||
<WarehouseFormDialog dialogName={'warehouse-form'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { CLASSES } from 'common/classes';
|
||||
import DashboardTopbarUser from 'components/Dashboard/TopbarUser';
|
||||
import UsersActions from 'containers/Preferences/Users/UsersActions';
|
||||
import CurrenciesActions from 'containers/Preferences/Currencies/CurrenciesActions';
|
||||
import WarehousesActions from '../../containers/Preferences/Warehouses/WarehousesActions'
|
||||
import withDashboard from 'containers/Dashboard/withDashboard';
|
||||
|
||||
import { compose } from 'utils';
|
||||
@@ -35,6 +36,11 @@ function PreferencesTopbar({ preferencesPageTitle }) {
|
||||
path={'/preferences/currencies'}
|
||||
component={CurrenciesActions}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path={'/preferences/warehouses'}
|
||||
component={WarehousesActions}
|
||||
/>
|
||||
</Switch>
|
||||
</Route>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,10 @@ export default [
|
||||
|
||||
href: '/preferences/currencies',
|
||||
},
|
||||
{
|
||||
text: <T id={'warehouses.label'} />,
|
||||
href: '/preferences/warehouses',
|
||||
},
|
||||
{
|
||||
text: <T id={'accountant'} />,
|
||||
disabled: false,
|
||||
|
||||
46
src/containers/Dialogs/WarehouseFormDialog/WarehouseForm.js
Normal file
46
src/containers/Dialogs/WarehouseFormDialog/WarehouseForm.js
Normal file
@@ -0,0 +1,46 @@
|
||||
import React from 'react';
|
||||
import { Formik } from 'formik';
|
||||
|
||||
import { CreateWarehouseFormSchema } from './WarehouseForm.schema';
|
||||
import { useWarehouseFormContext } from './WarehouseFormProvider';
|
||||
import WarehouseFormContent from './WarehouseFormContent';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
const defaultInitialValues = {
|
||||
warehouse_name: '',
|
||||
warehouse_address_1: '',
|
||||
warehouse_address_2: '',
|
||||
warehouse_address_city: '',
|
||||
warehouse_address_country: '',
|
||||
phone_number: '',
|
||||
};
|
||||
|
||||
/**
|
||||
* Warehouse form.
|
||||
* @returns
|
||||
*/
|
||||
function WarehouseForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// Initial form values.
|
||||
const initialValues = {
|
||||
...defaultInitialValues,
|
||||
};
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
validationSchema={CreateWarehouseFormSchema}
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleFormSubmit}
|
||||
component={WarehouseFormContent}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(WarehouseForm);
|
||||
@@ -0,0 +1,13 @@
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
warehouse_name: Yup.string().required().label(intl.get('warehouse_name')),
|
||||
warehouse_address_1: Yup.string().trim(),
|
||||
warehouse_address_2: Yup.string().trim(),
|
||||
warehouse_address_city: Yup.string().trim(),
|
||||
warehouse_address_country: Yup.string().trim(),
|
||||
phone_number: Yup.number(),
|
||||
});
|
||||
|
||||
export const CreateWarehouseFormSchema = Schema;
|
||||
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { Form } from 'formik';
|
||||
|
||||
import WarehouseFormFields from './WarehouseFormFields';
|
||||
import WarehouseFormFloatingActions from './WarehouseFormFloatingActions';
|
||||
|
||||
/**
|
||||
* Warehouse form content.
|
||||
* @returns
|
||||
*/
|
||||
export default function WarehouseFormContent() {
|
||||
return (
|
||||
<Form>
|
||||
<WarehouseFormFields />
|
||||
<WarehouseFormFloatingActions />
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import React from 'react';
|
||||
|
||||
import '../../../style/pages/Warehouses/warehouseFormDialog.scss';
|
||||
import { WarehouseFormProvider } from './WarehouseFormProvider';
|
||||
import WarehouseForm from './WarehouseForm';
|
||||
|
||||
/**
|
||||
* Warehouse form dialog content.
|
||||
*/
|
||||
export default function WarehouseFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
}) {
|
||||
return (
|
||||
<WarehouseFormProvider dialogName={dialogName}>
|
||||
<WarehouseForm />
|
||||
</WarehouseFormProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import React from 'react';
|
||||
|
||||
import intl from 'react-intl-universal';
|
||||
import { FastField, ErrorMessage, Field } from 'formik';
|
||||
import styled from 'styled-components';
|
||||
import {
|
||||
Classes,
|
||||
FormGroup,
|
||||
InputGroup,
|
||||
ControlGroup,
|
||||
Position,
|
||||
} from '@blueprintjs/core';
|
||||
import { inputIntent } from 'utils';
|
||||
import { FieldRequiredHint, Col, Row, FormattedMessage as T } from 'components';
|
||||
import { useWarehouseFormContext } from './WarehouseFormProvider';
|
||||
|
||||
/**
|
||||
* Warehouse form fields.
|
||||
* @returns
|
||||
*/
|
||||
export default function WarehouseFormFields() {
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
{/*------------ Warehouse Name -----------*/}
|
||||
<FastField name={'warehouse_name'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'warehouse.dialog.label.warehouse_name'} />}
|
||||
labelInfo={<FieldRequiredHint />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="warehouse_name" />}
|
||||
className={'form-group--warehouse_name'}
|
||||
>
|
||||
<InputGroup intent={inputIntent({ error, touched })} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
{/*------------ Warehouse Address -----------*/}
|
||||
<FastField name={'warehouse_address_1'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={intl.get('warehouse.dialog.label.warehouse_address')}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="warehouse_address_1" />}
|
||||
className={'form-group--warehouse_address_1'}
|
||||
>
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
placeholder={intl.get(
|
||||
'warehouse.dialog.label.warehouse_address_1',
|
||||
)}
|
||||
{...field}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
<WarehouseAddressWrap>
|
||||
<FastField name={'warehouse_address_2'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="warehouse_address_2" />}
|
||||
className={'form-group--warehouse_address_2'}
|
||||
>
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
placeholder={intl.get(
|
||||
'warehouse.dialog.label.warehouse_address_2',
|
||||
)}
|
||||
{...field}
|
||||
/>
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
{/*------------ Warehouse Address City & Country-----------*/}
|
||||
<FormGroup
|
||||
inline={true}
|
||||
className={'form-group--warehouse_address_city'}
|
||||
helperText={<ErrorMessage name="warehouse_address_city" />}
|
||||
>
|
||||
<ControlGroup>
|
||||
<FastField name={'warehouse_address_city'}>
|
||||
{({ field, meta: { error, touched } }) => (
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
placeholder={intl.get('warehouse.dialog.label.city')}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
<FastField name={'warehouse_address_country'}>
|
||||
{({ field, meta: { error, touched } }) => (
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
placeholder={intl.get('warehouse.dialog.label.country')}
|
||||
{...field}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
</ControlGroup>
|
||||
</FormGroup>
|
||||
</WarehouseAddressWrap>
|
||||
{/*------------ Phone Number -----------*/}
|
||||
<FastField name={'phone_number'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={intl.get('warehouse.dialog.label.phone_number')}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="phone_number" />}
|
||||
className={'form-group--phone_number'}
|
||||
>
|
||||
<InputGroup intent={inputIntent({ error, touched })} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const WarehouseAddressWrap = styled.div`
|
||||
padding-left: 150px;
|
||||
`;
|
||||
@@ -0,0 +1,48 @@
|
||||
import React from 'react';
|
||||
|
||||
import { Intent, Button, Classes } from '@blueprintjs/core';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
|
||||
import { useWarehouseFormContext } from './WarehouseFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouse form floating actions.
|
||||
* @returns
|
||||
*/
|
||||
function WarehouseFormFloatingActions({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
// Formik context.
|
||||
const { isSubmitting } = useFormikContext();
|
||||
|
||||
const { dialogName } = useWarehouseFormContext();
|
||||
|
||||
// Handle close button click.
|
||||
const handleCancelBtnClick = () => {
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={Classes.DIALOG_FOOTER}>
|
||||
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
||||
<Button onClick={handleCancelBtnClick} style={{ minWidth: '85px' }}>
|
||||
<T id={'cancel'} />
|
||||
</Button>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
loading={isSubmitting}
|
||||
style={{ minWidth: '95px' }}
|
||||
type="submit"
|
||||
>
|
||||
{<T id={'save'} />}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(WarehouseFormFloatingActions);
|
||||
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import {} from 'hooks/query';
|
||||
|
||||
const WarehouseFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Warehouse form provider.
|
||||
*/
|
||||
function WarehouseFormProvider({ dialogName, ...props }) {
|
||||
// State provider.
|
||||
const provider = {
|
||||
dialogName,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<WarehouseFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
}
|
||||
|
||||
const useWarehouseFormContext = () => React.useContext(WarehouseFormContext);
|
||||
|
||||
export { WarehouseFormProvider, useWarehouseFormContext };
|
||||
31
src/containers/Dialogs/WarehouseFormDialog/index.js
Normal file
31
src/containers/Dialogs/WarehouseFormDialog/index.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import React from 'react';
|
||||
import { FormattedMessage as T } from 'components';
|
||||
import { Dialog, DialogSuspense } from 'components';
|
||||
import withDialogRedux from 'components/DialogReduxConnect';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
const WarehouseFormDialogContent = React.lazy(() =>
|
||||
import('./WarehouseFormDialogContent'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Warehouse form form dialog.
|
||||
*/
|
||||
function WarehouseFormDialog({ dialogName, isOpen }) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={<T id={'warehouse.dialog.label'} />}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={true}
|
||||
autoFocus={true}
|
||||
className={'dialog--warehouse-form'}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<WarehouseFormDialogContent dialogName={dialogName} />
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
export default compose(withDialogRedux())(WarehouseFormDialog);
|
||||
32
src/containers/Preferences/Warehouses/WarehousesActions.js
Normal file
32
src/containers/Preferences/Warehouses/WarehousesActions.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react';
|
||||
import { Button, Intent } from '@blueprintjs/core';
|
||||
|
||||
import { FormattedMessage as T, Icon } from 'components';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouse actions.
|
||||
*/
|
||||
function WarehousesActions({
|
||||
//#ownProps
|
||||
openDialog,
|
||||
}) {
|
||||
const handleClickNewWarehouse = () => {
|
||||
openDialog('warehouse-form');
|
||||
};
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Button
|
||||
icon={<Icon icon="plus" iconSize={12} />}
|
||||
onClick={handleClickNewWarehouse}
|
||||
intent={Intent.PRIMARY}
|
||||
>
|
||||
<T id={'warehouses.label.new_warehouse'} />
|
||||
</Button>
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withDialogActions)(WarehousesActions);
|
||||
@@ -1757,7 +1757,6 @@
|
||||
"profit_loss_sheet.percentage_of_income": "% of Income",
|
||||
|
||||
"the_vendor_has_been_inactivated_successfully": "The contact has been inactivated successfully.",
|
||||
|
||||
"vendor.alert.activated_message": "The vendor has been activated successfully.",
|
||||
"vendor.alert.are_you_sure_want_to_inactivate_this_vendor": "Are you sure want to inactivate this vendor? You will to able to activate it later.",
|
||||
"vendor.alert.inactivated_message": "The vendor has been inactivated successfully.",
|
||||
@@ -1769,5 +1768,19 @@
|
||||
"customer.alert.are_you_sure_want_to_inactivate_this_customer": "Are you sure want to inactivate this customer? You will to able to activate it later.",
|
||||
|
||||
"credit_note_preview.dialog.title": "Credit Note PDF Preview",
|
||||
"payment_receive_preview.dialog.title": "Payment Receive PDF Preview"
|
||||
}
|
||||
"payment_receive_preview.dialog.title": "Payment Receive PDF Preview",
|
||||
|
||||
"credit_note_preview.dialog.title": "Credit Note PDF Preview",
|
||||
"payment_receive_preview.dialog.title": "Payment Receive PDF Preview",
|
||||
|
||||
"warehouses.label": "Warehouses",
|
||||
"warehouses.label.new_warehouse": "New Warehouse",
|
||||
"warehouse.dialog.label":"New Warehouse",
|
||||
"warehouse.dialog.label.warehouse_name":"Warehouse Name",
|
||||
"warehouse.dialog.label.warehouse_address":"Address",
|
||||
"warehouse.dialog.label.warehouse_address_1":"Address 1",
|
||||
"warehouse.dialog.label.warehouse_address_2":"Address 2",
|
||||
"warehouse.dialog.label.city":"City",
|
||||
"warehouse.dialog.label.country":"Country",
|
||||
"warehouse.dialog.label.phone_number":"Phone Number"
|
||||
}
|
||||
|
||||
36
src/style/pages/Warehouses/warehouseFormDialog.scss
Normal file
36
src/style/pages/Warehouses/warehouseFormDialog.scss
Normal file
@@ -0,0 +1,36 @@
|
||||
.dialog--warehouse-form {
|
||||
width: 650px;
|
||||
|
||||
.bp3-dialog-body {
|
||||
.bp3-form-group.bp3-inline {
|
||||
.bp3-label {
|
||||
font-size: 13px;
|
||||
min-width: 140px;
|
||||
}
|
||||
.bp3-form-content {
|
||||
width: 388px;
|
||||
}
|
||||
.bp3-control-group > * {
|
||||
flex-shrink: unset;
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
|
||||
&:first-child {
|
||||
padding-left: 0;
|
||||
}
|
||||
&:last-child {
|
||||
padding-right: 0;
|
||||
}
|
||||
}
|
||||
&.form-group--warehouse_name,
|
||||
&.form-group--phone_number {
|
||||
.bp3-form-content {
|
||||
width: 278px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.bp3-dialog-footer {
|
||||
padding-top: 10px;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user