(null);
const [validationResult, setValidationResult] = useState<{
valid: boolean;
errors: string[];
@@ -403,6 +418,13 @@ function AddChannelDialog({ selectedType, onSelectType, onClose, onChannelAdded
return () => { cancelled = true; };
}, [selectedType]);
+ // Focus first input when form is ready (avoids Windows focus loss after native dialogs)
+ useEffect(() => {
+ if (selectedType && !loadingConfig && firstInputRef.current) {
+ firstInputRef.current.focus();
+ }
+ }, [selectedType, loadingConfig]);
+
// Listen for WhatsApp QR events
useEffect(() => {
if (selectedType !== 'whatsapp') return;
@@ -753,6 +775,7 @@ function AddChannelDialog({ selectedType, onSelectType, onClose, onChannelAdded
{
+ if (!disabled && textareaRef.current) {
+ textareaRef.current.focus();
+ }
+ }, []);
+
// ── File staging via native dialog ─────────────────────────────
const pickFiles = useCallback(async () => {
diff --git a/src/pages/Cron/index.tsx b/src/pages/Cron/index.tsx
index d2604ed59..e6a55a2e5 100644
--- a/src/pages/Cron/index.tsx
+++ b/src/pages/Cron/index.tsx
@@ -28,6 +28,7 @@ import { Switch } from '@/components/ui/switch';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Textarea } from '@/components/ui/textarea';
+import { ConfirmDialog } from '@/components/ui/confirm-dialog';
import { useCronStore } from '@/stores/cron';
import { useGatewayStore } from '@/stores/gateway';
import { LoadingSpinner } from '@/components/common/LoadingSpinner';
@@ -318,9 +319,7 @@ function CronJobCard({ job, onToggle, onEdit, onDelete, onTrigger }: CronJobCard
};
const handleDelete = () => {
- if (confirm(t('card.deleteConfirm'))) {
- onDelete();
- }
+ onDelete();
};
return (
@@ -442,6 +441,7 @@ export function Cron() {
const gatewayStatus = useGatewayStore((state) => state.status);
const [showDialog, setShowDialog] = useState(false);
const [editingJob, setEditingJob] = useState();
+ const [jobToDelete, setJobToDelete] = useState<{ id: string } | null>(null);
const isGatewayRunning = gatewayStatus.state === 'running';
@@ -474,14 +474,7 @@ export function Cron() {
}
}, [toggleJob, t]);
- const handleDelete = useCallback(async (id: string) => {
- try {
- await deleteJob(id);
- toast.success(t('toast.deleted'));
- } catch {
- toast.error(t('toast.failedDelete'));
- }
- }, [deleteJob, t]);
+
if (loading) {
return (
@@ -629,7 +622,7 @@ export function Cron() {
setEditingJob(job);
setShowDialog(true);
}}
- onDelete={() => handleDelete(job.id)}
+ onDelete={() => setJobToDelete({ id: job.id })}
onTrigger={() => triggerJob(job.id)}
/>
))}
@@ -647,6 +640,23 @@ export function Cron() {
onSave={handleSave}
/>
)}
+
+ {
+ if (jobToDelete) {
+ await deleteJob(jobToDelete.id);
+ setJobToDelete(null);
+ toast.success(t('toast.deleted'));
+ }
+ }}
+ onCancel={() => setJobToDelete(null)}
+ />
);
}