confirm-button.tsx28 lines · main
1'use client';
2
3/**
4 * Submit button that asks for confirmation before letting the parent <form>'s
5 * server action run. Used for destructive snapshot actions (restore replaces
6 * all data; delete is permanent) so a non-coder can't trigger them by accident.
7 */
8export function ConfirmButton({
9 message,
10 className,
11 children,
12}: {
13 message: string;
14 className?: string;
15 children: React.ReactNode;
16}) {
17 return (
18 <button
19 type="submit"
20 className={className}
21 onClick={(e) => {
22 if (!window.confirm(message)) e.preventDefault();
23 }}
24 >
25 {children}
26 </button>
27 );
28}