mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 04:10:32 +00:00
Fix bugs.
This commit is contained in:
@@ -35,7 +35,7 @@ export default function SidebarMenu() {
|
||||
dropdownType={item.dropdownType || 'collapse'}
|
||||
caretIconSize={15}
|
||||
onClick={handleItemClick}
|
||||
// callapseActive={!!isActive}
|
||||
callapseActive={!!isActive}
|
||||
className={classNames({ 'is-active': isActive })} />
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import If from './Utils/If';
|
||||
import Money from './Money';
|
||||
import Icon from './Icon';
|
||||
// import Choose from './Utils/Choose';
|
||||
// import For from './Utils/For';
|
||||
|
||||
export {
|
||||
If,
|
||||
Money,
|
||||
Icon,
|
||||
// Choose,
|
||||
// For,
|
||||
};
|
||||
@@ -132,7 +132,7 @@ function MakeJournalEntriesForm({
|
||||
initialValues: {
|
||||
...initialValues,
|
||||
},
|
||||
onSubmit: async (values, { setErrors, setSubmitting }) => {
|
||||
onSubmit: async (values, { setErrors, setSubmitting, resetForm }) => {
|
||||
const entries = values.entries.filter((entry) => (
|
||||
(entry.credit || entry.debit)
|
||||
));
|
||||
@@ -171,11 +171,12 @@ function MakeJournalEntriesForm({
|
||||
setSubmitting(false);
|
||||
saveInvokeSubmit({ action: 'update', ...payload });
|
||||
clearSavedMediaIds([]);
|
||||
resetForm();
|
||||
resolve(response);
|
||||
}).catch((errors) => {
|
||||
if (errors.find(e => e.type === 'JOURNAL.NUMBER.ALREADY.EXISTS')) {
|
||||
setErrors({
|
||||
journal_number: 'Journal number is already used.',
|
||||
journal_number: formatMessage({ id: 'journal_number_is_already_used' }),
|
||||
});
|
||||
}
|
||||
setSubmitting(false);
|
||||
@@ -194,11 +195,12 @@ function MakeJournalEntriesForm({
|
||||
setSubmitting(false);
|
||||
saveInvokeSubmit({ action: 'new', ...payload });
|
||||
clearSavedMediaIds();
|
||||
resetForm();
|
||||
resolve(response);
|
||||
}).catch((errors) => {
|
||||
if (errors.find(e => e.type === 'JOURNAL.NUMBER.ALREADY.EXISTS')) {
|
||||
setErrors({
|
||||
journal_number: 'Journal number is already used.',
|
||||
journal_number: formatMessage({ id: 'journal_number_is_already_used' }),
|
||||
});
|
||||
}
|
||||
setSubmitting(false);
|
||||
|
||||
@@ -27,6 +27,7 @@ import withManualJournalsActions from 'containers/Accounting/withManualJournalsA
|
||||
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
|
||||
|
||||
function ManualJournalActionsBar({
|
||||
// #withResourceDetail
|
||||
resourceName = 'manual_journal',
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
MenuItem,
|
||||
MenuDivider,
|
||||
Position,
|
||||
Tag,
|
||||
} from '@blueprintjs/core';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
@@ -145,7 +146,9 @@ function ManualJournalsDataTable({
|
||||
id: 'status',
|
||||
Header: formatMessage({ id: 'status' }),
|
||||
accessor: (r) => {
|
||||
return r.status ? 'Published' : 'Draft';
|
||||
return r.status
|
||||
? <Tag minimal={true}><T id={'published'} /></Tag> :
|
||||
<Tag minimal={true} intent={Intent.WARNING}><T id={'draft'} /></Tag>;
|
||||
},
|
||||
disableResizing: true,
|
||||
width: 100,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
||||
import { Route, Switch, useHistory } from 'react-router-dom';
|
||||
import { useQuery } from 'react-query';
|
||||
import { Alert, Intent } from '@blueprintjs/core';
|
||||
@@ -36,17 +36,20 @@ function ManualJournalsTable({
|
||||
addManualJournalsTableQueries,
|
||||
}) {
|
||||
const history = useHistory();
|
||||
|
||||
const [deleteManualJournal, setDeleteManualJournal] = useState(false);
|
||||
const [deleteBulk, setDeleteBulk] = useState(false);
|
||||
const [selectedRows, setSelectedRows] = useState([]);
|
||||
const [bulkDelete, setBulkDelete] = useState(false);
|
||||
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
const fetchViews = useQuery('journals-resource-views', () => {
|
||||
return requestFetchResourceViews('manual_journals');
|
||||
});
|
||||
|
||||
const fetchManualJournals = useQuery('manual-journals-table', () =>
|
||||
requestFetchManualJournalsTable()
|
||||
);
|
||||
const fetchManualJournals = useQuery('manual-journals-table',
|
||||
() => requestFetchManualJournalsTable());
|
||||
|
||||
useEffect(() => {
|
||||
changePageTitle(formatMessage({id:'manual_journals'}));
|
||||
@@ -68,11 +71,24 @@ function ManualJournalsTable({
|
||||
// Handle confirm delete manual journal.
|
||||
const handleConfirmManualJournalDelete = useCallback(() => {
|
||||
requestDeleteManualJournal(deleteManualJournal.id).then(() => {
|
||||
AppToaster.show({
|
||||
message: formatMessage({
|
||||
id: 'the_journal_has_been_successfully_deleted',
|
||||
}, {
|
||||
number: deleteManualJournal.journal_number,
|
||||
}),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setDeleteManualJournal(false);
|
||||
AppToaster.show({ message: 'the_manual_Journal_has_been_deleted' });
|
||||
});
|
||||
}, [deleteManualJournal, requestDeleteManualJournal]);
|
||||
|
||||
|
||||
// Calculates the selected rows count.
|
||||
const selectedRowsCount = useMemo(
|
||||
() => Object.values(selectedRows).length,
|
||||
[selectedRows]);
|
||||
|
||||
const handleBulkDelete = useCallback(
|
||||
(accountsIds) => {
|
||||
setBulkDelete(accountsIds);
|
||||
@@ -80,17 +96,26 @@ function ManualJournalsTable({
|
||||
[setBulkDelete]
|
||||
);
|
||||
|
||||
// Handle confirm journals bulk delete.
|
||||
const handleConfirmBulkDelete = useCallback(() => {
|
||||
requestDeleteBulkManualJournals(bulkDelete)
|
||||
.then(() => {
|
||||
AppToaster.show({
|
||||
message: formatMessage({
|
||||
id: 'the_journals_has_been_successfully_deleted',
|
||||
}, {
|
||||
count: selectedRowsCount,
|
||||
}),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
setBulkDelete(false);
|
||||
AppToaster.show({ message: 'the_accounts_have_been_deleted' });
|
||||
})
|
||||
.catch((error) => {
|
||||
setBulkDelete(false);
|
||||
});
|
||||
}, [requestDeleteBulkManualJournals, bulkDelete]);
|
||||
|
||||
// Handle cancel bulk delete alert.
|
||||
const handleCancelBulkDelete = useCallback(() => {
|
||||
setBulkDelete(false);
|
||||
}, []);
|
||||
@@ -104,28 +129,23 @@ function ManualJournalsTable({
|
||||
|
||||
// Handle filter change to re-fetch data-table.
|
||||
const handleFilterChanged = useCallback(() => {
|
||||
fetchManualJournals.refetch();
|
||||
|
||||
}, [fetchManualJournals]);
|
||||
|
||||
// Handle view change to re-fetch data table.
|
||||
const handleViewChanged = useCallback(() => {
|
||||
fetchManualJournals.refetch();
|
||||
|
||||
}, [fetchManualJournals]);
|
||||
|
||||
// Handle fetch data of manual jouranls datatable.
|
||||
const handleFetchData = useCallback(
|
||||
({ pageIndex, pageSize, sortBy }) => {
|
||||
addManualJournalsTableQueries({
|
||||
...(sortBy.length > 0
|
||||
? {
|
||||
column_sort_by: sortBy[0].id,
|
||||
sort_order: sortBy[0].desc ? 'desc' : 'asc',
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
},
|
||||
[addManualJournalsTableQueries]
|
||||
);
|
||||
const handleFetchData = useCallback(({ pageIndex, pageSize, sortBy }) => {
|
||||
addManualJournalsTableQueries({
|
||||
...(sortBy.length > 0) ? {
|
||||
column_sort_by: sortBy[0].id,
|
||||
sort_order: sortBy[0].desc ? 'desc' : 'asc',
|
||||
} : {},
|
||||
});
|
||||
}, [addManualJournalsTableQueries]);
|
||||
|
||||
const handlePublishJournal = useCallback(
|
||||
(journal) => {
|
||||
@@ -165,45 +185,40 @@ function ManualJournalsTable({
|
||||
'/dashboard/accounting/manual-journals/:custom_view_id/custom_view',
|
||||
'/dashboard/accounting/manual-journals',
|
||||
]}>
|
||||
<ManualJournalsViewTabs />
|
||||
|
||||
<ManualJournalsDataTable
|
||||
onDeleteJournal={handleDeleteJournal}
|
||||
onFetchData={handleFetchData}
|
||||
onEditJournal={handleEditJournal}
|
||||
onPublishJournal={handlePublishJournal}
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
/>
|
||||
</Route>
|
||||
</Switch>
|
||||
|
||||
<ManualJournalsDataTable
|
||||
onDeleteJournal={handleDeleteJournal}
|
||||
onFetchData={handleFetchData}
|
||||
onEditJournal={handleEditJournal}
|
||||
onPublishJournal={handlePublishJournal}
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
/>
|
||||
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'move_to_trash'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon='trash'
|
||||
intent={Intent.DANGER}
|
||||
isOpen={deleteManualJournal}
|
||||
onCancel={handleCancelManualJournalDelete}
|
||||
onConfirm={handleConfirmManualJournalDelete}
|
||||
>
|
||||
<p>
|
||||
Are you sure you want to move <b>filename</b> to Trash? You will be
|
||||
able to restore it later, but it will become private to you.
|
||||
</p>
|
||||
<p><T id={'once_delete_this_journal_category_you_will_able_to_restore_it'} /></p>
|
||||
</Alert>
|
||||
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'move_to_trash'} />}
|
||||
confirmButtonText={<T id={'delete_count'} values={{ count: selectedRowsCount }} />}
|
||||
icon='trash'
|
||||
intent={Intent.DANGER}
|
||||
isOpen={bulkDelete}
|
||||
onCancel={handleCancelBulkDelete}
|
||||
onConfirm={handleConfirmBulkDelete}
|
||||
>
|
||||
<p>
|
||||
Are you sure you want to move <b>filename</b> to Trash? You will be
|
||||
able to restore it later, but it will become private to you.
|
||||
</p>
|
||||
<p><T id={'once_delete_these_journalss_you_will_not_able_restore_them'} /></p>
|
||||
</Alert>
|
||||
</DashboardPageContent>
|
||||
</DashboardInsider>
|
||||
|
||||
@@ -8,12 +8,14 @@ import {
|
||||
Tab,
|
||||
Button,
|
||||
} from '@blueprintjs/core';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import Icon from 'components/Icon';
|
||||
import { useParams, withRouter } from 'react-router-dom';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { compose } from 'utils';
|
||||
import { connect } from 'react-redux';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
|
||||
import { useUpdateEffect } from 'hooks';
|
||||
import { compose } from 'utils';
|
||||
import Icon from 'components/Icon';
|
||||
|
||||
import withManualJournals from './withManualJournals';
|
||||
import withManualJournalsActions from './withManualJournalsActions';
|
||||
@@ -85,10 +87,14 @@ function ManualJournalsViewTabs({
|
||||
<Tab
|
||||
id='all'
|
||||
title={
|
||||
<Link to={`/dashboard/accounting/manual-journals`}>All</Link>
|
||||
<Link to={`/dashboard/accounting/manual-journals`}>
|
||||
<T id={'all'} />
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
{tabs}
|
||||
|
||||
{ tabs }
|
||||
|
||||
<Button
|
||||
className='button--new-view'
|
||||
icon={<Icon icon='plus' />}
|
||||
@@ -101,7 +107,16 @@ function ManualJournalsViewTabs({
|
||||
);
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => ({
|
||||
// Mapping view id from matched route params.
|
||||
viewId: ownProps.match.params.custom_view_id,
|
||||
});
|
||||
|
||||
const withManualJournalsViewTabs = connect(mapStateToProps);
|
||||
|
||||
export default compose(
|
||||
withRouter,
|
||||
withManualJournalsViewTabs,
|
||||
withManualJournals(({ manualJournalsViews }) => ({
|
||||
manualJournalsViews,
|
||||
})),
|
||||
|
||||
@@ -70,7 +70,6 @@ function AccountsChart({
|
||||
const fetchAccountsHook = useQuery(
|
||||
['accounts-table', accountsTableQuery],
|
||||
() => requestFetchAccountsTable(),
|
||||
{ refetchInterval: 3000 }
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -270,8 +269,8 @@ function AccountsChart({
|
||||
</Switch>
|
||||
|
||||
<Alert
|
||||
cancelButtonText="Cancel"
|
||||
confirmButtonText="Delete"
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={deleteAccount}
|
||||
|
||||
@@ -256,7 +256,6 @@ const mapStateToProps = (state, props) => {
|
||||
return {
|
||||
name: 'item-category-form',
|
||||
payload: {action: 'new', id: null, ...dialogPayload},
|
||||
|
||||
itemCategoryId: dialogPayload?.id || null,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useQuery } from 'react-query';
|
||||
import { Alert, Intent } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T, FormattedHTMLMessage, useIntl } from 'react-intl';
|
||||
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import ItemCategoriesDataTable from 'containers/Items/ItemCategoriesTable';
|
||||
import ItemsCategoryActionsBar from 'containers/Items/ItemsCategoryActionsBar';
|
||||
|
||||
import withDialog from 'connectors/Dialog.connector';
|
||||
import withDashboardActions from 'containers/Dashboard/withDashboard';
|
||||
import withItemCategoriesActions from 'containers/Items/withItemCategoriesActions';
|
||||
|
||||
import { compose } from 'utils';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
|
||||
|
||||
const ItemCategoryList = ({
|
||||
@@ -18,18 +22,27 @@ const ItemCategoryList = ({
|
||||
|
||||
// #withItemCategoriesActions
|
||||
requestFetchItemCategories,
|
||||
requestDeleteItemCategory,
|
||||
|
||||
// #withDialog
|
||||
openDialog,
|
||||
}) => {
|
||||
const { id } = useParams();
|
||||
|
||||
const [selectedRows, setSelectedRows] = useState([]);
|
||||
const {formatMessage} =useIntl()
|
||||
const [filter, setFilter] = useState({});
|
||||
const [deleteCategory, setDeleteCategory] = useState(false);
|
||||
|
||||
const {formatMessage} = useIntl();
|
||||
|
||||
useEffect(() => {
|
||||
id
|
||||
? changePageTitle(formatMessage({id:'edit_category_details'}))
|
||||
: changePageTitle(formatMessage({id:'category_list'}));
|
||||
? changePageTitle(formatMessage({ id:'edit_category_details' }))
|
||||
: changePageTitle(formatMessage({ id:'category_list' }));
|
||||
}, []);
|
||||
|
||||
const fetchCategories = useQuery('items-categories-table',
|
||||
() => { requestFetchItemCategories(); });
|
||||
const fetchCategories = useQuery(['items-categories-table', filter],
|
||||
(key, query) => requestFetchItemCategories(query));
|
||||
|
||||
const handleFilterChanged = useCallback(() => {
|
||||
|
||||
@@ -40,6 +53,40 @@ const ItemCategoryList = ({
|
||||
setSelectedRows(itemCategories);
|
||||
}, [setSelectedRows]);
|
||||
|
||||
// Handle fetch data of accounts datatable.
|
||||
const handleFetchData = useCallback(({ pageIndex, pageSize, sortBy }) => {
|
||||
setFilter({
|
||||
...(sortBy.length > 0
|
||||
? {
|
||||
column_sort_by: sortBy[0].id,
|
||||
sort_order: sortBy[0].desc ? 'desc' : 'asc',
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleDeleteCategory = (itemCategory) => { setDeleteCategory(itemCategory); };
|
||||
const handleCancelItemDelete = () => { setDeleteCategory(false) };
|
||||
|
||||
// Handle alert confirm delete item category.
|
||||
const handleConfirmItemDelete = () => {
|
||||
requestDeleteItemCategory(deleteCategory.id).then(() => {
|
||||
setDeleteCategory(false);
|
||||
AppToaster.show({
|
||||
message: formatMessage({
|
||||
id: 'the_item_category_has_been_successfully_deleted'
|
||||
}),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
}).catch(() => {
|
||||
setDeleteCategory(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handleEditCategory = (category) => {
|
||||
openDialog('item-category-form', { action: 'edit', id: category.id });
|
||||
};
|
||||
|
||||
return (
|
||||
<DashboardInsider name={'item-category-list'}>
|
||||
<ItemsCategoryActionsBar
|
||||
@@ -47,12 +94,31 @@ const ItemCategoryList = ({
|
||||
selectedRows={selectedRows} />
|
||||
|
||||
<ItemCategoriesDataTable
|
||||
onSelectedRowsChange={handleSelectedRowsChange} />
|
||||
onSelectedRowsChange={handleSelectedRowsChange}
|
||||
onFetchData={handleFetchData}
|
||||
onEditCategory={handleEditCategory}
|
||||
onDeleteCategory={handleDeleteCategory} />
|
||||
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'delete'} />}
|
||||
icon="trash"
|
||||
intent={Intent.DANGER}
|
||||
isOpen={deleteCategory}
|
||||
onCancel={handleCancelItemDelete}
|
||||
onConfirm={handleConfirmItemDelete}
|
||||
>
|
||||
<p>
|
||||
<FormattedHTMLMessage
|
||||
id={'once_delete_this_item_category_you_will_able_to_restore_it'} />
|
||||
</p>
|
||||
</Alert>
|
||||
</DashboardInsider>
|
||||
);
|
||||
};
|
||||
|
||||
export default compose(
|
||||
withDashboardActions,
|
||||
withDialog,
|
||||
withItemCategoriesActions,
|
||||
)(ItemCategoryList);
|
||||
|
||||
@@ -13,7 +13,6 @@ import LoadingIndicator from 'components/LoadingIndicator';
|
||||
import { compose } from 'utils';
|
||||
import DataTable from 'components/DataTable';
|
||||
|
||||
import DialogConnect from 'connectors/Dialog.connector';
|
||||
import withItemCategories from './withItemCategories';
|
||||
|
||||
|
||||
@@ -25,26 +24,21 @@ const ItemsCategoryList = ({
|
||||
onFetchData,
|
||||
onDeleteCategory,
|
||||
onEditCategory,
|
||||
openDialog,
|
||||
onSelectedRowsChange,
|
||||
}) => {
|
||||
|
||||
const {formatMessage} = useIntl();
|
||||
const handelEditCategory = (category) => () => {
|
||||
openDialog('item-form', { action: 'edit', id: category.id });
|
||||
onEditCategory(category.id);
|
||||
};
|
||||
|
||||
const handleDeleteCategory = (category) => () => {
|
||||
onDeleteCategory(category);
|
||||
};
|
||||
const handelEditCategory = (category) => { onEditCategory(category); };
|
||||
const handleDeleteCategory = (category) => { onDeleteCategory(category); };
|
||||
|
||||
const actionMenuList = (category) => (
|
||||
<Menu>
|
||||
<MenuItem text={<T id={'edit_category'} />} onClick={handelEditCategory(category)} />
|
||||
<MenuItem
|
||||
text={<T id={'edit_category'} />}
|
||||
onClick={() => handelEditCategory(category)} />
|
||||
<MenuItem
|
||||
text={<T id={'delete_category'}/>}
|
||||
onClick={handleDeleteCategory(category)}
|
||||
onClick={() => handleDeleteCategory(category)}
|
||||
/>
|
||||
</Menu>
|
||||
);
|
||||
@@ -87,8 +81,8 @@ const ItemsCategoryList = ({
|
||||
},
|
||||
], [actionMenuList]);
|
||||
|
||||
const handelFetchData = useCallback(() => {
|
||||
onFetchData && onFetchData();
|
||||
const handelFetchData = useCallback((...params) => {
|
||||
onFetchData && onFetchData(...params);
|
||||
}, []);
|
||||
|
||||
const handleSelectedRowsChange = useCallback((selectedRows) => {
|
||||
@@ -111,7 +105,6 @@ const ItemsCategoryList = ({
|
||||
};
|
||||
|
||||
export default compose(
|
||||
DialogConnect,
|
||||
withItemCategories(({ categoriesList }) => ({
|
||||
categoriesList,
|
||||
})),
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
import { Row, Col } from 'react-grid-system';
|
||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||
import { Select } from '@blueprintjs/select';
|
||||
import { queryCache } from 'react-query';
|
||||
|
||||
import AppToaster from 'components/AppToaster';
|
||||
import AccountsConnect from 'connectors/Accounts.connector';
|
||||
@@ -55,15 +56,12 @@ const ItemForm = ({
|
||||
deleteCallback: requestDeleteMedia,
|
||||
});
|
||||
|
||||
const ItemTypeDisplay = useMemo(
|
||||
() => [
|
||||
{ value: null, label: 'Select Item Type' },
|
||||
{ value: 'service', label: 'Service' },
|
||||
{ value: 'inventory', label: 'Inventory' },
|
||||
{ value: 'non-inventory', label: 'Non-Inventory' },
|
||||
],
|
||||
[]
|
||||
);
|
||||
const ItemTypeDisplay = useMemo(() => [
|
||||
{ value: null, label: 'Select Item Type' },
|
||||
{ value: 'service', label: 'Service' },
|
||||
{ value: 'inventory', label: 'Inventory' },
|
||||
{ value: 'non-inventory', label: 'Non-Inventory' },
|
||||
], []);
|
||||
|
||||
const validationSchema = Yup.object().shape({
|
||||
active: Yup.boolean(),
|
||||
@@ -128,6 +126,8 @@ const ItemForm = ({
|
||||
}),
|
||||
intent: Intent.SUCCESS,
|
||||
});
|
||||
queryCache.removeQueries(['items-table']);
|
||||
history.push('/dashboard/items');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
|
||||
export const mapDispatchToProps = (dispatch) => ({
|
||||
requestSubmitItemCategory: (form) => dispatch(submitItemCategory({ form })),
|
||||
requestFetchItemCategories: () => dispatch(fetchItemCategories()),
|
||||
requestFetchItemCategories: (query) => dispatch(fetchItemCategories({ query })),
|
||||
requestDeleteItemCategory: (id) => dispatch(deleteItemCategory(id)),
|
||||
requestEditItemCategory: (id, form) => dispatch(editItemCategory(id, form)),
|
||||
});
|
||||
|
||||
@@ -102,9 +102,12 @@ export default {
|
||||
save: 'Save',
|
||||
save_as_draft: 'Save as Draft',
|
||||
active: 'Active',
|
||||
draft: 'Draft',
|
||||
published: 'Published',
|
||||
new_item: 'New Item',
|
||||
table_views: 'Table Views',
|
||||
delete: 'Delete',
|
||||
delete_count: 'Delete ({count})',
|
||||
import: 'Import',
|
||||
export: 'Export',
|
||||
filter: 'Filter',
|
||||
@@ -182,6 +185,8 @@ export default {
|
||||
'once_delete_this_account_you_will_able_to_restore_it': `Once you delete this account, you won\'t be able to restore it later. Are you sure you want to delete this account?<br /><br />If you're not sure, you can inactivate this account instead.`,
|
||||
'the_journal_has_been_successfully_created': 'The journal #{number} has been successfully created.',
|
||||
'the_journal_has_been_successfully_edited': 'The journal #{number} has been successfully edited.',
|
||||
'the_journal_has_been_successfully_deleted': 'The journal #{number} has been successfully deleted.',
|
||||
'the_journals_has_been_successfully_deleted': 'The journals {count} have been successfully deleted.',
|
||||
'credit': 'Credit',
|
||||
'debit': 'Debit',
|
||||
'once_delete_this_item_you_will_able_to_restore_it': `Once you delete this item, you won\'t be able to restore the item later. Are you sure you want to delete ?<br /><br />If you're not sure, you can inactivate it instead.`,
|
||||
@@ -192,4 +197,10 @@ export default {
|
||||
'the_custom_view_has_been_successfully_deleted': 'The custom view has been successfully deleted.',
|
||||
'teammate_invited_to_organization_account': 'Your teammate has been invited to the organization account.',
|
||||
'select_account_type': 'Select account type',
|
||||
'the_item_category_has_been_successfully_deleted': 'The item category has been successfully deleted.',
|
||||
'once_delete_this_item_category_you_will_able_to_restore_it': 'Once you delete this item category, you won\'t be able to restore the item later. Are you sure you want to delete?',
|
||||
'once_delete_this_journal_category_you_will_able_to_restore_it': 'Once you delete this journal, you won\'t be able to restore the item later. Are you sure you want to delete?',
|
||||
'all': 'All',
|
||||
'once_delete_these_journalss_you_will_not_able_restore_them': 'Once you delete these journals, you won\'t be able to retrieve them later. Are you sure you want to delete them?',
|
||||
'journal_number_is_already_used': 'Journal number is already used.',
|
||||
};
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
|
||||
import ApiService from 'services/ApiService';
|
||||
|
||||
export const submitInvite = ({ form, token }) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post(`/invite/accept/${token}`, { ...form });
|
||||
};
|
||||
};
|
||||
|
||||
export const submitSendInvite = ({ form }) => {
|
||||
return (dispatch) => {
|
||||
return ApiService.post('invite', { form });
|
||||
};
|
||||
};
|
||||
@@ -7,7 +7,7 @@ export const submitItemCategory = ({ form }) => {
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchItemCategories = () => {
|
||||
export const fetchItemCategories = ({ query }) => {
|
||||
return (dispatch, getState) => new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
@@ -18,7 +18,7 @@ export const fetchItemCategories = () => {
|
||||
loading: true,
|
||||
}
|
||||
});
|
||||
ApiService.get('item_categories')
|
||||
ApiService.get('item_categories', { params: { ...query } })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ITEMS_CATEGORY_LIST_SET,
|
||||
@@ -70,7 +70,7 @@ export const deleteItemCategory = (id) => {
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.CATEGORY_DELETE,
|
||||
id,
|
||||
payload: { id },
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
|
||||
@@ -24,8 +24,10 @@ export default createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.CATEGORY_DELETE]: (state, action) => {
|
||||
if (typeof state.categories[action.id] !== 'undefined') {
|
||||
delete state.categories[action.id];
|
||||
const { id } = action.payload;
|
||||
|
||||
if (typeof state.categories[id] !== 'undefined') {
|
||||
delete state.categories[id];
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -20,8 +20,12 @@ export default createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.CATEGORY_DELETE]: (state, action) => {
|
||||
if (typeof state.categories[action.id] !== 'undefined') {
|
||||
delete state.categories[action.id];
|
||||
const { id } = action.payload;
|
||||
const categories = { ...state.categories };
|
||||
|
||||
if (typeof categories[id] !== 'undefined') {
|
||||
delete categories[id];
|
||||
state.categories = categories;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -65,5 +65,14 @@ export const fetchItem = ({ id }) => {
|
||||
};
|
||||
|
||||
export const deleteItem = ({ id }) => {
|
||||
return dispatch => ApiService.delete(`items/${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); });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -77,14 +77,14 @@ const itemsReducer = createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.ITEM_DELETE]: (state, action) => {
|
||||
const { itemId } = action;
|
||||
const { id } = action.payload;
|
||||
const items = { ...state.items };
|
||||
|
||||
if (state.items[itemId]) {
|
||||
const item = state.items[itemId];
|
||||
const itemPageNumber = item._page_number;
|
||||
|
||||
delete state.items[itemId];
|
||||
if (items[id]) {
|
||||
const item = items[id];
|
||||
|
||||
delete items[id];
|
||||
state.items = items;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
}
|
||||
.status{
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ export default {
|
||||
getList: {
|
||||
validation: [
|
||||
query('column_sort_order').optional().trim().escape(),
|
||||
query('sort_order').optional().isInt(['desc', 'asc']),
|
||||
query('sort_order').optional().trim().escape().isIn(['desc', 'asc']),
|
||||
query('stringified_filter_roles').optional().isJSON(),
|
||||
],
|
||||
async handler(req, res) {
|
||||
|
||||
Reference in New Issue
Block a user