stack/apps/dashboard/src/components/user-dialogs.tsx
Armaan Jain c8fe42db4e
Some checks failed
all-good: Did all the other checks pass? / all-good (push) Has been cancelled
Ensure Prisma migrations are in sync with the schema / check_prisma_migrations (22.x) (push) Has been cancelled
Docker Server Build and Push / Docker Build and Push Server (push) Has been cancelled
Docker Server Build and Run / docker (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (mock, 22.x) (push) Has been cancelled
Runs E2E API Tests / E2E Tests (Node ${{ matrix.node-version }}, Freestyle ${{ matrix.freestyle-mode }}) (prod, 22.x) (push) Has been cancelled
Runs E2E API Tests with custom port prefix / build (22.x) (push) Has been cancelled
Runs E2E API Tests with external source of truth / build (22.x) (push) Has been cancelled
Lint & build / lint_and_build (latest) (push) Has been cancelled
Dev Environment Test With Custom Base Port / restart-dev-and-test-with-custom-base-port (push) Has been cancelled
Dev Environment Test / restart-dev-and-test (push) Has been cancelled
Run setup tests with custom base port / setup-tests-with-custom-base-port (push) Has been cancelled
Run setup tests / setup-tests (push) Has been cancelled
TOC Generator / TOC Generator (push) Has been cancelled
Payments redesign (#1045)
Co-authored-by: Konstantin Wohlwend <n2d4xc@gmail.com>
2025-12-17 16:34:17 -08:00

58 lines
1.4 KiB
TypeScript

import { ServerUser } from '@stackframe/stack';
import { ActionDialog, CopyField, Typography } from "@/components/ui";
import { useRouter } from './router';
export function DeleteUserDialog(props: {
user: ServerUser,
open: boolean,
redirectTo?: string,
onOpenChange: (open: boolean) => void,
}) {
const router = useRouter();
return <ActionDialog
open={props.open}
onOpenChange={props.onOpenChange}
title="Delete User"
danger
cancelButton
okButton={{
label: "Delete User", onClick: async () => {
await props.user.delete();
if (props.redirectTo) {
router.push(props.redirectTo);
}
}
}}
confirmText="I understand that this action cannot be undone."
>
{`Are you sure you want to delete the user ${props.user.displayName ? '"' + props.user.displayName + '"' : ''} with ID ${props.user.id}?`}
</ActionDialog>;
}
export function ImpersonateUserDialog(props: {
user: ServerUser,
impersonateSnippet: string | null,
onClose: () => void,
}) {
return <ActionDialog
open={props.impersonateSnippet !== null}
onOpenChange={(open) => !open && props.onClose()}
title="Impersonate User"
okButton
>
<Typography>
Open your website and paste the following code into the browser console:
</Typography>
<CopyField
type="textarea"
monospace
height={60}
value={props.impersonateSnippet ?? ""}
/>
</ActionDialog>;
}