From 9efe5c846975fd570b93e993a45c48a796178cfd Mon Sep 17 00:00:00 2001 From: Gitead Date: Thu, 25 Jun 2026 20:48:35 -0400 Subject: [PATCH] feat: add Auto Claim toggle with hourly time picker to AI column claim section Co-Authored-By: Claude Sonnet 4.6 --- apps/Frontend/src/pages/appointments-page.tsx | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/apps/Frontend/src/pages/appointments-page.tsx b/apps/Frontend/src/pages/appointments-page.tsx index 6be3411c..fce29085 100755 --- a/apps/Frontend/src/pages/appointments-page.tsx +++ b/apps/Frontend/src/pages/appointments-page.tsx @@ -58,6 +58,14 @@ import { PopoverTrigger, } from "@/components/ui/popover"; import { Label } from "@/components/ui/label"; +import { Switch } from "@/components/ui/switch"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; import { useAppDispatch, useAppSelector } from "@/redux/hooks"; import { clearTaskStatus, @@ -167,6 +175,9 @@ export default function AppointmentsPage() { const [isClaimingColumn, setIsClaimingColumn] = useState(false); const [selectedClaimAiColumns, setSelectedClaimAiColumns] = useState>(new Set()); const [isClaimingAiColumn, setIsClaimingAiColumn] = useState(false); + const [autoClaimEnabled, setAutoClaimEnabled] = useState(false); + const [autoClaimTime, setAutoClaimTime] = useState("19:00"); + const autoClaimFiredHourRef = useRef(null); const [aiClaimModalOpen, setAiClaimModalOpen] = useState(false); const [aiClaimQueue, setAiClaimQueue] = useState([]); const [aiClaimCurrentIndex, setAiClaimCurrentIndex] = useState(0); @@ -462,6 +473,26 @@ export default function AppointmentsPage() { } }, [needsAiClaimResume, isLoadingAppointments]); + // Auto-claim: fire handleClaimForColumnWithAi at the configured hour each day + useEffect(() => { + if (!autoClaimEnabled || !autoClaimTime) return; + const [targetHour] = autoClaimTime.split(":").map(Number); + const interval = setInterval(() => { + const now = new Date(); + const currentHour = now.getHours(); + const currentMinute = now.getMinutes(); + if (currentHour === targetHour && currentMinute === 0) { + if (autoClaimFiredHourRef.current !== currentHour) { + autoClaimFiredHourRef.current = currentHour; + handleClaimForColumnWithAi(); + } + } else if (autoClaimFiredHourRef.current === currentHour && currentMinute !== 0) { + autoClaimFiredHourRef.current = null; + } + }, 30_000); + return () => clearInterval(interval); + }, [autoClaimEnabled, autoClaimTime, selectedClaimAiColumns]); + // Create/upsert appointment mutation const createAppointmentMutation = useMutation({ mutationFn: async (appointment: InsertAppointment) => { @@ -1784,7 +1815,7 @@ export default function AppointmentsPage() { {/* Claim for Column with AI section */} -
+
{/* Text Reminder for Column section */}