mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
refactor: items alert.
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "7.8.4",
|
"@babel/core": "7.8.4",
|
||||||
"@blueprintjs/core": "^3.23.1",
|
"@blueprintjs/core": "^3.38.1",
|
||||||
"@blueprintjs/datetime": "^3.15.2",
|
"@blueprintjs/datetime": "^3.15.2",
|
||||||
"@blueprintjs/select": "^3.11.2",
|
"@blueprintjs/select": "^3.11.2",
|
||||||
"@blueprintjs/table": "^3.8.3",
|
"@blueprintjs/table": "^3.8.3",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
FormattedHTMLMessage,
|
FormattedHTMLMessage,
|
||||||
@@ -30,6 +30,7 @@ function InventoryAdjustmentDeleteAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// handle cancel delete alert.
|
// handle cancel delete alert.
|
||||||
const handleCancelInventoryAdjustmentDelete = () => {
|
const handleCancelInventoryAdjustmentDelete = () => {
|
||||||
@@ -37,9 +38,9 @@ function InventoryAdjustmentDeleteAlert({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmInventoryAdjustmentDelete = () => {
|
const handleConfirmInventoryAdjustmentDelete = () => {
|
||||||
|
setLoading(true);
|
||||||
requestDeleteInventoryAdjustment(inventoryId)
|
requestDeleteInventoryAdjustment(inventoryId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_adjustment_has_been_deleted_successfully',
|
id: 'the_adjustment_has_been_deleted_successfully',
|
||||||
@@ -48,7 +49,9 @@ function InventoryAdjustmentDeleteAlert({
|
|||||||
});
|
});
|
||||||
queryCache.invalidateQueries('inventory-adjustment-list');
|
queryCache.invalidateQueries('inventory-adjustment-list');
|
||||||
})
|
})
|
||||||
.catch((errors) => {
|
.catch((errors) => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -62,6 +65,7 @@ function InventoryAdjustmentDeleteAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelInventoryAdjustmentDelete}
|
onCancel={handleCancelInventoryAdjustmentDelete}
|
||||||
onConfirm={handleConfirmInventoryAdjustmentDelete}
|
onConfirm={handleConfirmInventoryAdjustmentDelete}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage
|
<FormattedHTMLMessage
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
FormattedMessage as T,
|
|
||||||
useIntl,
|
|
||||||
} from 'react-intl';
|
|
||||||
import { Intent, Alert } from '@blueprintjs/core';
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
import { queryCache } from 'react-query';
|
import { queryCache } from 'react-query';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
@@ -30,6 +27,7 @@ function ItemActivateAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// Handle activate item alert cancel.
|
// Handle activate item alert cancel.
|
||||||
const handleCancelActivateItem = () => {
|
const handleCancelActivateItem = () => {
|
||||||
@@ -38,9 +36,9 @@ function ItemActivateAlert({
|
|||||||
|
|
||||||
// Handle confirm item activated.
|
// Handle confirm item activated.
|
||||||
const handleConfirmItemActivate = () => {
|
const handleConfirmItemActivate = () => {
|
||||||
|
setLoading(true);
|
||||||
requestActivateItem(itemId)
|
requestActivateItem(itemId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_item_has_been_activated_successfully',
|
id: 'the_item_has_been_activated_successfully',
|
||||||
@@ -49,8 +47,10 @@ function ItemActivateAlert({
|
|||||||
});
|
});
|
||||||
queryCache.invalidateQueries('items-table');
|
queryCache.invalidateQueries('items-table');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {})
|
||||||
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -62,6 +62,7 @@ function ItemActivateAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelActivateItem}
|
onCancel={handleCancelActivateItem}
|
||||||
onConfirm={handleConfirmItemActivate}
|
onConfirm={handleConfirmItemActivate}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<T id={'are_sure_to_activate_this_item'} />
|
<T id={'are_sure_to_activate_this_item'} />
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import { FormattedMessage as T, useIntl } from 'react-intl';
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
import { Intent, Alert } from '@blueprintjs/core';
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
@@ -26,16 +26,16 @@ function ItemBulkDeleteAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
// handle cancel item bulk delete alert.
|
// handle cancel item bulk delete alert.
|
||||||
const handleCancelBulkDelete = () => {
|
const handleCancelBulkDelete = () => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
};
|
};
|
||||||
// Handle confirm items bulk delete.
|
// Handle confirm items bulk delete.
|
||||||
const handleConfirmBulkDelete = () => {
|
const handleConfirmBulkDelete = () => {
|
||||||
|
setLoading(true);
|
||||||
requestDeleteBulkItems(itemsIds)
|
requestDeleteBulkItems(itemsIds)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_items_has_been_deleted_successfully',
|
id: 'the_items_has_been_deleted_successfully',
|
||||||
@@ -43,7 +43,9 @@ function ItemBulkDeleteAlert({
|
|||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((errors) => {
|
.catch((errors) => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
FormattedHTMLMessage,
|
FormattedHTMLMessage,
|
||||||
@@ -30,6 +30,7 @@ function ItemCategoryBulkDeleteAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// handle cancel bulk delete alert.
|
// handle cancel bulk delete alert.
|
||||||
const handleCancelBulkDelete = () => {
|
const handleCancelBulkDelete = () => {
|
||||||
@@ -38,9 +39,9 @@ function ItemCategoryBulkDeleteAlert({
|
|||||||
|
|
||||||
// handle confirm itemCategories bulk delete.
|
// handle confirm itemCategories bulk delete.
|
||||||
const handleConfirmBulkDelete = () => {
|
const handleConfirmBulkDelete = () => {
|
||||||
|
setLoading(true);
|
||||||
requestDeleteBulkItemCategories(itemCategoriesIds)
|
requestDeleteBulkItemCategories(itemCategoriesIds)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_item_categories_has_been_deleted_successfully',
|
id: 'the_item_categories_has_been_deleted_successfully',
|
||||||
@@ -48,8 +49,10 @@ function ItemCategoryBulkDeleteAlert({
|
|||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((errors) => {
|
.catch((errors) => {})
|
||||||
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
@@ -63,6 +66,7 @@ function ItemCategoryBulkDeleteAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelBulkDelete}
|
onCancel={handleCancelBulkDelete}
|
||||||
onConfirm={handleConfirmBulkDelete}
|
onConfirm={handleConfirmBulkDelete}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage
|
<FormattedHTMLMessage
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
FormattedHTMLMessage,
|
FormattedHTMLMessage,
|
||||||
@@ -31,6 +31,7 @@ function ItemCategoryDeleteAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// handle cancel delete item category alert.
|
// handle cancel delete item category alert.
|
||||||
const handleCancelItemCategoryDelete = () => {
|
const handleCancelItemCategoryDelete = () => {
|
||||||
@@ -39,9 +40,9 @@ function ItemCategoryDeleteAlert({
|
|||||||
|
|
||||||
// Handle alert confirm delete item category.
|
// Handle alert confirm delete item category.
|
||||||
const handleConfirmItemDelete = () => {
|
const handleConfirmItemDelete = () => {
|
||||||
|
setLoading(true);
|
||||||
requestDeleteItemCategory(itemCategoryId)
|
requestDeleteItemCategory(itemCategoryId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_item_category_has_been_deleted_successfully',
|
id: 'the_item_category_has_been_deleted_successfully',
|
||||||
@@ -50,7 +51,9 @@ function ItemCategoryDeleteAlert({
|
|||||||
});
|
});
|
||||||
queryCache.invalidateQueries('items-categories-list');
|
queryCache.invalidateQueries('items-categories-list');
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -64,6 +67,7 @@ function ItemCategoryDeleteAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelItemCategoryDelete}
|
onCancel={handleCancelItemCategoryDelete}
|
||||||
onConfirm={handleConfirmItemDelete}
|
onConfirm={handleConfirmItemDelete}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage
|
<FormattedHTMLMessage
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import {
|
||||||
FormattedMessage as T,
|
FormattedMessage as T,
|
||||||
FormattedHTMLMessage,
|
FormattedHTMLMessage,
|
||||||
@@ -33,6 +33,7 @@ function ItemDeleteAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// handle cancel delete item alert.
|
// handle cancel delete item alert.
|
||||||
const handleCancelItemDelete = () => {
|
const handleCancelItemDelete = () => {
|
||||||
@@ -40,9 +41,9 @@ function ItemDeleteAlert({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmDeleteItem = () => {
|
const handleConfirmDeleteItem = () => {
|
||||||
|
setLoading(true);
|
||||||
requestDeleteItem(itemId)
|
requestDeleteItem(itemId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_item_has_been_deleted_successfully',
|
id: 'the_item_has_been_deleted_successfully',
|
||||||
@@ -53,7 +54,10 @@ function ItemDeleteAlert({
|
|||||||
})
|
})
|
||||||
.catch(({ errors }) => {
|
.catch(({ errors }) => {
|
||||||
handleDeleteErrors(errors);
|
handleDeleteErrors(errors);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
|
setLoading(false);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -66,6 +70,7 @@ function ItemDeleteAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelItemDelete}
|
onCancel={handleCancelItemDelete}
|
||||||
onConfirm={handleConfirmDeleteItem}
|
onConfirm={handleConfirmDeleteItem}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<FormattedHTMLMessage
|
<FormattedHTMLMessage
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
import React from 'react';
|
import React, { useState } from 'react';
|
||||||
import {
|
import { FormattedMessage as T, useIntl } from 'react-intl';
|
||||||
FormattedMessage as T,
|
|
||||||
useIntl,
|
|
||||||
} from 'react-intl';
|
|
||||||
import { Intent, Alert } from '@blueprintjs/core';
|
import { Intent, Alert } from '@blueprintjs/core';
|
||||||
import { queryCache } from 'react-query';
|
import { queryCache } from 'react-query';
|
||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
@@ -30,6 +27,7 @@ function ItemInactivateAlert({
|
|||||||
closeAlert,
|
closeAlert,
|
||||||
}) {
|
}) {
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
// handle cancel inactivate alert.
|
// handle cancel inactivate alert.
|
||||||
const handleCancelInactivateItem = () => {
|
const handleCancelInactivateItem = () => {
|
||||||
@@ -38,9 +36,9 @@ function ItemInactivateAlert({
|
|||||||
|
|
||||||
// Handle confirm item Inactive.
|
// Handle confirm item Inactive.
|
||||||
const handleConfirmItemInactive = () => {
|
const handleConfirmItemInactive = () => {
|
||||||
|
setLoading(true);
|
||||||
requestInactiveItem(itemId)
|
requestInactiveItem(itemId)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
closeAlert(name);
|
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: formatMessage({
|
message: formatMessage({
|
||||||
id: 'the_item_has_been_inactivated_successfully',
|
id: 'the_item_has_been_inactivated_successfully',
|
||||||
@@ -49,7 +47,9 @@ function ItemInactivateAlert({
|
|||||||
});
|
});
|
||||||
queryCache.invalidateQueries('items-table');
|
queryCache.invalidateQueries('items-table');
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {})
|
||||||
|
.finally(() => {
|
||||||
|
setLoading(false);
|
||||||
closeAlert(name);
|
closeAlert(name);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -62,6 +62,7 @@ function ItemInactivateAlert({
|
|||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
onCancel={handleCancelInactivateItem}
|
onCancel={handleCancelInactivateItem}
|
||||||
onConfirm={handleConfirmItemInactive}
|
onConfirm={handleConfirmItemInactive}
|
||||||
|
loading={isLoading}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
<T id={'are_sure_to_inactive_this_item'} />
|
<T id={'are_sure_to_inactive_this_item'} />
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ItemDeleteAlert from 'containers/Alerts/Item/ItemDeleteAlert';
|
import ItemDeleteAlert from 'containers/Alerts/Items/ItemDeleteAlert';
|
||||||
import ItemInactivateAlert from 'containers/Alerts/Item/ItemInactivateAlert';
|
import ItemInactivateAlert from 'containers/Alerts/Items/ItemInactivateAlert';
|
||||||
import ItemActivateAlert from 'containers/Alerts/Item/ItemActivateAlert';
|
import ItemActivateAlert from 'containers/Alerts/Items/ItemActivateAlert';
|
||||||
import ItemBulkDeleteAlert from 'containers/Alerts/Item/ItemBulkDeleteAlert';
|
import ItemBulkDeleteAlert from 'containers/Alerts/Items/ItemBulkDeleteAlert';
|
||||||
import ItemCategoryDeleteAlert from 'containers/Alerts/Item/ItemCategoryDeleteAlert';
|
import ItemCategoryDeleteAlert from 'containers/Alerts/Items/ItemCategoryDeleteAlert';
|
||||||
import ItemCategoryBulkDeleteAlert from 'containers/Alerts/Item/ItemCategoryBulkDeleteAlert';
|
import ItemCategoryBulkDeleteAlert from 'containers/Alerts/Items/ItemCategoryBulkDeleteAlert';
|
||||||
import InventoryAdjustmentDeleteAlert from 'containers/Alerts/Item/InventoryAdjustmentDeleteAlert';
|
import InventoryAdjustmentDeleteAlert from 'containers/Alerts/Items/InventoryAdjustmentDeleteAlert';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items alert.
|
* Items alert.
|
||||||
|
|||||||
Reference in New Issue
Block a user