Fix impersonation: hard navigation + stop impersonating banner
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { authClient } from "@/lib/auth-client";
|
||||
|
||||
export function StopImpersonateBanner({ userName }: { userName: string }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function handleStop() {
|
||||
setLoading(true);
|
||||
try {
|
||||
await authClient.admin.stopImpersonating();
|
||||
window.location.href = "/admin/users";
|
||||
} catch {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="flex items-center justify-between px-6 py-2 text-sm"
|
||||
style={{
|
||||
backgroundColor: "var(--color-highlight)",
|
||||
borderBottom: "2px solid var(--foreground)",
|
||||
}}
|
||||
>
|
||||
<span>
|
||||
Вы просматриваете платформу как <strong>{userName}</strong>
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleStop}
|
||||
disabled={loading}
|
||||
className="btn-aubade text-xs px-3 py-1"
|
||||
>
|
||||
{loading ? "..." : "← Вернуться в админку"}
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user