41 lines
708 B
TypeScript
41 lines
708 B
TypeScript
"use client";
|
|
|
|
import type { ReactNode } from "react";
|
|
|
|
export function ConfirmAction({
|
|
message,
|
|
action,
|
|
userId,
|
|
className,
|
|
style,
|
|
children,
|
|
}: {
|
|
message: string;
|
|
action: string;
|
|
userId: number;
|
|
className?: string;
|
|
style?: React.CSSProperties;
|
|
children: ReactNode;
|
|
}) {
|
|
return (
|
|
<form
|
|
action="/api/admin/users/actions"
|
|
method="post"
|
|
style={{ display: "inline-block" }}
|
|
>
|
|
<input type="hidden" name="userId" value={userId} />
|
|
<input type="hidden" name="action" value={action} />
|
|
<button
|
|
type="submit"
|
|
className={className}
|
|
style={style}
|
|
onClick={(e) => {
|
|
if (!confirm(message)) e.preventDefault();
|
|
}}
|
|
>
|
|
{children}
|
|
</button>
|
|
</form>
|
|
);
|
|
}
|