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:
copilot-swe-agent[bot]
2025-12-28 15:56:42 +00:00
parent 03dc7fa841
commit ff355f3cd8
2 changed files with 16 additions and 0 deletions

View File

@@ -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",

View File

@@ -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) {