refactor: remove dpracted useStore

This commit is contained in:
2026-09-02 17:36:00 +02:00
parent 6f3759d48d
commit be2e250ba1
+11 -8
View File
@@ -1,7 +1,6 @@
import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useMutation, useQueryClient } from "@tanstack/react-query";
import { deleteStorage, updateStorage } from "../utils/api/storages"; import { deleteStorage, updateStorage } from "../utils/api/storages";
import { useForm } from "@tanstack/react-form"; import { useForm } from "@tanstack/react-form";
import { useStore } from "@tanstack/react-store";
import { Button, IconButton, Input } from "@mui/joy"; import { Button, IconButton, Input } from "@mui/joy";
import { Trash2 } from "lucide-react"; import { Trash2 } from "lucide-react";
import type { Storage } from "../misc/interfaces"; import type { Storage } from "../misc/interfaces";
@@ -56,11 +55,6 @@ export const StorageRow = ({ storage, onError }: StorageRowProps) => {
}, },
}); });
const values = useStore(form.baseStore, (state) => state.values);
const isDirty =
values.name !== storage.name ||
(values.description ?? "") !== (storage.description ?? "");
return ( return (
<> <>
<DeleteConfirmation <DeleteConfirmation
@@ -122,7 +116,14 @@ export const StorageRow = ({ storage, onError }: StorageRowProps) => {
</td> </td>
<td className="px-6 py-5 text-right"> <td className="px-6 py-5 text-right">
<div className="flex flex-wrap justify-end gap-2"> <div className="flex flex-wrap justify-end gap-2">
{isDirty && ( <form.Subscribe
selector={(state) =>
state.values.name !== storage.name ||
(state.values.description ?? "") !== (storage.description ?? "")
}
>
{(isDirty) =>
isDirty && (
<Button <Button
color="primary" color="primary"
onClick={form.handleSubmit} onClick={form.handleSubmit}
@@ -132,7 +133,9 @@ export const StorageRow = ({ storage, onError }: StorageRowProps) => {
> >
{mutation.isPending ? "..." : t("save")} {mutation.isPending ? "..." : t("save")}
</Button> </Button>
)} )
}
</form.Subscribe>
<IconButton <IconButton
color="danger" color="danger"
variant="plain" variant="plain"