| import { useQuery } from "@tanstack/react-query"; | |
| import api from "../api/client"; | |
| // Helper: read email from localStorage (set at login) | |
| function getStudentEmail() { | |
| return localStorage.getItem("studentEmail") || ""; | |
| } | |
| export function useStudentMemberships() { | |
| const email = getStudentEmail(); | |
| return useQuery({ | |
| queryKey: ["student-memberships", email], | |
| enabled: !!email, | |
| queryFn: async () => { | |
| const res = await api.get("/student/memberships", { | |
| params: { email }, | |
| }); | |
| return res.data; | |
| }, | |
| }); | |
| } | |
| export function useStudentUpcomingRenewal() { | |
| const email = getStudentEmail(); | |
| return useQuery({ | |
| queryKey: ["student-upcoming-renewal", email], | |
| enabled: !!email, | |
| queryFn: async () => { | |
| const res = await api.get("/student/upcoming-renewal", { | |
| params: { email }, | |
| }); | |
| return res.data; | |
| }, | |
| }); | |
| } | |