Fix checkin time cutoff

This commit is contained in:
Roba Boru
2026-07-24 11:37:52 +03:00
parent 7e50668737
commit 5a89e296d6
7 changed files with 153 additions and 60 deletions

View File

@@ -2,7 +2,7 @@
import { useState, useEffect, useRef } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { Plus, Loader2, Zap, Trash2, Edit, Search, X, GripVertical } from 'lucide-react';
import { Plus, Loader2, Zap, Trash2, Edit, Search, X, GripVertical, RefreshCw } from 'lucide-react';
import DataTable from '@/components/ui/DataTable';
import ActionButton from '@/components/ui/ActionButton';
import Modal from '@/components/ui/Modal';
@@ -210,6 +210,13 @@ export default function SchedulesPage() {
},
});
const recalculateStopsMutation = useMutation({
mutationFn: (id: string) => apiClient.post(`/schedules/${id}/recalculate-stops`, {}),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['schedules'] });
},
});
const deleteScheduleMutation = useMutation({
mutationFn: ({ id, cascade }: { id: string; cascade?: boolean }) => apiClient.delete(`/schedules/${id}${cascade ? '?cascade=true' : ''}`),
onSuccess: () => {
@@ -1130,6 +1137,15 @@ export default function SchedulesPage() {
>
Cancel
</ActionButton>
<ActionButton
type="button"
variant="secondary"
icon={RefreshCw}
loading={recalculateStopsMutation.isPending}
onClick={() => editingSchedule && recalculateStopsMutation.mutate(editingSchedule.id)}
>
Recalculate Stop Times
</ActionButton>
<ActionButton type="submit" loading={updateScheduleMutation.isPending}>
Update Schedule
</ActionButton>