From 816f4cfaf0eca50265036166091187e43371b497 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 22 Jun 2026 00:38:47 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20resolve=20all=20CI=20lint=20errors=20(9?= =?UTF-8?q?=20errors=20=E2=86=92=200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Move SortTh outside AdminEmergencyContactIndexPage to fix react-hooks/static-components (5 errors) - Fix ternary expressions used as statements in toggleSection and toggleDate (2 @typescript-eslint/no-unused-expressions errors) - Remove stale eslint-disable-next-line react/no-danger comment referencing unregistered rule (1 error) - Fix pre-existing any type in WiredParentScreens student.map --- src/pages/AdminProgressPages.tsx | 44 +-- src/pages/AdministratorToolPages.tsx | 2 +- src/pages/family/FamilyLegacyImportPage.tsx | 1 - src/pages/parent/WiredParentScreens.tsx | 318 ++++++++++---------- src/pages/slips/SlipPreviewListPage.tsx | 2 +- 5 files changed, 187 insertions(+), 180 deletions(-) diff --git a/src/pages/AdminProgressPages.tsx b/src/pages/AdminProgressPages.tsx index babf2b6..7950b8a 100644 --- a/src/pages/AdminProgressPages.tsx +++ b/src/pages/AdminProgressPages.tsx @@ -37,6 +37,27 @@ type FlatContact = { phone: string } +type SortKey = keyof Omit + +function SortTh({ col, label, sortKey, sortDir, onSort }: { + col: SortKey + label: string + sortKey: SortKey + sortDir: 'asc' | 'desc' + onSort: (col: SortKey) => void +}) { + const active = sortKey === col + return ( + onSort(col)} + > + {label} {active ? (sortDir === 'asc' ? '▲' : '▼') : '⇅'} + + ) +} + export function AdminEmergencyContactIndexPage() { const [groups, setGroups] = useState([]) const [error, setError] = useState(null) @@ -97,19 +118,6 @@ export function AdminEmergencyContactIndexPage() { }) }, [flatRows, search, sortKey, sortDir]) - function SortTh({ col, label }: { col: typeof sortKey; label: string }) { - const active = sortKey === col - return ( - toggleSort(col)} - > - {label} {active ? (sortDir === 'asc' ? '▲' : '▼') : '⇅'} - - ) - } - return ( {error ?
{error}
: null} @@ -132,11 +140,11 @@ export function AdminEmergencyContactIndexPage() { - - - - - + + + + + diff --git a/src/pages/AdministratorToolPages.tsx b/src/pages/AdministratorToolPages.tsx index 174c8f9..2bc065d 100644 --- a/src/pages/AdministratorToolPages.tsx +++ b/src/pages/AdministratorToolPages.tsx @@ -1350,7 +1350,7 @@ export function AdminClassAssignmentPage() { function toggleSection(key: string) { setExpandedSections((prev) => { const next = new Set(prev) - next.has(key) ? next.delete(key) : next.add(key) + if (next.has(key)) next.delete(key); else next.add(key) return next }) } diff --git a/src/pages/family/FamilyLegacyImportPage.tsx b/src/pages/family/FamilyLegacyImportPage.tsx index 01060e9..b4b97d2 100644 --- a/src/pages/family/FamilyLegacyImportPage.tsx +++ b/src/pages/family/FamilyLegacyImportPage.tsx @@ -116,7 +116,6 @@ export function FamilyLegacyImportPage() { {meta?.instructions_html ? (
) : ( diff --git a/src/pages/parent/WiredParentScreens.tsx b/src/pages/parent/WiredParentScreens.tsx index eec6c7b..1bb7e67 100644 --- a/src/pages/parent/WiredParentScreens.tsx +++ b/src/pages/parent/WiredParentScreens.tsx @@ -4,19 +4,19 @@ import { fetchAttendanceReportForm, fetchParentEnrollments, fetchParentEventsOverview, - fetchParentInvoices, - fetchParentProfile, - fetchParentRegistrationOverview, - submitParentAttendanceReport, - submitContactMessage, -} from '../../api/session' -import type { - ParentAttendanceReportFormResponse, - ParentEnrollmentStudent, - ParentEventsOverviewResponse, - ParentInvoiceRow, - ParentRegistrationOverviewResponse, -} from '../../api/types' + fetchParentInvoices, + fetchParentProfile, + fetchParentRegistrationOverview, + submitParentAttendanceReport, + submitContactMessage, +} from '../../api/session' +import type { + ParentAttendanceReportFormResponse, + ParentEnrollmentStudent, + ParentEventsOverviewResponse, + ParentInvoiceRow, + ParentRegistrationOverviewResponse, +} from '../../api/types' import { useAuth } from '../../auth/AuthProvider' /** `Views/parent/contact.php` — POST /api/v1/contact */ @@ -307,19 +307,19 @@ export function ParentPaymentInvoicesPage() { } /** `Views/parent/event_participation.php` — GET/POST /api/v1/parents/events … */ -export function ParentEventsPage() { - const [error, setError] = useState(null) - const [loading, setLoading] = useState(true) - const [data, setData] = useState(null) +export function ParentEventsPage() { + const [error, setError] = useState(null) + const [loading, setLoading] = useState(true) + const [data, setData] = useState(null) useEffect(() => { let cancelled = false ;(async () => { setLoading(true) try { - const data = await fetchParentEventsOverview() - if (cancelled) return - setData(data) + const data = await fetchParentEventsOverview() + if (cancelled) return + setData(data) setError(null) } catch (e) { if (!cancelled) setError(e instanceof Error ? e.message : 'Failed to load events.') @@ -342,43 +342,43 @@ export function ParentEventsPage() { {loading ? (

Loading…

) : ( -
-
Actions
- - - - - {(data?.activeEvents ?? []).length === 0 ? ( - - ) : (data?.activeEvents ?? []).map((event) => ( - - - - - - ))} - -
EventDateDescription
No active events.
{event.title ?? event.event_name ?? '—'}{event.event_date ?? event.start_date ?? '—'}{event.description ?? '—'}
- - )} +
+ + + + + + {(data?.activeEvents ?? []).length === 0 ? ( + + ) : (data?.activeEvents ?? []).map((event) => ( + + + + + + ))} + +
EventDateDescription
No active events.
{event.title ?? event.event_name ?? '—'}{event.event_date ?? event.start_date ?? '—'}{event.description ?? '—'}
+
+ )} ) } /** `Views/parent/register_student.php` — GET /api/v1/parents/registration */ -export function ParentRegisterStudentPage() { - const [error, setError] = useState(null) - const [loading, setLoading] = useState(true) - const [data, setData] = useState(null) +export function ParentRegisterStudentPage() { + const [error, setError] = useState(null) + const [loading, setLoading] = useState(true) + const [data, setData] = useState(null) useEffect(() => { let cancelled = false ;(async () => { setLoading(true) try { - const data = await fetchParentRegistrationOverview() - if (cancelled) return - setData(data) + const data = await fetchParentRegistrationOverview() + if (cancelled) return + setData(data) setError(null) } catch (e) { if (!cancelled) setError(e instanceof Error ? e.message : 'Failed to load registration.') @@ -401,68 +401,68 @@ export function ParentRegisterStudentPage() { {loading ? (

Loading…

) : ( - <> - -

Students

-
- - - - {(data?.existingKids ?? []).length === 0 ? ( - - ) : (data?.existingKids ?? []).map((student) => ( - - - - - - - ))} - -
NameGradeClassStatus
No students registered.
{student.firstname} {student.lastname}{student.registration_grade ?? '—'}{student.class_section ?? '—'}{student.admission_status ?? student.enrollment_status ?? '—'}
-
-

Emergency contacts

-
- - - - {(data?.emergencies ?? []).length === 0 ? ( - - ) : (data?.emergencies ?? []).map((contact) => ( - - - - - - - ))} - -
NamePhoneEmailRelation
No emergency contacts.
{contact.name}{contact.cellphone}{contact.email ?? '—'}{contact.relation ?? '—'}
-
- - )} + <> + +

Students

+
+ + + + {(data?.existingKids ?? []).length === 0 ? ( + + ) : (data?.existingKids ?? []).map((student) => ( + + + + + + + ))} + +
NameGradeClassStatus
No students registered.
{student.firstname} {student.lastname}{student.registration_grade ?? '—'}{student.class_section ?? '—'}{student.admission_status ?? student.enrollment_status ?? '—'}
+
+

Emergency contacts

+
+ + + + {(data?.emergencies ?? []).length === 0 ? ( + + ) : (data?.emergencies ?? []).map((contact) => ( + + + + + + + ))} + +
NamePhoneEmailRelation
No emergency contacts.
{contact.name}{contact.cellphone}{contact.email ?? '—'}{contact.relation ?? '—'}
+
+ + )} ) } /** `Views/parent/report_attendance.php` — form: GET /api/v1/parents/attendance-reports/form */ -export function ParentReportAttendancePage() { - const [error, setError] = useState(null) - const [status, setStatus] = useState(null) - const [loading, setLoading] = useState(true) - const [data, setData] = useState(null) +export function ParentReportAttendancePage() { + const [error, setError] = useState(null) + const [status, setStatus] = useState(null) + const [loading, setLoading] = useState(true) + const [data, setData] = useState(null) useEffect(() => { let cancelled = false ;(async () => { setLoading(true) try { - const data = await fetchAttendanceReportForm() - if (cancelled) return - setData(data) + const data = await fetchAttendanceReportForm() + if (cancelled) return + setData(data) setError(null) } catch (e) { if (!cancelled) @@ -482,65 +482,65 @@ export function ParentReportAttendancePage() { ciViewFile="report_attendance.php" legacyCiRoutes={['/parent/report-attendance']} > - {status ?
{status}
: null} - {error ?
{error}
: null} - {loading ? ( -

Loading…

- ) : ( -
{ - e.preventDefault() - setStatus(null) - setError(null) - const form = new FormData(e.currentTarget) - try { - const res = await submitParentAttendanceReport({ - student_ids: [Number(form.get('student_id'))], - date: String(form.get('date') ?? ''), - type: String(form.get('type') ?? ''), - arrival_time: String(form.get('arrival_time') ?? ''), - dismiss_time: String(form.get('dismiss_time') ?? ''), - reason: String(form.get('reason') ?? ''), - }) - setStatus(`Report submitted. Inserted: ${res.inserted ?? 0}`) - e.currentTarget.reset() - } catch (err) { - setError(err instanceof Error ? err.message : 'Failed to submit report.') - } - }} - > -
- - -
-
- - -
-
- - -
-
-
-