feat(branche & warehouse ) add mark primary alert.

This commit is contained in:
elforjani13
2022-02-08 20:31:15 +02:00
parent 09d5771481
commit 49f8cce54b
13 changed files with 244 additions and 25 deletions

View File

@@ -3,5 +3,14 @@ import React from 'react';
const BranchDeleteAlert = React.lazy(() =>
import('../../Alerts/Branches/BranchDeleteAlert'),
);
const BranchMarkPrimaryAlert = React.lazy(() =>
import('../../Alerts/Branches/BranchMarkPrimaryAlert'),
);
export default [{ name: 'branch-delete', component: BranchDeleteAlert }];
export default [
{ name: 'branch-delete', component: BranchDeleteAlert },
{
name: 'branch-mark-primary',
component: BranchMarkPrimaryAlert,
},
];

View File

@@ -27,22 +27,27 @@ function BranchesDataTable({
// Table columns.
const columns = useBranchesTableColumns();
const Time = true;
const { branches, isBranchesLoading, isBranchesFetching } =
useBranchesContext();
// Handle edit branch.
const handleEditBranch = ({ id }) => {
openDialog('branch-form', { branchId: id, action: 'edit' });
};
// Handle delete branch.
const handleDeleteBranch = ({ id }) => {
openAlert('branch-delete', { branchId: id });
};
if (Time) {
return <BranchesEmptyStatus />;
}
// Handle mark primary branch.
const handleMarkPrimaryBranch = ({ id }) => {
openAlert('branch-mark-primary', { branchId: id });
};
// if (type) {
// return <BranchesEmptyStatus />;
// }
return (
<BranchesTableCard>
@@ -58,6 +63,7 @@ function BranchesDataTable({
payload={{
onEdit: handleEditBranch,
onDelete: handleDeleteBranch,
onMarkPrimary: handleMarkPrimaryBranch,
}}
/>
</BranchesTableCard>

View File

@@ -9,7 +9,7 @@ import { Icon } from 'components';
* Context menu of Branches.
*/
export function ActionsMenu({
payload: { onEdit, onDelete },
payload: { onEdit, onDelete, onMarkPrimary },
row: { original },
}) {
return (
@@ -19,6 +19,11 @@ export function ActionsMenu({
text={intl.get('branches.action.edit_branch')}
onClick={safeCallback(onEdit, original)}
/>
<MenuItem
icon={<Icon icon="check" />}
text={intl.get('branches.action.mark_as_primary')}
onClick={safeCallback(onMarkPrimary, original)}
/>
<MenuDivider />
<MenuItem
icon={<Icon icon="trash-16" iconSize={16} />}