feat(branche): add crud branches.

This commit is contained in:
elforjani13
2022-02-01 23:18:32 +02:00
parent dcac1053be
commit dea4fe0e79
17 changed files with 366 additions and 74 deletions

View File

@@ -4,8 +4,11 @@ import styled from 'styled-components';
import { DataTable } from 'components';
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import { useBranchesTableColumns, ActionsMenu } from './components';
import { useBranchesContext } from './BranchesProvider';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
@@ -14,23 +17,42 @@ import { compose } from 'utils';
function BranchesDataTable({
// #withDialogAction
openDialog,
// #withAlertActions
openAlert,
}) {
// Table columns.
const columns = useBranchesTableColumns();
const { branches, isBranchesLoading, isBranchesFetching } =
useBranchesContext();
const handleEditBranch = ({ id }) => {
openDialog('branch-form', { branchId: id, action: 'edit' });
};
const handleDeleteBranch = ({ id }) => {
openAlert('branch-delete', { branchId: id });
};
return (
<BranchesTable
columns={columns}
data={[]}
// loading={}
// progressBarLoading={}
data={branches}
loading={isBranchesLoading}
headerLoading={isBranchesLoading}
progressBarLoading={isBranchesFetching}
TableLoadingRenderer={TableSkeletonRows}
noInitialFetch={true}
ContextMenu={ActionsMenu}
payload={{}}
payload={{
onEdit: handleEditBranch,
onDelete: handleDeleteBranch,
}}
/>
);
}
export default compose(withDialogActions)(BranchesDataTable);
export default compose(withDialogActions, withAlertActions)(BranchesDataTable);
const BranchesTable = styled(DataTable)``;