mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(warehouse): add credit & edit & delete warehouse.
This commit is contained in:
77
src/containers/Alerts/Warehouses/WarehouseDeleteAlert.js
Normal file
77
src/containers/Alerts/Warehouses/WarehouseDeleteAlert.js
Normal file
@@ -0,0 +1,77 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
|
||||
import { Intent, Alert } from '@blueprintjs/core';
|
||||
import { AppToaster } from 'components';
|
||||
import { useDeleteWarehouse } from 'hooks/query';
|
||||
|
||||
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
|
||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouse delete alert
|
||||
* @returns
|
||||
*/
|
||||
function WarehouseDeleteAlert({
|
||||
name,
|
||||
|
||||
// #withAlertStoreConnect
|
||||
isOpen,
|
||||
payload: { warehouseId },
|
||||
|
||||
// #withAlertActions
|
||||
closeAlert,
|
||||
}) {
|
||||
const { mutateAsync: deleteWarehouseMutate, isLoading } =
|
||||
useDeleteWarehouse();
|
||||
|
||||
// handle cancel delete warehouse alert.
|
||||
const handleCancelDeleteAlert = () => {
|
||||
closeAlert(name);
|
||||
};
|
||||
|
||||
// handleConfirm delete invoice
|
||||
const handleConfirmWarehouseDelete = () => {
|
||||
deleteWarehouseMutate(warehouseId)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: intl.get('warehouse.alert.delete_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
})
|
||||
.catch(
|
||||
({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {},
|
||||
)
|
||||
.finally(() => {
|
||||
closeAlert(name);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelDeleteAlert}
|
||||
onConfirm={handleConfirmWarehouseDelete}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage id={'warehouse.once_delete_this_warehouse'} />
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(WarehouseDeleteAlert);
|
||||
@@ -19,7 +19,8 @@ import CurrenciesAlerts from '../Preferences/Currencies/CurrenciesAlerts';
|
||||
import RolesAlerts from '../Preferences/Users/Roles/RolesAlerts';
|
||||
import CreditNotesAlerts from '../Sales/CreditNotes/CreditNotesAlerts';
|
||||
import VendorCreditNotesAlerts from '../Purchases/CreditNotes/VendorCreditNotesAlerts';
|
||||
import TransactionsLockingAlerts from '../TransactionsLocking/TransactionsLockingAlerts'
|
||||
import TransactionsLockingAlerts from '../TransactionsLocking/TransactionsLockingAlerts';
|
||||
import WarehousesAlerts from '../Preferences/Warehouses/WarehousesAlerts';
|
||||
|
||||
export default [
|
||||
...AccountsAlerts,
|
||||
@@ -43,5 +44,6 @@ export default [
|
||||
...RolesAlerts,
|
||||
...CreditNotesAlerts,
|
||||
...VendorCreditNotesAlerts,
|
||||
...TransactionsLockingAlerts
|
||||
...TransactionsLockingAlerts,
|
||||
...WarehousesAlerts,
|
||||
];
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
import React from 'react';
|
||||
import { Formik } from 'formik';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import { Formik } from 'formik';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
|
||||
import { AppToaster } from 'components';
|
||||
import { CreateWarehouseFormSchema } from './WarehouseForm.schema';
|
||||
import { useWarehouseFormContext } from './WarehouseFormProvider';
|
||||
import WarehouseFormContent from './WarehouseFormContent';
|
||||
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
import { compose, transformToForm } from 'utils';
|
||||
|
||||
const defaultInitialValues = {
|
||||
warehouse_name: '',
|
||||
warehouse_address_1: '',
|
||||
warehouse_address_2: '',
|
||||
warehouse_address_city: '',
|
||||
warehouse_address_country: '',
|
||||
name: '',
|
||||
code: '',
|
||||
address: '',
|
||||
city: '',
|
||||
country: '',
|
||||
phone_number: '',
|
||||
website: '',
|
||||
email: '',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -25,13 +31,50 @@ function WarehouseForm({
|
||||
// #withDialogActions
|
||||
closeDialog,
|
||||
}) {
|
||||
const {
|
||||
dialogName,
|
||||
warehouse,
|
||||
warehouseId,
|
||||
createWarehouseMutate,
|
||||
editWarehouseMutate,
|
||||
} = useWarehouseFormContext();
|
||||
|
||||
// Initial form values.
|
||||
const initialValues = {
|
||||
...defaultInitialValues,
|
||||
...transformToForm(warehouse, defaultInitialValues),
|
||||
};
|
||||
|
||||
// Handles the form submit.
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {};
|
||||
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
|
||||
const form = { ...values };
|
||||
|
||||
// Handle request response success.
|
||||
const onSuccess = (response) => {
|
||||
AppToaster.show({
|
||||
message: intl.get('warehouse.dialog.success_message'),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
closeDialog(dialogName);
|
||||
};
|
||||
|
||||
// Handle request response errors.
|
||||
const onError = ({
|
||||
response: {
|
||||
data: { errors },
|
||||
},
|
||||
}) => {
|
||||
if (errors) {
|
||||
}
|
||||
setSubmitting(false);
|
||||
};
|
||||
|
||||
if (warehouseId) {
|
||||
editWarehouseMutate([warehouseId, form]).then(onSuccess).catch(onError);
|
||||
} else {
|
||||
createWarehouseMutate(form).then(onSuccess).catch(onError);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Formik
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
import * as Yup from 'yup';
|
||||
import intl from 'react-intl-universal';
|
||||
import { DATATYPES_LENGTH } from 'common/dataTypes';
|
||||
|
||||
const Schema = Yup.object().shape({
|
||||
warehouse_name: Yup.string().required().label(intl.get('warehouse_name')),
|
||||
warehouse_address_1: Yup.string().trim(),
|
||||
name: Yup.string().required().label(intl.get('warehouse_name')),
|
||||
code: Yup.string().trim().min(0).max(DATATYPES_LENGTH.STRING),
|
||||
address: Yup.string().trim(),
|
||||
warehouse_address_2: Yup.string().trim(),
|
||||
warehouse_address_city: Yup.string().trim(),
|
||||
warehouse_address_country: Yup.string().trim(),
|
||||
city: Yup.string().trim(),
|
||||
country: Yup.string().trim(),
|
||||
phone_number: Yup.number(),
|
||||
website: Yup.string().url().nullable(),
|
||||
email: Yup.string().email().nullable(),
|
||||
});
|
||||
|
||||
export const CreateWarehouseFormSchema = Schema;
|
||||
|
||||
@@ -10,9 +10,10 @@ import WarehouseForm from './WarehouseForm';
|
||||
export default function WarehouseFormDialogContent({
|
||||
// #ownProps
|
||||
dialogName,
|
||||
warehouseId,
|
||||
}) {
|
||||
return (
|
||||
<WarehouseFormProvider dialogName={dialogName}>
|
||||
<WarehouseFormProvider warehouseId={warehouseId} dialogName={dialogName}>
|
||||
<WarehouseForm />
|
||||
</WarehouseFormProvider>
|
||||
);
|
||||
|
||||
@@ -22,28 +22,44 @@ export default function WarehouseFormFields() {
|
||||
return (
|
||||
<div className={Classes.DIALOG_BODY}>
|
||||
{/*------------ Warehouse Name -----------*/}
|
||||
<FastField name={'warehouse_name'}>
|
||||
<FastField name={'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" />}
|
||||
helperText={<ErrorMessage name="name" />}
|
||||
className={'form-group--warehouse_name'}
|
||||
>
|
||||
<InputGroup intent={inputIntent({ error, touched })} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
{/*------------ Warehouse Code -----------*/}
|
||||
<FastField name={'code'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'warehouse.dialog.label.code'} />}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="code" />}
|
||||
className={'form-group--warehouse_name'}
|
||||
>
|
||||
<InputGroup intent={inputIntent({ error, touched })} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
{/*------------ Warehouse Address -----------*/}
|
||||
<FastField name={'warehouse_address_1'}>
|
||||
<FastField name={'address'}>
|
||||
{({ 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" />}
|
||||
helperText={<ErrorMessage name="address" />}
|
||||
className={'form-group--warehouse_address_1'}
|
||||
>
|
||||
<InputGroup
|
||||
@@ -57,24 +73,6 @@ export default function WarehouseFormFields() {
|
||||
)}
|
||||
</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}
|
||||
@@ -82,7 +80,7 @@ export default function WarehouseFormFields() {
|
||||
helperText={<ErrorMessage name="warehouse_address_city" />}
|
||||
>
|
||||
<ControlGroup>
|
||||
<FastField name={'warehouse_address_city'}>
|
||||
<FastField name={'city'}>
|
||||
{({ field, meta: { error, touched } }) => (
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
@@ -91,7 +89,7 @@ export default function WarehouseFormFields() {
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
<FastField name={'warehouse_address_country'}>
|
||||
<FastField name={'country'}>
|
||||
{({ field, meta: { error, touched } }) => (
|
||||
<InputGroup
|
||||
intent={inputIntent({ error, touched })}
|
||||
@@ -103,6 +101,7 @@ export default function WarehouseFormFields() {
|
||||
</ControlGroup>
|
||||
</FormGroup>
|
||||
</WarehouseAddressWrap>
|
||||
|
||||
{/*------------ Phone Number -----------*/}
|
||||
<FastField name={'phone_number'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
@@ -117,6 +116,36 @@ export default function WarehouseFormFields() {
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
{/*------------ Email -----------*/}
|
||||
<FastField name={'email'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={intl.get('warehouse.dialog.label.email')}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="email" />}
|
||||
className={'form-group--warehouse_name'}
|
||||
>
|
||||
<InputGroup intent={inputIntent({ error, touched })} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
{/*------------ Website -----------*/}
|
||||
<FastField name={'website'}>
|
||||
{({ form, field, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={intl.get('warehouse.dialog.label.website')}
|
||||
intent={inputIntent({ error, touched })}
|
||||
inline={true}
|
||||
helperText={<ErrorMessage name="email" />}
|
||||
className={'form-group--warehouse_name'}
|
||||
>
|
||||
<InputGroup placeholder={'https://'} {...field} />
|
||||
</FormGroup>
|
||||
)}
|
||||
</FastField>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,44 @@
|
||||
import React from 'react';
|
||||
import { DialogContent } from 'components';
|
||||
// import {} from 'hooks/query';
|
||||
import {
|
||||
useCreateWarehouse,
|
||||
useEditWarehouse,
|
||||
useWarehouse,
|
||||
} from 'hooks/query';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
const WarehouseFormContext = React.createContext();
|
||||
|
||||
/**
|
||||
* Warehouse form provider.
|
||||
*/
|
||||
function WarehouseFormProvider({ dialogName, ...props }) {
|
||||
function WarehouseFormProvider({ dialogName, warehouseId, ...props }) {
|
||||
const { state } = useLocation();
|
||||
|
||||
console.log(state, 'XXX');
|
||||
// Create and edit warehouse mutations.
|
||||
const { mutateAsync: createWarehouseMutate } = useCreateWarehouse();
|
||||
const { mutateAsync: editWarehouseMutate } = useEditWarehouse();
|
||||
|
||||
// Handle fetch invoice detail.
|
||||
const { data: warehouse, isLoading: isWarehouseLoading } = useWarehouse(
|
||||
warehouseId,
|
||||
{
|
||||
enabled: !!warehouseId,
|
||||
},
|
||||
);
|
||||
|
||||
// State provider.
|
||||
const provider = {
|
||||
dialogName,
|
||||
warehouse,
|
||||
warehouseId,
|
||||
createWarehouseMutate,
|
||||
editWarehouseMutate,
|
||||
};
|
||||
|
||||
return (
|
||||
<DialogContent
|
||||
// isLoading={}
|
||||
>
|
||||
<DialogContent isLoading={isWarehouseLoading}>
|
||||
<WarehouseFormContext.Provider value={provider} {...props} />
|
||||
</DialogContent>
|
||||
);
|
||||
|
||||
@@ -12,18 +12,31 @@ const WarehouseFormDialogContent = React.lazy(() =>
|
||||
/**
|
||||
* Warehouse form form dialog.
|
||||
*/
|
||||
function WarehouseFormDialog({ dialogName, isOpen }) {
|
||||
function WarehouseFormDialog({
|
||||
dialogName,
|
||||
payload: { warehouseId = null, action },
|
||||
isOpen,
|
||||
}) {
|
||||
return (
|
||||
<Dialog
|
||||
name={dialogName}
|
||||
title={<T id={'warehouse.dialog.label'} />}
|
||||
title={
|
||||
action == 'edit' ? (
|
||||
<T id={'warehouse.dialog.label.edit_warehouse'} />
|
||||
) : (
|
||||
<T id={'warehouse.dialog.label.new_warehouse'} />
|
||||
)
|
||||
}
|
||||
isOpen={isOpen}
|
||||
canEscapeJeyClose={true}
|
||||
autoFocus={true}
|
||||
className={'dialog--warehouse-form'}
|
||||
>
|
||||
<DialogSuspense>
|
||||
<WarehouseFormDialogContent dialogName={dialogName} />
|
||||
<WarehouseFormDialogContent
|
||||
dialogName={dialogName}
|
||||
warehouseId={warehouseId}
|
||||
/>
|
||||
</DialogSuspense>
|
||||
</Dialog>
|
||||
);
|
||||
|
||||
@@ -1,63 +1,30 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
import { ContextMenu2 } from '@blueprintjs/popover2';
|
||||
|
||||
import { useWarehousesContext } from './WarehousesProvider';
|
||||
import WarehousesGridItems from './WarehousesGridItems';
|
||||
import { WarehouseContextMenu } from './components';
|
||||
import withAlertsActions from '../../Alert/withAlertActions';
|
||||
import withDialogActions from '../../Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
|
||||
const WAREHOUSE = [
|
||||
{
|
||||
title: 'Warehouse #1',
|
||||
code: '1001',
|
||||
city: 'City',
|
||||
country: 'Country',
|
||||
email: 'email@emial.com',
|
||||
phone: '09xxxxxxxx',
|
||||
},
|
||||
{
|
||||
title: 'Warehouse #2',
|
||||
code: '100',
|
||||
city: 'City',
|
||||
country: 'Country',
|
||||
email: 'email@emial.com',
|
||||
phone: '09xxxxxxxx',
|
||||
},
|
||||
{
|
||||
title: 'Warehouse #2',
|
||||
code: '100',
|
||||
city: 'City',
|
||||
country: 'Country',
|
||||
email: 'email@emial.com',
|
||||
phone: '09xxxxxxxx',
|
||||
},
|
||||
];
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouses.
|
||||
* @returns
|
||||
*/
|
||||
function Warehouses({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
// #withDashboardActions
|
||||
changePreferencesPageTitle,
|
||||
}) {
|
||||
return (
|
||||
<ContextMenu2 content={<WarehouseContextMenu />}>
|
||||
<WarehouseGridWrap>
|
||||
<WarehousesGridItems warehouses={WAREHOUSE} />
|
||||
</WarehouseGridWrap>
|
||||
</ContextMenu2>
|
||||
);
|
||||
const { warehouses } = useWarehousesContext();
|
||||
|
||||
React.useEffect(() => {
|
||||
changePreferencesPageTitle(intl.get('warehouses.label'));
|
||||
}, [changePreferencesPageTitle]);
|
||||
|
||||
return warehouses.map((warehouse) => (
|
||||
<WarehousesGridItems warehouse={warehouse} />
|
||||
));
|
||||
}
|
||||
|
||||
export default compose(withAlertsActions, withDialogActions)(Warehouses);
|
||||
|
||||
const WarehouseGridWrap = styled.div`
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 15px;
|
||||
`;
|
||||
export default compose(withDashboardActions)(Warehouses);
|
||||
|
||||
10
src/containers/Preferences/Warehouses/WarehousesAlerts.js
Normal file
10
src/containers/Preferences/Warehouses/WarehousesAlerts.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
|
||||
const WarehouseDeleteAlert = React.lazy(() =>
|
||||
import('../../Alerts/Warehouses/WarehouseDeleteAlert'),
|
||||
);
|
||||
|
||||
/**
|
||||
* Warehouses alerts.
|
||||
*/
|
||||
export default [{ name: 'warehouse-delete', component: WarehouseDeleteAlert }];
|
||||
@@ -1,74 +1,56 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { ContextMenu2 } from '@blueprintjs/popover2';
|
||||
|
||||
import { WarehouseContextMenu, WarehousesGrid } from './components';
|
||||
|
||||
import withAlertsActions from '../../Alert/withAlertActions';
|
||||
import withDialogActions from '../../Dialog/withDialogActions';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouse grid items.
|
||||
* @returns
|
||||
*/
|
||||
function WarehousesGridItems({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
// #withDialogActions
|
||||
openDialog,
|
||||
|
||||
warehouse,
|
||||
}) {
|
||||
// Handle edit warehouse.
|
||||
const handleEditWarehouse = () => {
|
||||
openDialog('warehouse-form', { warehouseId: warehouse.id, action: 'edit' });
|
||||
};
|
||||
|
||||
// Handle delete warehouse.
|
||||
const handleDeleteWarehouse = () => {
|
||||
openAlert('warehouse-delete', { warehouseId: warehouse.id });
|
||||
};
|
||||
|
||||
function WarehousesGrid({ warehouse }) {
|
||||
return (
|
||||
<WarehouseGrid>
|
||||
<WarehouseHeader>
|
||||
<WarehouseTitle>{warehouse.title}</WarehouseTitle>
|
||||
<WarehouseCode>{warehouse.code}</WarehouseCode>
|
||||
</WarehouseHeader>
|
||||
<WarehouseInfoItem>{warehouse.city}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.country}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.email}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.phone}</WarehouseInfoItem>
|
||||
</WarehouseGrid>
|
||||
<ContextMenu2
|
||||
content={
|
||||
<WarehouseContextMenu
|
||||
onEditClick={handleEditWarehouse}
|
||||
onDeleteClick={handleDeleteWarehouse}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<WarehousesGrid warehouse={warehouse} />
|
||||
</ContextMenu2>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Warehouse Grid.
|
||||
* @returns
|
||||
*/
|
||||
function WarehousesGridItems({ warehouses }) {
|
||||
return warehouses.map((warehouse) => (
|
||||
<WarehousesGrid warehouse={warehouse} />
|
||||
));
|
||||
}
|
||||
export default WarehousesGridItems;
|
||||
export default compose(
|
||||
withAlertsActions,
|
||||
withDialogActions,
|
||||
)(WarehousesGridItems);
|
||||
|
||||
const WarehouseGrid = styled.div`
|
||||
const WarehouseGridWrap = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 3px;
|
||||
width: 300px; // 453px
|
||||
height: 160px; //225px
|
||||
background: #fff;
|
||||
margin: 5px;
|
||||
padding: 16px 12px 10px;
|
||||
border: 1px solid #c8cad0; //#CFD1D6
|
||||
transition: all 0.1s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
border-color: #0153cc;
|
||||
}
|
||||
`;
|
||||
|
||||
const WarehouseTitle = styled.div`
|
||||
font-size: 14px; //22px
|
||||
font-style: inherit;
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
`;
|
||||
|
||||
const WarehouseHeader = styled.div`
|
||||
margin: 4px 0px 15px;
|
||||
`;
|
||||
|
||||
const WarehouseCode = styled.div`
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
color: #6b7176;
|
||||
`;
|
||||
|
||||
const WarehouseInfoItem = styled.div`
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
line-height: 1.3rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin: 0;
|
||||
flex-wrap: wrap;
|
||||
margin: 15px;
|
||||
`;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
|
||||
import Warehouses from './Warehouses';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Warehouses List.
|
||||
* @returns
|
||||
*/
|
||||
function WarehousesList({
|
||||
// #withDashboardActions
|
||||
changePreferencesPageTitle,
|
||||
}) {
|
||||
React.useEffect(() => {
|
||||
changePreferencesPageTitle(intl.get('warehouses.label'));
|
||||
}, [changePreferencesPageTitle]);
|
||||
|
||||
return <Warehouses />;
|
||||
}
|
||||
|
||||
export default compose(withDashboardActions)(WarehousesList);
|
||||
@@ -1,7 +1,9 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import styled from 'styled-components';
|
||||
import { useWarehouses } from 'hooks/query';
|
||||
import PreferencesPageLoader from '../PreferencesPageLoader';
|
||||
|
||||
const WarehousesContext = React.createContext();
|
||||
|
||||
@@ -9,12 +11,24 @@ const WarehousesContext = React.createContext();
|
||||
* Warehouses data provider.
|
||||
*/
|
||||
function WarehousesProvider({ ...props }) {
|
||||
// Fetch warehouses list.
|
||||
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses();
|
||||
|
||||
// Provider state.
|
||||
const provider = {};
|
||||
const provider = {
|
||||
warehouses,
|
||||
isWarehouesLoading,
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PREFERENCES_PAGE_INSIDE_CONTENT)}>
|
||||
<WarehousesContext.Provider value={provider} {...props} />
|
||||
<WarehousePreference>
|
||||
{isWarehouesLoading ? (
|
||||
<PreferencesPageLoader />
|
||||
) : (
|
||||
<WarehousesContext.Provider value={provider} {...props} />
|
||||
)}
|
||||
</WarehousePreference>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -22,3 +36,9 @@ function WarehousesProvider({ ...props }) {
|
||||
const useWarehousesContext = () => React.useContext(WarehousesContext);
|
||||
|
||||
export { WarehousesProvider, useWarehousesContext };
|
||||
|
||||
const WarehousePreference = styled.div`
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin: 15px;
|
||||
`;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { Menu, MenuItem, MenuDivider, Intent } from '@blueprintjs/core';
|
||||
import { If, Icon, Can } from '../../../components';
|
||||
@@ -35,3 +36,64 @@ export function WarehouseContextMenu({
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
export function WarehousesGrid({ warehouse }) {
|
||||
return (
|
||||
<WarehouseGrid>
|
||||
<WarehouseHeader>
|
||||
<WarehouseTitle>{warehouse.name}</WarehouseTitle>
|
||||
<WarehouseCode>{warehouse.code}</WarehouseCode>
|
||||
</WarehouseHeader>
|
||||
<WarehouseInfoItem>{warehouse.city}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.country}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.email}</WarehouseInfoItem>
|
||||
<WarehouseInfoItem>{warehouse.phone_number}</WarehouseInfoItem>
|
||||
</WarehouseGrid>
|
||||
);
|
||||
}
|
||||
|
||||
const WarehouseGrid = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border-radius: 3px;
|
||||
width: 280px; // 453px
|
||||
height: 160px; //225px
|
||||
background: #fff;
|
||||
margin: 5px;
|
||||
padding: 16px 12px 10px;
|
||||
border: 1px solid #c8cad0; //#CFD1D6
|
||||
transition: all 0.1s ease-in-out;
|
||||
|
||||
&:hover {
|
||||
border-color: #0153cc;
|
||||
}
|
||||
`;
|
||||
|
||||
const WarehouseTitle = styled.div`
|
||||
font-size: 14px; //22px
|
||||
font-style: inherit;
|
||||
color: #000;
|
||||
white-space: nowrap;
|
||||
font-weight: 500;
|
||||
line-height: 1;
|
||||
`;
|
||||
|
||||
const WarehouseHeader = styled.div`
|
||||
margin: 4px 0px 15px;
|
||||
`;
|
||||
|
||||
const WarehouseCode = styled.div`
|
||||
display: inline-block;
|
||||
font-size: 11px;
|
||||
color: #6b7176;
|
||||
`;
|
||||
|
||||
const WarehouseInfoItem = styled.div`
|
||||
display: inline-block;
|
||||
font-size: 12px;
|
||||
color: #000;
|
||||
line-height: 1.3rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin: 0;
|
||||
`;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { WarehousesProvider } from './WarehousesProvider';
|
||||
import Warehouses from './WarehousesList';
|
||||
import Warehouses from './Warehouses';
|
||||
|
||||
/**
|
||||
* Warehouses Preferences.
|
||||
|
||||
Reference in New Issue
Block a user