+
-
{/* Item type */}
+
}
inline={true}
>
@@ -299,7 +343,7 @@ const ItemForm = ({
{...getFieldProps('type')}
/>
-
+
{/* Item name */}
}
@@ -307,7 +351,7 @@ const ItemForm = ({
className={'form-group--item-name'}
intent={errors.name && touched.name && Intent.DANGER}
helperText={
-
+
}
inline={true}
>
@@ -324,7 +368,9 @@ const ItemForm = ({
labelInfo={infoIcon}
className={'form-group--item-sku'}
intent={errors.sku && touched.sku && Intent.DANGER}
- helperText={}
+ helperText={
+
+ }
inline={true}
>
+
}
className={classNames(
'form-group--select-list',
'form-group--category',
- Classes.FILL
+ Classes.FILL,
)}
>
}
labelProp={'name'}
/>
-
+
{/* Active checkbox */}
}
+ label={}
defaultChecked={values.active}
{...getFieldProps('active')}
/>
@@ -395,14 +439,18 @@ const ItemForm = ({
-
+
+
+
}
+ label={}
className={'form-group--item-selling-price'}
- intent={errors.selling_price && touched.selling_price && Intent.DANGER}
+ intent={
+ errors.selling_price && touched.selling_price && Intent.DANGER
+ }
helperText={
-
+
}
inline={true}
>
@@ -419,7 +467,7 @@ const ItemForm = ({
}}
/>
-
+
{/* Selling account */}
}
@@ -431,12 +479,12 @@ const ItemForm = ({
Intent.DANGER
}
helperText={
-
+
}
className={classNames(
'form-group--sell-account',
'form-group--select-list',
- Classes.FILL
+ Classes.FILL,
)}
>
}
labelProp={'name'}
/>
@@ -456,7 +502,9 @@ const ItemForm = ({
-
+
+
+
{/* Cost price */}
+
}
inline={true}
>
@@ -490,12 +538,12 @@ const ItemForm = ({
Intent.DANGER
}
helperText={
-
+
}
className={classNames(
'form-group--cost-account',
'form-group--select-list',
- Classes.FILL
+ Classes.FILL,
)}
>
}
+ defaultText={}
labelProp={'name'}
selectedItem={values.cost_account_id}
selectedItemProp={'id'}
@@ -521,18 +568,23 @@ const ItemForm = ({
}
+ label={}
inline={true}
intent={
errors.inventory_account_id &&
touched.inventory_account_id &&
Intent.DANGER
}
- helperText={}
+ helperText={
+
+ }
className={classNames(
'form-group--item-inventory_account',
'form-group--select-list',
- Classes.FILL
+ Classes.FILL,
)}
>
}
labelProp={'name'}
selectedItem={values.inventory_account_id}
- selectedItemProp={'id'} />
+ selectedItemProp={'id'}
+ />
}
+ label={}
className={'form-group--item-stock'}
inline={true}
>
@@ -561,28 +613,20 @@ const ItemForm = ({
-
-
+
+
);
};
export default compose(
- withAccounts(({accounts})=>({
+ withAccounts(({ accounts }) => ({
accounts,
})),
withAccountDetail,
diff --git a/client/src/containers/Items/ItemFormPage.js b/client/src/containers/Items/ItemFormPage.js
index 71b95cb9c..2f36f96a8 100644
--- a/client/src/containers/Items/ItemFormPage.js
+++ b/client/src/containers/Items/ItemFormPage.js
@@ -1,5 +1,5 @@
-import React, {useCallback } from 'react';
-import { useParams,useHistory } from 'react-router-dom';
+import React, { useCallback } from 'react';
+import { useParams, useHistory } from 'react-router-dom';
import { useQuery } from 'react-query';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
@@ -12,7 +12,6 @@ import withItemsActions from './withItemsActions';
import { compose } from 'utils';
-
const ItemFormContainer = ({
// #withDashboardActions
changePageTitle,
@@ -29,35 +28,43 @@ const ItemFormContainer = ({
const { id } = useParams();
const history = useHistory();
- const fetchAccounts = useQuery('accounts-list',
- (key) => requestFetchAccounts());
+ const fetchAccounts = useQuery('accounts-list', (key) =>
+ requestFetchAccounts(),
+ );
- const fetchCategories = useQuery('item-categories-list',
- (key) => requestFetchItemCategories());
+ const fetchCategories = useQuery('item-categories-list', (key) =>
+ requestFetchItemCategories(),
+ );
- const fetchItemDetail = useQuery(
- id && ['item-detail-list', id],
- (key) => requestFetchItems());
+ const fetchItemDetail = useQuery(id && ['item-detail-list', id], (key) =>
+ requestFetchItems(),
+ );
-const handleFormSubmit =useCallback((payload)=>{
+ const handleFormSubmit = useCallback(
+ (payload) => {
+ payload.redirect && history.push('/items');
+ },
+ [history],
+ );
- payload.redirect && history.push('/items/new');
-
-},[history])
-
-const handleCancel =useCallback(()=>{
-
- history.push('/items/new');
-},[history])
+ const handleCancel = useCallback(() => {
+ // history.push('/items');
+ history.goBack();
+ }, [history]);
return (
-
+
);
@@ -67,5 +74,5 @@ export default compose(
withDashboardActions,
withAccountsActions,
withItemCategoriesActions,
- withItemsActions
+ withItemsActions,
)(ItemFormContainer);
diff --git a/client/src/containers/Items/ItemsFooter.js b/client/src/containers/Items/ItemsFooter.js
new file mode 100644
index 000000000..57b0e9386
--- /dev/null
+++ b/client/src/containers/Items/ItemsFooter.js
@@ -0,0 +1,56 @@
+import React from 'react';
+import { Intent, Button } from '@blueprintjs/core';
+import { FormattedMessage as T } from 'react-intl';
+
+export default function ItemFloatingFooter({
+ formik: { isSubmitting },
+ onSubmitClick,
+ onCancelClick,
+ itemDetail,
+}) {
+ return (
+
+ );
+}
diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js
index e00255fa8..82c698fbf 100644
--- a/client/src/lang/en/index.js
+++ b/client/src/lang/en/index.js
@@ -438,6 +438,9 @@ export default {
'The expense has been successfully deleted',
the_expenses_has_been_successfully_deleted:
'The expenses has been successfully deleted',
+ once_delete_these_expenses_you_will_not_able_restore_them:
+ "Once you delete these expenses, you won't be able to retrieve them later. Are you sure you want to delete them?",
+
the_expense_id_has_been_published: 'The expense id has been published',
select_beneficiary_account: 'Select Beneficiary Account',
total_amount_equals_zero: 'Total amount equals zero',
diff --git a/client/src/lang/en/locale.js b/client/src/lang/en/locale.js
index 47ba9bba1..395a78ccc 100644
--- a/client/src/lang/en/locale.js
+++ b/client/src/lang/en/locale.js
@@ -8,7 +8,7 @@ export const locale = {
notType: ({ path, type, value, originalValue }) => {
let isCast = originalValue != null && originalValue !== value;
let msg =
- `${path} must beeeeee a \`${type}\` type, ` +
+ `${path} must be a \`${type}\` type, ` +
`but the final value was: \`${printValue(value, true)}\`` +
(isCast
? ` (cast from the value \`${printValue(originalValue, true)}\`).`
diff --git a/client/src/store/customers/customers.actions.js b/client/src/store/customers/customers.actions.js
index ab705bc92..6e2a131a5 100644
--- a/client/src/store/customers/customers.actions.js
+++ b/client/src/store/customers/customers.actions.js
@@ -107,3 +107,19 @@ export const deleteCustomer = ({ id }) => {
});
};
+export const deleteBulkCustomers = ({ ids }) => {
+ return (dispatch) =>
+ new Promise((resolve, reject) => {
+ ApiService.delete('customers', { params: { ids } })
+ .then((response) => {
+ dispatch({
+ type: t.CUSTOMERS_BULK_DELETE,
+ payload: { ids },
+ });
+ resolve(response);
+ })
+ .catch((error) => {
+ reject(error.response.data.errors || []);
+ });
+ });
+};
diff --git a/client/src/store/customers/customers.reducer.js b/client/src/store/customers/customers.reducer.js
index 86d198974..a0ea60a8e 100644
--- a/client/src/store/customers/customers.reducer.js
+++ b/client/src/store/customers/customers.reducer.js
@@ -40,6 +40,17 @@ const customersReducer = createReducer(initialState, {
const { loading } = action.payload;
state.loading = !!loading;
},
+ [t.CUSTOMERS_BULK_DELETE]: (state, action) => {
+ const { ids } = action.payload;
+ const items = { ...state.items };
+
+ ids.forEach((id) => {
+ if (typeof items[id] !== 'undefined') {
+ delete items[id];
+ }
+ });
+ state.items = items;
+ },
});
export default createTableQueryReducers('customers', customersReducer);
diff --git a/client/src/store/customers/customers.type.js b/client/src/store/customers/customers.type.js
index c63620434..81b12d864 100644
--- a/client/src/store/customers/customers.type.js
+++ b/client/src/store/customers/customers.type.js
@@ -4,5 +4,6 @@ export default {
CUSTOMERS_PAGE_SET: 'CUSTOMERS_PAGE_SET',
CUSTOMERS_TABLE_LOADING: 'CUSTOMERS_TABLE_LOADING',
CUSTOMERS_TABLE_QUERIES_ADD: 'CUSTOMERS_TABLE_QUERIES_ADD',
- CUSTOMER_DELETE:'CUSTOMER_DELETE'
+ CUSTOMER_DELETE:'CUSTOMER_DELETE',
+ CUSTOMERS_BULK_DELETE:'CUSTOMERS_BULK_DELETE'
};
diff --git a/client/src/store/expenses/expenses.actions.js b/client/src/store/expenses/expenses.actions.js
index 1f4ac1097..ff271f504 100644
--- a/client/src/store/expenses/expenses.actions.js
+++ b/client/src/store/expenses/expenses.actions.js
@@ -114,7 +114,7 @@ export const deleteExpense = ({ id }) => {
export const deleteBulkExpenses = ({ ids }) => {
return (dispatch) =>
new Promise((resolve, reject) => {
- ApiService.delete('expenses/bulk', { params: { ids } })
+ ApiService.delete('expenses', { params: { ids } })
.then((response) => {
dispatch({
type: t.EXPENSES_BULK_DELETE,
diff --git a/client/src/store/items/items.actions.js b/client/src/store/items/items.actions.js
index 461bd949b..963890492 100644
--- a/client/src/store/items/items.actions.js
+++ b/client/src/store/items/items.actions.js
@@ -2,93 +2,101 @@ import ApiService from 'services/ApiService';
import t from 'store/types';
export const submitItem = ({ form }) => {
- return dispatch => ApiService.post(`items`, form);
+ return (dispatch) => ApiService.post(`items`, form);
};
export const editItem = ({ id, form }) => {
- return dispatch => ApiService.post(`items/${id}`, form);
+ return (dispatch) => ApiService.post(`items/${id}`, form);
};
export const fetchItems = ({ query }) => {
- return (dispatch, getState) => new Promise((resolve, reject) => {
- const pageQuery = getState().items.tableQuery;
+ return (dispatch, getState) =>
+ new Promise((resolve, reject) => {
+ const pageQuery = getState().items.tableQuery;
- dispatch({
- type: t.ITEMS_TABLE_LOADING,
- payload: { loading: true },
- });
- dispatch({
- type: t.SET_DASHBOARD_REQUEST_LOADING,
- });
- ApiService.get(`items`, { params: { ...pageQuery, ...query } }).then(response => {
- dispatch({
- type: t.ITEMS_SET,
- items: response.data.items.results,
- });
- dispatch({
- type: t.ITEMS_PAGE_SET,
- items: response.data.items.results,
- customViewId: response.data.customViewId,
- paginationMeta: response.data.items.pagination,
- });
dispatch({
type: t.ITEMS_TABLE_LOADING,
- payload: { loading: false },
+ payload: { loading: true },
});
dispatch({
- type: t.SET_DASHBOARD_REQUEST_COMPLETED,
+ type: t.SET_DASHBOARD_REQUEST_LOADING,
});
- resolve(response);
- }).catch((error) => {
- dispatch({
- type: t.SET_DASHBOARD_REQUEST_COMPLETED,
- });
- reject(error);
+ ApiService.get(`items`, { params: { ...pageQuery, ...query } })
+ .then((response) => {
+ dispatch({
+ type: t.ITEMS_SET,
+ items: response.data.items.results,
+ });
+ dispatch({
+ type: t.ITEMS_PAGE_SET,
+ items: response.data.items.results,
+ customViewId: response.data.customViewId,
+ paginationMeta: response.data.items.pagination,
+ });
+ dispatch({
+ type: t.ITEMS_TABLE_LOADING,
+ payload: { loading: false },
+ });
+ dispatch({
+ type: t.SET_DASHBOARD_REQUEST_COMPLETED,
+ });
+ resolve(response);
+ })
+ .catch((error) => {
+ dispatch({
+ type: t.SET_DASHBOARD_REQUEST_COMPLETED,
+ });
+ reject(error);
+ });
});
- });
};
export const fetchItem = ({ id }) => {
- return dispatch =>
+ return (dispatch) =>
new Promise((resolve, reject) => {
ApiService.get(`items/${id}`)
- .then(response => {
+ .then((response) => {
dispatch({
type: t.ITEM_SET,
- item: response.data.item
+ item: response.data.item,
});
})
- .catch(error => {
+ .catch((error) => {
reject(error);
});
});
};
export const deleteItem = ({ id }) => {
- return dispatch => new Promise((resolve, reject) => {
- ApiService.delete(`items/${id}`)
- .then((response) => {
- dispatch({
- type: t.ITEM_DELETE,
- payload: { id },
+ return (dispatch) =>
+ new Promise((resolve, reject) => {
+ ApiService.delete(`items/${id}`)
+ .then((response) => {
+ dispatch({
+ type: t.ITEM_DELETE,
+ payload: { id },
+ });
+ resolve(response);
+ })
+ .catch((error) => {
+ reject(error);
});
- resolve(response);
- }).catch((error) => { reject(error); });
- });
+ });
};
-
-
export const deleteBulkItems = ({ ids }) => {
- return dispatch => new Promise((resolve, reject) => {
- ApiService.delete(`items`, { params: { ids }}).then((response) => {
- dispatch({
- type: t.ITEMS_BULK_DELETE,
- payload: { ids }
- });
- resolve(response);
- }).catch((error) => {
- reject(error);
+ return (dispatch) =>
+ new Promise((resolve, reject) => {
+ ApiService.delete('items', { params: { ids } })
+ .then((response) => {
+ dispatch({
+ type: t.ITEMS_BULK_DELETE,
+ payload: { ids },
+ });
+ resolve(response);
+ })
+ .catch((error) => {
+ reject(error.response.data.errors || []);
+ });
});
- });
};
diff --git a/client/src/store/items/items.reducer.js b/client/src/store/items/items.reducer.js
index 25fecd60e..5ea3a6c55 100644
--- a/client/src/store/items/items.reducer.js
+++ b/client/src/store/items/items.reducer.js
@@ -1,8 +1,6 @@
import t from 'store/types';
import { createReducer } from '@reduxjs/toolkit';
-import {
- getItemsViewPages,
-} from 'store/items/items.selectors';
+import { getItemsViewPages } from 'store/items/items.selectors';
import { createTableQueryReducers } from 'store/queryReducers';
const initialState = {
@@ -20,7 +18,7 @@ const itemsReducer = createReducer(initialState, {
[t.ITEMS_SET]: (state, action) => {
const _items = {};
- action.items.forEach(item => {
+ action.items.forEach((item) => {
_items[item.id] = item;
});
state.items = {
@@ -43,11 +41,11 @@ const itemsReducer = createReducer(initialState, {
if (typeof itemRelation === 'undefined') {
state.itemsRelation[item.id] = [];
}
- const filteredRelation = state.itemsRelation[item.id]
- .filter((relation) => (
+ const filteredRelation = state.itemsRelation[item.id].filter(
+ (relation) =>
relation.viewId === viewId &&
- relation.pageNumber === paginationMeta.page
- ));
+ relation.pageNumber === paginationMeta.page,
+ );
filteredRelation.push({
viewId,
@@ -61,10 +59,10 @@ const itemsReducer = createReducer(initialState, {
pages: {
...viewPages,
[paginationMeta.page]: {
- ids: items.map(i => i.id),
+ ids: items.map((i) => i.id),
meta: paginationMeta,
},
- },
+ },
};
},
@@ -93,9 +91,21 @@ const itemsReducer = createReducer(initialState, {
state.loading = !!loading;
},
- [t.ITEMS_SET_CURRENT_VIEW]: (state, action) => {
+ [t.ITEMS_SET_CURRENT_VIEW]: (state, action) => {
state.currentViewId = action.currentViewId;
},
+
+ [t.ITEMS_BULK_DELETE]: (state, action) => {
+ const { ids } = action.payload;
+ const items = { ...state.items };
+
+ ids.forEach((id) => {
+ if (typeof items[id] !== 'undefined') {
+ delete items[id];
+ }
+ });
+ state.items = items;
+ },
});
export default createTableQueryReducers('items', itemsReducer);