Merge branch 'develop' into main

This commit is contained in:
a.bouhuolia
2022-03-24 15:32:30 +02:00
757 changed files with 26203 additions and 1575 deletions

View File

@@ -0,0 +1,79 @@
import React from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { useDeleteBranch } from 'hooks/query';
import { handleDeleteErrors } from '../../Preferences/Branches/utils';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Branch delete alert.
*/
function BranchDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { branchId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: deleteBranch, isLoading } = useDeleteBranch();
// Handle cancel delete alert.
const handleCancelDelete = () => {
closeAlert(name);
};
// Handle confirm delete branch.
const handleConfirmDeleteBranch = () => {
deleteBranch(branchId)
.then(() => {
AppToaster.show({
message: intl.get('branch.alert.delete_message'),
intent: Intent.SUCCESS,
});
})
.catch(
({
response: {
data: { errors },
},
}) => {
handleDeleteErrors(errors);
},
)
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'delete'} />}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancelDelete}
onConfirm={handleConfirmDeleteBranch}
loading={isLoading}
>
<p>
<FormattedHTMLMessage id={'branch.once_delete_this_branch'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(BranchDeleteAlert);

View File

@@ -0,0 +1,70 @@
import React from 'react';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from 'components';
import { useMarkBranchAsPrimary } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertActions from 'containers/Alert/withAlertActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import { compose } from 'utils';
/**
* branch mark primary alert.
*/
function BranchMarkPrimaryAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { branchId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: markPrimaryBranchMutate, isLoading } =
useMarkBranchAsPrimary();
// Handle cancel mark primary alert.
const handleCancelMarkPrimaryAlert = () => {
closeAlert(name);
};
// andle cancel mark primary confirm.
const handleConfirmMarkPrimaryBranch = () => {
markPrimaryBranchMutate(branchId)
.then(() => {
AppToaster.show({
message: intl.get('branch.alert.mark_primary_message'),
intent: Intent.SUCCESS,
});
closeAlert(name);
})
.catch((error) => {
closeAlert(name);
});
};
return (
<Alert
// cancelButtonText={<T id={'cancel'} />}
// confirmButtonText={<T id={'make_primary'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelMarkPrimaryAlert}
onConfirm={handleConfirmMarkPrimaryBranch}
loading={isLoading}
>
<p>
<T id={'branch.alert.are_you_sure_you_want_to_make'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(BranchMarkPrimaryAlert);

View File

@@ -0,0 +1,80 @@
import React from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { useDeleteWarehouse } from 'hooks/query';
import { handleDeleteErrors } from '../../Preferences/Warehouses/utils';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* Warehouse delete alert
* @returns
*/
function WarehouseDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: deleteWarehouseMutate, isLoading } =
useDeleteWarehouse();
// handle cancel delete warehouse alert.
const handleCancelDeleteAlert = () => {
closeAlert(name);
};
// handleConfirm delete invoice
const handleConfirmWarehouseDelete = () => {
deleteWarehouseMutate(warehouseId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse.alert.delete_message'),
intent: Intent.SUCCESS,
});
})
.catch(
({
response: {
data: { errors },
},
}) => {
handleDeleteErrors(errors);
},
)
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'delete'} />}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancelDeleteAlert}
onConfirm={handleConfirmWarehouseDelete}
loading={isLoading}
>
<p>
<FormattedHTMLMessage id={'warehouse.once_delete_this_warehouse'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(WarehouseDeleteAlert);

View File

@@ -0,0 +1,71 @@
import React from 'react';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { useTransferredWarehouseTransfer } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* warehouse transfer transferred alert.
* @returns
*/
function TransferredWarehouseTransferAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseTransferId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: transferredWarehouseTransferMutate, isLoading } =
useTransferredWarehouseTransfer();
// handle cancel alert.
const handleCancelAlert = () => {
closeAlert(name);
};
// Handle confirm alert.
const handleConfirmTransferred = () => {
transferredWarehouseTransferMutate(warehouseTransferId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse_transfer.alert.transferred_warehouse'),
intent: Intent.SUCCESS,
});
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'deliver'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelAlert}
onConfirm={handleConfirmTransferred}
loading={isLoading}
>
<p>
<T id={'warehouse_transfer.alert.are_you_sure_you_want_to_deliver'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(TransferredWarehouseTransferAlert);

View File

@@ -0,0 +1,70 @@
import React from 'react';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { FormattedMessage as T } from 'components';
import { useMarkWarehouseAsPrimary } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertActions from 'containers/Alert/withAlertActions';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import { compose } from 'utils';
/**
* warehouse mark primary alert.
*/
function WarehouseMarkPrimaryAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseId },
// #withAlertActions
closeAlert,
}) {
// const { mutateAsync: markPrimaryWarehouseMutate, isLoading } =
// useMarkWarehouseAsPrimary();
// Handle cancel mark primary alert.
const handleCancelMarkPrimaryAlert = () => {
closeAlert(name);
};
// andle cancel mark primary confirm.
const handleConfirmMarkPrimaryWarehouse = () => {
markPrimaryWarehouseMutate(warehouseId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse.alert.mark_primary_message'),
intent: Intent.SUCCESS,
});
closeAlert(name);
})
.catch((error) => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'make_primary'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelMarkPrimaryAlert}
onConfirm={handleConfirmMarkPrimaryWarehouse}
loading={isLoading}
>
<p>
<T id={'warehouse.alert.are_you_sure_you_want_to_make'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(WarehouseMarkPrimaryAlert);

View File

@@ -0,0 +1,85 @@
import React from 'react';
import intl from 'react-intl-universal';
import { FormattedMessage as T, FormattedHTMLMessage } from 'components';
import { Intent, Alert } from '@blueprintjs/core';
import { AppToaster } from 'components';
import { useDeleteWarehouseTransfer } from 'hooks/query';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import { compose } from 'utils';
/**
* Warehouse transfer delete alert
* @returns
*/
function WarehouseTransferDeleteAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseTransferId },
// #withAlertActions
closeAlert,
// #withDrawerActions
closeDrawer,
}) {
const { mutateAsync: deleteWarehouseTransferMutate, isLoading } =
useDeleteWarehouseTransfer();
// handle cancel delete warehouse alert.
const handleCancelDeleteAlert = () => {
closeAlert(name);
};
// handleConfirm delete warehouse transfer.
const handleConfirmWarehouseTransferDelete = () => {
deleteWarehouseTransferMutate(warehouseTransferId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse_transfer.alert.delete_message'),
intent: Intent.SUCCESS,
});
closeDrawer('warehouse-transfer-detail-drawer');
})
.catch(
({
response: {
data: { errors },
},
}) => {},
)
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'delete'} />}
icon="trash"
intent={Intent.DANGER}
isOpen={isOpen}
onCancel={handleCancelDeleteAlert}
onConfirm={handleConfirmWarehouseTransferDelete}
loading={isLoading}
>
<p>
<FormattedHTMLMessage
id={'warehouse_transfer.once_delete_this_warehouse_transfer'}
/>
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
withDrawerActions,
)(WarehouseTransferDeleteAlert);

View File

@@ -0,0 +1,71 @@
import React from 'react';
import { FormattedMessage as T } from 'components';
import intl from 'react-intl-universal';
import { Intent, Alert } from '@blueprintjs/core';
import { useInitiateWarehouseTransfer } from 'hooks/query';
import { AppToaster } from 'components';
import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
import withAlertActions from 'containers/Alert/withAlertActions';
import { compose } from 'utils';
/**
* warehouse transfer initiate alert.
* @returns
*/
function WarehouseTransferInitiateAlert({
name,
// #withAlertStoreConnect
isOpen,
payload: { warehouseTransferId },
// #withAlertActions
closeAlert,
}) {
const { mutateAsync: initialWarehouseTransferMutate, isLoading } =
useInitiateWarehouseTransfer();
// handle cancel alert.
const handleCancelAlert = () => {
closeAlert(name);
};
// Handle confirm alert.
const handleConfirmInitiated = () => {
initialWarehouseTransferMutate(warehouseTransferId)
.then(() => {
AppToaster.show({
message: intl.get('warehouse_transfer.alert.initiate_warehouse'),
intent: Intent.SUCCESS,
});
})
.catch((error) => {})
.finally(() => {
closeAlert(name);
});
};
return (
<Alert
cancelButtonText={<T id={'cancel'} />}
confirmButtonText={<T id={'warehouse_transfer.label.initiate'} />}
intent={Intent.WARNING}
isOpen={isOpen}
onCancel={handleCancelAlert}
onConfirm={handleConfirmInitiated}
loading={isLoading}
>
<p>
<T id={'warehouse_transfer.alert.are_you_sure_you_want_to_initate'} />
</p>
</Alert>
);
}
export default compose(
withAlertStoreConnect(),
withAlertActions,
)(WarehouseTransferInitiateAlert);