A continuation of HomeBox the inventory and organization system built for the Home User
Fix frontend linting errors in WipeInventoryDialog
copilot-swe-agent[bot]35941583c824
diff --git a/frontend/components/WipeInventoryDialog.vue b/frontend/components/WipeInventoryDialog.vueindex 323ca7ab..29f323b3 100644--- a/frontend/components/WipeInventoryDialog.vue+++ b/frontend/components/WipeInventoryDialog.vue@@ -1,92 +1,131 @@<template>- <BaseModal v-model="dialog" max-width="600px">- <template #title>- <span>{{ $t("tools.actions_set.wipe_inventory") }}</span>- </template>- <div class="space-y-4">- <p class="text-base">- {{ $t("tools.actions_set.wipe_inventory_confirm") }}- </p>-+ <AlertDialog :open="dialog" @update:open="handleOpenChange">+ <AlertDialogContent>+ <AlertDialogHeader>+ <AlertDialogTitle>{{ $t("tools.actions_set.wipe_inventory") }}</AlertDialogTitle>+ <AlertDialogDescription>+ {{ $t("tools.actions_set.wipe_inventory_confirm") }}+ </AlertDialogDescription>+ </AlertDialogHeader>+<div class="space-y-2"><div class="flex items-center space-x-2"><inputid="wipe-labels-checkbox"v-model="wipeLabels"type="checkbox"- class="h-4 w-4 rounded border-gray-300"+ class="size-4 rounded border-gray-300"/>- <label for="wipe-labels-checkbox" class="text-sm font-medium cursor-pointer">+ <label for="wipe-labels-checkbox" class="cursor-pointer text-sm font-medium">{{ $t("tools.actions_set.wipe_inventory_labels") }}</label></div>-+<div class="flex items-center space-x-2"><inputid="wipe-locations-checkbox"v-model="wipeLocations"type="checkbox"- class="h-4 w-4 rounded border-gray-300"+ class="size-4 rounded border-gray-300"/>- <label for="wipe-locations-checkbox" class="text-sm font-medium cursor-pointer">+ <label for="wipe-locations-checkbox" class="cursor-pointer text-sm font-medium">{{ $t("tools.actions_set.wipe_inventory_locations") }}</label></div>-+<div class="flex items-center space-x-2"><inputid="wipe-maintenance-checkbox"v-model="wipeMaintenance"type="checkbox"- class="h-4 w-4 rounded border-gray-300"+ class="size-4 rounded border-gray-300"/>- <label for="wipe-maintenance-checkbox" class="text-sm font-medium cursor-pointer">+ <label for="wipe-maintenance-checkbox" class="cursor-pointer text-sm font-medium">{{ $t("tools.actions_set.wipe_inventory_maintenance") }}</label></div></div>-+<p class="text-sm text-gray-600">{{ $t("tools.actions_set.wipe_inventory_note") }}</p>- </div>-- <template #actions>- <BaseButton @click="close"> {{ $t("global.cancel") }} </BaseButton>- <BaseButton type="primary" @click="confirm">- {{ $t("global.confirm") }}- </BaseButton>- </template>- </BaseModal>++ <AlertDialogFooter>+ <AlertDialogCancel @click="close">+ {{ $t("global.cancel") }}+ </AlertDialogCancel>+ <AlertDialogAction @click="confirm">+ {{ $t("global.confirm") }}+ </AlertDialogAction>+ </AlertDialogFooter>+ </AlertDialogContent>+ </AlertDialog></template><script setup lang="ts">import { DialogID } from "~/components/ui/dialog-provider/utils";import { useDialog } from "~/components/ui/dialog-provider";-- const { registerOpenDialogCallback, closeDialog } = useDialog();-+ import {+ AlertDialog,+ AlertDialogAction,+ AlertDialogCancel,+ AlertDialogContent,+ AlertDialogDescription,+ AlertDialogFooter,+ AlertDialogHeader,+ AlertDialogTitle,+ } from "@/components/ui/alert-dialog";++ const { registerOpenDialogCallback, closeDialog, addAlert, removeAlert } = useDialog();+const dialog = ref(false);const wipeLabels = ref(false);const wipeLocations = ref(false);const wipeMaintenance = ref(false);-- let onCloseCallback: ((result?: { wipeLabels: boolean; wipeLocations: boolean; wipeMaintenance: boolean } | undefined) => void) | undefined;-- registerOpenDialogCallback(DialogID.WipeInventory, (params?: { onClose?: (result?: { wipeLabels: boolean; wipeLocations: boolean; wipeMaintenance: boolean } | undefined) => void }) => {- dialog.value = true;- wipeLabels.value = false;- wipeLocations.value = false;- wipeMaintenance.value = false;- onCloseCallback = params?.onClose;- });-++ let onCloseCallback:+ | ((result?: { wipeLabels: boolean; wipeLocations: boolean; wipeMaintenance: boolean } | undefined) => void)+ | undefined;++ registerOpenDialogCallback(+ DialogID.WipeInventory,+ (params?: {+ onClose?: (+ result?: { wipeLabels: boolean; wipeLocations: boolean; wipeMaintenance: boolean } | undefined+ ) => void;+ }) => {+ dialog.value = true;+ wipeLabels.value = false;+ wipeLocations.value = false;+ wipeMaintenance.value = false;+ onCloseCallback = params?.onClose;+ }+ );++ watch(+ dialog,+ val => {+ if (val) {+ addAlert("wipe-inventory-dialog");+ } else {+ removeAlert("wipe-inventory-dialog");+ }+ },+ { immediate: true }+ );++ function handleOpenChange(open: boolean) {+ if (!open) {+ close();+ }+ }+function close() {dialog.value = false;closeDialog(DialogID.WipeInventory, undefined);onCloseCallback?.(undefined);}-+function confirm() {dialog.value = false;const result = {diff --git a/frontend/lib/api/classes/actions.ts b/frontend/lib/api/classes/actions.tsindex 542aa868..43057c13 100644--- a/frontend/lib/api/classes/actions.ts+++ b/frontend/lib/api/classes/actions.ts@@ -33,7 +33,10 @@ export class ActionsAPI extends BaseAPI {}wipeInventory(options?: { wipeLabels?: boolean; wipeLocations?: boolean; wipeMaintenance?: boolean }) {- return this.http.post<{ wipeLabels?: boolean; wipeLocations?: boolean; wipeMaintenance?: boolean }, ActionAmountResult>({+ return this.http.post<+ { wipeLabels?: boolean; wipeLocations?: boolean; wipeMaintenance?: boolean },+ ActionAmountResult+ >({url: route("/actions/wipe-inventory"),body: options || {},});diff --git a/frontend/pages/tools.vue b/frontend/pages/tools.vueindex 090bcb92..57a66906 100644--- a/frontend/pages/tools.vue+++ b/frontend/pages/tools.vue@@ -131,7 +131,7 @@const api = useUserApi();const confirm = useConfirm();-+// Fetch status to check for demo modeconst pubApi = usePublicApi();const { data: status } = useAsyncData(async () => {@@ -240,24 +240,24 @@await confirm.open(t("tools.demo_mode_error.wipe_inventory"));return;}-+openDialog(DialogID.WipeInventory, {- onClose: async (result) => {+ onClose: async result => {if (!result) {return;}-+const apiResult = await api.actions.wipeInventory({wipeLabels: result.wipeLabels,wipeLocations: result.wipeLocations,wipeMaintenance: result.wipeMaintenance,});-+if (apiResult.error) {toast.error(t("tools.toast.failed_wipe_inventory"));return;}-+toast.success(t("tools.toast.wipe_inventory_success", { results: apiResult.data.completed }));},});