Skip to content

Commit b1ec77c

Browse files
committed
ask for confirmation before clearing API keys
1 parent ca92f4b commit b1ec77c

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

src/components/ApiKeysDialog.tsx

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ export function ApiKeysDialog({ onClose }: ApiKeysDialogProps) {
2626
};
2727

2828
const handleClearKeys = () => {
29-
dispatch({
30-
type: "UPDATE_API_KEYS",
31-
payload: {},
32-
});
33-
setGoogleMapsKey("");
29+
const confirmed = window.confirm(
30+
"Are you sure you want to clear all API keys? This action cannot be undone."
31+
);
32+
33+
if (confirmed) {
34+
dispatch({
35+
type: "UPDATE_API_KEYS",
36+
payload: {},
37+
});
38+
setGoogleMapsKey("");
39+
}
3440
};
3541

3642
return (
@@ -80,27 +86,29 @@ export function ApiKeysDialog({ onClose }: ApiKeysDialogProps) {
8086
</p>
8187
</div>
8288

83-
<div className="flex justify-end gap-2">
89+
<div className="flex justify-between gap-2">
8490
<button
8591
type="button"
8692
onClick={handleClearKeys}
8793
className="px-4 py-2 text-sm text-red-600 hover:bg-red-50 rounded"
8894
>
8995
Clear All Keys
9096
</button>
91-
<button
92-
type="button"
93-
onClick={onClose}
94-
className="px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded"
95-
>
96-
Cancel
97-
</button>
98-
<button
99-
type="submit"
100-
className="px-4 py-2 text-sm text-white bg-brand hover:bg-brand/90 rounded"
101-
>
102-
Save
103-
</button>
97+
<div className="flex gap-2">
98+
<button
99+
type="button"
100+
onClick={onClose}
101+
className="px-4 py-2 text-sm text-gray-600 hover:bg-gray-100 rounded"
102+
>
103+
Cancel
104+
</button>
105+
<button
106+
type="submit"
107+
className="px-4 py-2 text-sm text-white bg-brand hover:bg-brand/90 rounded"
108+
>
109+
Save
110+
</button>
111+
</div>
104112
</div>
105113
</form>
106114
</div>

0 commit comments

Comments
 (0)