mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-31 10:07:28 +01:00
Add demo mode check for wipe inventory action
Added frontend check to display error modal when user attempts to wipe inventory in demo mode. The modal shows: "Inventory, labels and locations cannot be wiped whilst Homebox is in demo mode. Please ensure that you are not in demo mode and try again." Backend already had demo mode protection returning 403 Forbidden. Co-authored-by: katosdev <7927609+katosdev@users.noreply.github.com>
This commit is contained in:
@@ -748,6 +748,9 @@
|
||||
"zero_datetimes_sub": "Resets the time value for all date time fields in your inventory to the beginning of the date. This is to fix a bug that was introduced early on in the development of the site that caused the time value to be stored with the time which caused issues with date fields displaying accurate values. '<a class=\"link\" href=\"https://github.com/hay-kot/homebox/issues/236\" target=\"_blank\">'See Github Issue #236 for more details.'</a>'"
|
||||
},
|
||||
"actions_sub": "Apply Actions to your inventory in bulk. These are irreversible actions. '<b>'Be careful.'</b>'",
|
||||
"demo_mode_error": {
|
||||
"wipe_inventory": "Inventory, labels and locations cannot be wiped whilst Homebox is in demo mode. Please ensure that you are not in demo mode and try again."
|
||||
},
|
||||
"import_export": "Import/Export",
|
||||
"import_export_set": {
|
||||
"export": "Export Inventory",
|
||||
|
||||
@@ -131,6 +131,13 @@
|
||||
|
||||
const api = useUserApi();
|
||||
const confirm = useConfirm();
|
||||
|
||||
// Fetch status to check for demo mode
|
||||
const pubApi = usePublicApi();
|
||||
const { data: status } = useAsyncData(async () => {
|
||||
const { data } = await pubApi.status();
|
||||
return data;
|
||||
});
|
||||
|
||||
function getBillOfMaterials() {
|
||||
const url = api.reports.billOfMaterialsURL();
|
||||
@@ -228,6 +235,12 @@
|
||||
}
|
||||
|
||||
async function wipeInventory() {
|
||||
// Check if in demo mode
|
||||
if (status.value?.demo) {
|
||||
await confirm.open(t("tools.demo_mode_error.wipe_inventory"));
|
||||
return;
|
||||
}
|
||||
|
||||
openDialog(DialogID.WipeInventory, {
|
||||
onClose: async (result) => {
|
||||
if (!result) {
|
||||
|
||||
Reference in New Issue
Block a user