diff --git a/frontend/src/pages/GroupSettingsPage.tsx b/frontend/src/pages/GroupSettingsPage.tsx index c71a0b8..bca3365 100644 --- a/frontend/src/pages/GroupSettingsPage.tsx +++ b/frontend/src/pages/GroupSettingsPage.tsx @@ -2,6 +2,7 @@ import { Trash2, UserPlus } from "lucide-react"; import { useEffect, useState } from "react"; import { ApiError } from "../api/client"; +import { ConfirmDialog } from "../components/ConfirmDialog"; import { PlayerLink } from "../components/PlayerLink"; import { Spinner } from "../components/Spinner"; import { Switch } from "../components/Switch"; @@ -24,6 +25,7 @@ export function GroupSettingsPage() { const [selected, setSelected] = useState>(new Set()); const [newNick, setNewNick] = useState(""); + const [removeTarget, setRemoveTarget] = useState<{ userId: number; nickname: string } | null>(null); useEffect(() => { if (group) setSelected(new Set(group.expansion_ids)); @@ -121,7 +123,10 @@ export function GroupSettingsPage() { {m.nickname} · {m.role} {isOwner && m.role !== "owner" && ( - )} @@ -129,6 +134,21 @@ export function GroupSettingsPage() { ))} + + setRemoveTarget(null)} + onConfirm={() => { + if (!removeTarget) return; + const userId = removeTarget.userId; + setRemoveTarget(null); + remove(userId); + }} + /> ); } diff --git a/frontend/src/pages/admin/AdminAchievementsPage.tsx b/frontend/src/pages/admin/AdminAchievementsPage.tsx index 99016b6..c7b3d2d 100644 --- a/frontend/src/pages/admin/AdminAchievementsPage.tsx +++ b/frontend/src/pages/admin/AdminAchievementsPage.tsx @@ -2,6 +2,7 @@ import { useRef, useState } from "react"; import { ApiError } from "../../api/client"; import { Avatar } from "../../components/Avatar"; +import { ConfirmDialog } from "../../components/ConfirmDialog"; import { Spinner } from "../../components/Spinner"; import { useToast } from "../../context/ToastContext"; import { @@ -87,6 +88,7 @@ function AchievementCard({ ach }: { ach: AchievementRead }) { const toast = useToast(); const fileRef = useRef(null); const [editing, setEditing] = useState(false); + const [confirmRemove, setConfirmRemove] = useState(false); const [name, setName] = useState(ach.name); const [description, setDescription] = useState(ach.description); const [condition, setCondition] = useState(ach.condition); @@ -117,7 +119,6 @@ function AchievementCard({ ach }: { ach: AchievementRead }) { }; const remove = async () => { - if (!window.confirm(`Удалить ачивку «${ach.name}»?`)) return; try { await del.mutateAsync(ach.slug); toast.show("Удалено"); @@ -175,7 +176,11 @@ function AchievementCard({ ach }: { ach: AchievementRead }) { - )} + + setConfirmRemove(false)} + onConfirm={() => { + setConfirmRemove(false); + remove(); + }} + /> ); } diff --git a/frontend/src/pages/admin/AdminRecordsPage.tsx b/frontend/src/pages/admin/AdminRecordsPage.tsx index 7fd1c7a..8bbab19 100644 --- a/frontend/src/pages/admin/AdminRecordsPage.tsx +++ b/frontend/src/pages/admin/AdminRecordsPage.tsx @@ -1,6 +1,8 @@ import { Pencil, Trash2 } from "lucide-react"; import { useMemo, useState } from "react"; +import { ApiError } from "../../api/client"; +import { ConfirmDialog } from "../../components/ConfirmDialog"; import { Spinner } from "../../components/Spinner"; import { Switch } from "../../components/Switch"; import { useToast } from "../../context/ToastContext"; @@ -20,6 +22,7 @@ export function AdminRecordsPage() { const [factionFilter, setFactionFilter] = useState(null); const [grouped, setGrouped] = useState(true); const [editId, setEditId] = useState(null); + const [deleteTarget, setDeleteTarget] = useState(null); const { data: groups } = useAdminGroups(); const { data: users } = useAdminUsers(); @@ -61,13 +64,7 @@ export function AdminRecordsPage() { - @@ -137,6 +134,25 @@ export function AdminRecordsPage() { )} {editId != null && setEditId(null)} />} + + setDeleteTarget(null)} + onConfirm={async () => { + if (!deleteTarget) return; + setDeleteTarget(null); + try { + await del.mutateAsync(deleteTarget.id); + toast.show("Удалено"); + } catch (e) { + toast.show(e instanceof ApiError ? e.message : "Не удалось удалить"); + } + }} + /> ); } diff --git a/frontend/src/pages/admin/DevDeleteAccountButton.tsx b/frontend/src/pages/admin/DevDeleteAccountButton.tsx index 40b735e..884b137 100644 --- a/frontend/src/pages/admin/DevDeleteAccountButton.tsx +++ b/frontend/src/pages/admin/DevDeleteAccountButton.tsx @@ -1,7 +1,9 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { useState } from "react"; import { ApiError, api, unwrap } from "../../api/client"; import { qk } from "../../api/queryKeys"; +import { ConfirmDialog } from "../../components/ConfirmDialog"; import { useToast } from "../../context/ToastContext"; /** @@ -21,6 +23,7 @@ export function DevDeleteAccountButton({ }) { const qc = useQueryClient(); const toast = useToast(); + const [confirmOpen, setConfirmOpen] = useState(false); const del = useMutation({ mutationFn: async () => unwrap( @@ -32,29 +35,34 @@ export function DevDeleteAccountButton({ }); return ( - + <> + + setConfirmOpen(false)} + onConfirm={async () => { + setConfirmOpen(false); + try { + await del.mutateAsync(); + toast.show("Аккаунт удалён"); + } catch (e) { + toast.show(e instanceof ApiError ? e.message : "Не удалось удалить"); + } + }} + /> + ); }