Skip to content

Commit aa868cb

Browse files
Copilothpware
andauthored
Fix ban reason input sharing state across user dialogs (#10)
* Initial plan * Fix ban description input sharing state across users Co-authored-by: hpware <157942818+hpware@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hpware <157942818+hpware@users.noreply.github.com>
1 parent 2e164a2 commit aa868cb

File tree

1 file changed

+14
-5
lines changed
  • apps/web/src/app/dashboard/user/manage_all

1 file changed

+14
-5
lines changed

apps/web/src/app/dashboard/user/manage_all/client.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import Image from "next/image";
4242
import { Input } from "@/components/ui/input";
4343

4444
export function Client() {
45-
const [banReason, setBanReason] = useState("");
45+
const [banReasons, setBanReasons] = useState<Record<string, string>>({});
4646
const submitToServer = useMutation({
4747
mutationFn: async (sendData: any) => {
4848
try {
@@ -227,8 +227,13 @@ export function Client() {
227227
<span>Ban Reason</span>
228228
<Input
229229
type="text"
230-
value={banReason}
231-
onChange={(e) => setBanReason(e.target.value)}
230+
value={banReasons[row.original.id] || ""}
231+
onChange={(e) =>
232+
setBanReasons(prev => ({
233+
...prev,
234+
[row.original.id]: e.target.value
235+
}))
236+
}
232237
/>
233238
<DialogDescription className="flex flex-col">
234239
<span>
@@ -248,9 +253,13 @@ export function Client() {
248253
submitToServer.mutate({
249254
action: "ban_user",
250255
user: row.original.id,
251-
reason: banReason,
256+
reason: banReasons[row.original.id] || "",
257+
});
258+
setBanReasons(prev => {
259+
const newReasons = { ...prev };
260+
delete newReasons[row.original.id];
261+
return newReasons;
252262
});
253-
setBanReason("");
254263
}}
255264
>
256265
Ban User

0 commit comments

Comments
 (0)