import React, { useEffect, useState } from "react"; import { Box, Button, Chip, Paper, Typography, } from "@mui/material"; import { api } from "../api"; import { JobApplication } from "../types"; import { useToast } from "../toast"; import JobDetailsDialog from "./JobDetailsDialog"; export default function RemindersView() { const { toast } = useToast(); const [items, setItems] = useState([]); const [openJobId, setOpenJobId] = useState(null); const load = async () => { const res = await api.get("/jobapplications/reminders", { params: { upcomingDays: 14 }, }); setItems(res.data); }; useEffect(() => { void load(); }, []); const setFollowUp = async (id: number, daysFromNow: number | null) => { try { const d = daysFromNow === null ? null : new Date(Date.now() + daysFromNow * 24 * 60 * 60 * 1000) .toISOString() .slice(0, 10); await api.patch(`/jobapplications/${id}/followup`, { followUpAt: d, }); toast(daysFromNow === null ? "Follow-up cleared." : "Follow-up set.", "success"); await load(); } catch { toast("Failed to set follow-up.", "error"); } }; return ( Needs Follow-up Based on your rules and upcoming follow-up dates. {items.map((j) => ( {j.company?.name ?? ""}{" "} �{" "} {j.jobTitle} {j.needsFollowUp ? ( ) : null} {j.followUpReason ? ( ) : null} {j.followUpAt ? ( ) : null} ))} {items.length === 0 && ( Nothing to follow up right now. )} setOpenJobId(null)} /> ); }