Fix Dashboard.tsx: update Schedule refs to ShiftInstance
All checks were successful
CI / Go tests & lint (push) Successful in 8s
CI / Frontend tests & type-check (push) Successful in 38s
CI / Go tests & lint (pull_request) Successful in 8s
CI / Frontend tests & type-check (pull_request) Successful in 38s

Replace removed Schedule type and api.listSchedules() with
ShiftInstance and api.listShifts() after the schedule rewrite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-08 11:48:47 -03:00
parent fc88b8f005
commit 9905234b34

View File

@@ -1,24 +1,25 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { api, CheckIn, Notification, Schedule } from '../api'; import { api, CheckIn, Notification, ShiftInstance } from '../api';
import { useAuth } from '../auth'; import { useAuth } from '../auth';
export default function Dashboard() { export default function Dashboard() {
const { volunteerID } = useAuth(); const { volunteerID } = useAuth();
const [schedules, setSchedules] = useState<Schedule[]>([]); const now = new Date();
const [schedules, setSchedules] = useState<ShiftInstance[]>([]);
const [notifications, setNotifications] = useState<Notification[]>([]); const [notifications, setNotifications] = useState<Notification[]>([]);
const [activeCheckIn, setActiveCheckIn] = useState<CheckIn | null>(null); const [activeCheckIn, setActiveCheckIn] = useState<CheckIn | null>(null);
const [history, setHistory] = useState<CheckIn[]>([]); const [history, setHistory] = useState<CheckIn[]>([]);
const [error, setError] = useState(''); const [error, setError] = useState('');
useEffect(() => { useEffect(() => {
api.listSchedules().then(setSchedules).catch(() => {}); api.listShifts(now.getFullYear(), now.getMonth() + 1).then(setSchedules).catch(() => {});
api.listNotifications().then(setNotifications).catch(() => {}); api.listNotifications().then(setNotifications).catch(() => {});
api.getHistory().then(data => { api.getHistory().then(data => {
setHistory(data); setHistory(data);
const active = data.find(c => !c.checked_out_at && c.volunteer_id === volunteerID); const active = data.find(c => !c.checked_out_at && c.volunteer_id === volunteerID);
setActiveCheckIn(active ?? null); setActiveCheckIn(active ?? null);
}).catch(() => {}); }).catch(() => {});
}, [volunteerID]); }, [volunteerID]); // eslint-disable-line react-hooks/exhaustive-deps
async function handleCheckIn() { async function handleCheckIn() {
try { try {
@@ -48,7 +49,7 @@ export default function Dashboard() {
} }
const upcomingSchedules = schedules const upcomingSchedules = schedules
.filter(s => new Date(s.starts_at) >= new Date()) .filter(s => new Date(s.date) >= now)
.slice(0, 5); .slice(0, 5);
const unreadNotifications = notifications.filter(n => !n.read); const unreadNotifications = notifications.filter(n => !n.read);
@@ -78,7 +79,7 @@ export default function Dashboard() {
<ul> <ul>
{upcomingSchedules.map(s => ( {upcomingSchedules.map(s => (
<li key={s.id}> <li key={s.id}>
<strong>{s.title}</strong> {new Date(s.starts_at).toLocaleString()} to {new Date(s.ends_at).toLocaleString()} <strong>{s.name}</strong> {s.date} {s.start_time.slice(0, 5)}{s.end_time.slice(0, 5)}
</li> </li>
))} ))}
</ul> </ul>