fix: Remove not used files and notes.

This commit is contained in:
Ahmed Bouhuolia
2020-06-13 19:12:24 +02:00
parent a849b9a945
commit ac9c360629
15 changed files with 57 additions and 519 deletions

View File

@@ -30,19 +30,20 @@ import withExpenses from 'containers/Expenses/withExpenses';
import withExpensesActions from 'containers/Expenses/withExpensesActions';
function ExpenseDataTable({
loading,
//#withExpenes
expenses,
expensesLoading,
// #withDashboardActions
changeCurrentView,
changePageSubtitle,
setTopbarEditView,
// #withView
viewMeta,
// #ownProps
loading,
onFetchData,
onEditExpense,
onDeleteExpense,
@@ -119,8 +120,7 @@ function ExpenseDataTable({
),
[handleEditExpense, handleDeleteExpense, handlePublishExpense],
);
console.log(Object.values(expenses), 'ER');
const columns = useMemo(
() => [
{

View File

@@ -2,7 +2,7 @@ import React from 'react';
import { Intent, Button } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
function ExpenseFooter({
export default function ExpenseFooter({
formik: { isSubmitting },
onSubmitClick,
onCancelClick,
@@ -40,6 +40,4 @@ function ExpenseFooter({
</Button>
</div>
);
}
export default ExpenseFooter;
};

View File

@@ -43,6 +43,7 @@ function ExpenseForm({
changePageSubtitle,
//#withExpenseDetail
// @todo expenseDetail to expense
expenseDetail,
// #own Props
@@ -79,6 +80,7 @@ function ExpenseForm({
} else {
changePageTitle(formatMessage({ id: 'new_expense' }));
}
// @todo not functions just states.
}, [changePageTitle, changePageSubtitle, expenseDetail, formatMessage]);
const validationSchema = Yup.object().shape({
@@ -98,11 +100,11 @@ function ExpenseForm({
.label(formatMessage({ id: 'description' })),
publish: Yup.boolean().label(formatMessage({ id: 'publish' })),
categories: Yup.array().of(
Yup.object().shape({
index: Yup.number().nullable(),
amount: Yup.number().nullable(),
// @todo expense_account_id is required.
expense_account_id: Yup.number().nullable(),
description: Yup.string().nullable(),
}),
@@ -135,6 +137,7 @@ function ExpenseForm({
reference_no: '',
currency_code: '',
categories: [
// @todo @mohamed index
defaultCategory,
defaultCategory,
defaultCategory,
@@ -144,7 +147,6 @@ function ExpenseForm({
[defaultCategory],
);
const initialValues = useMemo(
() => ({
...(expenseDetail
@@ -181,7 +183,6 @@ function ExpenseForm({
const categories = values.categories.filter(
(category) => category.amount || category.index,
);
const form = {
...values,
published: payload.publish,
@@ -209,6 +210,7 @@ function ExpenseForm({
resolve(response);
})
.catch((errors) => {
// @todo handle errors.
if (errors.find((e) => e.type === 'TOTAL.AMOUNT.EQUALS.ZERO')) {
}
setErrors(
@@ -255,6 +257,8 @@ function ExpenseForm({
},
});
console.log(formik.errors);
const handleSubmitClick = useCallback(
(payload) => {
setPayload(payload);
@@ -280,6 +284,7 @@ function ExpenseForm({
},
[setDeletedFiles, deletedFiles],
);
// @todo @mohamed
const fetchHook = useQuery('expense-form', () => requestFetchExpensesTable());
return (

View File

@@ -35,6 +35,7 @@ function ExpenseFormHeader({
[setFieldValue],
);
// @todo @mohamed reusable components.
const infoIcon = useMemo(() => <Icon icon="info-circle" iconSize={12} />, []);
const requiredSpan = useMemo(() => <span className="required">*</span>, []);
@@ -74,6 +75,7 @@ function ExpenseFormHeader({
};
// Filters accounts items.
// @filter accounts predicator resauble
const filterAccountsPredicater = useCallback(
(query, account, _index, exactMatch) => {
const normalizedTitle = account.name.toLowerCase();
@@ -101,6 +103,7 @@ function ExpenseFormHeader({
const onItemsSelect = useCallback(
(filedName) => {
return (filed) => {
// @todo @mohamed
setSelectedItems({
...selectedItems,
[filedName]: filed,

View File

@@ -144,6 +144,7 @@ function ExpenseTable({
disableSortBy: true,
},
{
// @todo Add hint component after the header label.
Header: formatMessage({ id: 'expense_category' }),
id: 'expense_account_id',
accessor: 'expense_account_id',
@@ -161,7 +162,6 @@ function ExpenseTable({
disableResizing: true,
width: 150,
},
{
Header: formatMessage({ id: 'description' }),
accessor: 'description',

View File

@@ -12,25 +12,29 @@ import withCurrenciesActions from 'containers/Currencies/withCurrenciesActions';
import { compose } from 'utils';
function Expenses({
//#withwithAccountsActions
// #withwithAccountsActions
requestFetchAccounts,
//#withExpensesActions
// #withExpensesActions
requestFetchExpense,
// #wihtCurrenciesActions
requestFetchCurrencies,
}) {
const history = useHistory();
const { id } = useParams();
// @todo
const fetchAccounts = useQuery('accounts-expense-list', (key) =>
requestFetchAccounts(),
);
// @todo
const fetchExpense = useQuery(id && ['expense', id], (key, expense_Id) =>
requestFetchExpense(expense_Id),
);
// @todo
const fetchCurrencies = useQuery('currencies-expense-list', () =>
requestFetchCurrencies(),
);

View File

@@ -62,7 +62,6 @@ function ExpensesList({
);
// Handle cancel expense journal.
const handleCancelExpenseDelete = useCallback(() => {
setDeleteExpense(false);
}, [setDeleteExpense]);
@@ -103,12 +102,8 @@ function ExpensesList({
.then(() => {
AppToaster.show({
message: formatMessage(
{
id: 'the_expenses_has_been_successfully_deleted',
},
{
count: selectedRowsCount,
},
{ id: 'the_expenses_has_been_successfully_deleted', },
{ count: selectedRowsCount, },
),
intent: Intent.SUCCESS,
});
@@ -117,6 +112,8 @@ function ExpensesList({
.catch((error) => {
setBulkDelete(false);
});
// @todo
}, [requestDeleteBulkExpenses, bulkDelete, formatMessage, selectedRowsCount]);
// Handle cancel bulk delete alert.

View File

@@ -1,11 +1,8 @@
import { connect } from 'react-redux';
import { getExpenseById } from 'store/expenses/expenses.reducer';
const mapStateToProps = (state, props) => {
return {
expenseDetail: getExpenseById(state, props.expenseId),
};
};
const mapStateToProps = (state, props) => ({
expenseDetail: getExpenseById(state, props.expenseId),
});
export default connect(mapStateToProps);

View File

@@ -14,7 +14,6 @@ export const mapDispatchToProps = (dispatch) => ({
requestSubmitExpense: (form) => dispatch(submitExpense({ form })),
requestFetchExpense: (id) => dispatch(fetchExpense({ id })),
requestEditExpense: (id, form) => dispatch(editExpense({ id, form })),
requestDeleteExpense: (id) => dispatch(deleteExpense({ id })),
requestFetchExpensesTable: (query = {}) =>
dispatch(fetchExpensesTable({ query: { ...query } })),