fix(Branches & warehouses ): mark primary.

This commit is contained in:
elforjani13
2022-02-20 18:38:19 +02:00
parent 3a4c1adbd4
commit 05b0f5caac
8 changed files with 55 additions and 32 deletions

View File

@@ -3,17 +3,17 @@ import React from 'react';
const WarehouseDeleteAlert = React.lazy(() =>
import('../../Alerts/Warehouses/WarehouseDeleteAlert'),
);
const WarehouseMarkPrimaryAlert = React.lazy(() =>
import('../../Alerts/Warehouses/WarehouseMarkPrimaryAlert'),
);
// const WarehouseMarkPrimaryAlert = React.lazy(() =>
// import('../../Alerts/Warehouses/WarehouseMarkPrimaryAlert'),
// );
/**
* Warehouses alerts.
*/
export default [
{ name: 'warehouse-delete', component: WarehouseDeleteAlert },
{
name: 'warehouse-mark-primary',
component: WarehouseMarkPrimaryAlert,
},
// {
// name: 'warehouse-mark-primary',
// component: WarehouseMarkPrimaryAlert,
// },
];

View File

@@ -1,7 +1,11 @@
import React from 'react';
import intl from 'react-intl-universal';
import { Intent } from '@blueprintjs/core';
import { ContextMenu2 } from '@blueprintjs/popover2';
import { AppToaster } from 'components';
import { WarehouseContextMenu, WarehousesGridItemBox } from './components';
import { useMarkWarehouseAsPrimary } from 'hooks/query';
import withAlertsActions from '../../Alert/withAlertActions';
import withDialogActions from '../../Dialog/withDialogActions';
@@ -19,6 +23,9 @@ function WarehouseGridItem({
warehouse,
}) {
const { mutateAsync: markWarehouseAsPrimaryMutate } =
useMarkWarehouseAsPrimary();
// Handle edit warehouse.
const handleEditWarehouse = () => {
openDialog('warehouse-form', { warehouseId: warehouse.id, action: 'edit' });
@@ -28,8 +35,13 @@ function WarehouseGridItem({
openAlert('warehouse-delete', { warehouseId: warehouse.id });
};
// Handle mark primary warehouse.
const handleMarkPrimaryWarehouse = () => {
openAlert('warehouse-mark-primary', { warehouseId: warehouse.id });
const handleMarkWarehouseAsPrimary = () => {
markWarehouseAsPrimaryMutate(warehouse.id).then(() => {
AppToaster.show({
message: intl.get('warehouse.alert.mark_primary_message'),
intent: Intent.SUCCESS,
});
});
};
return (
@@ -38,7 +50,7 @@ function WarehouseGridItem({
<WarehouseContextMenu
onEditClick={handleEditWarehouse}
onDeleteClick={handleDeleteWarehouse}
onMarkPrimary={handleMarkPrimaryWarehouse}
onMarkPrimary={handleMarkWarehouseAsPrimary}
/>
}
>