import React, { useEffect, useState } from "react"; import { Box, Button, Paper, TextField, Typography } from "@mui/material"; import { api } from "../api"; import { useToast } from "../toast"; type RuleSettings = { id: number; appliedFollowUpDays: number; appliedGhostDays: number; offerFollowUpDays: number; offerGhostDays: number; feedbackFollowUpDays: number; feedbackGhostDays: number; }; export default function RulesSettingsCard() { const { toast } = useToast(); const [s, setS] = useState(null); const [saving, setSaving] = useState(false); useEffect(() => { api.get("/rules").then((r) => setS(r.data)); }, []); const save = async () => { if (!s) return; setSaving(true); try { await api.put("/rules", s); toast("Rules saved.", "success"); } catch { toast("Failed to save rules.", "error"); } finally { setSaving(false); } }; if (!s) return null; const num = (k: keyof RuleSettings) => ({ value: s[k], onChange: (e: React.ChangeEvent) => setS((p) => (p ? { ...p, [k]: Number(e.target.value) } : p)), type: "number" as const, inputProps: { min: 1, max: 365 }, }); return ( Follow-up + Ghosting Rules Jobs get a “Follow up” flag based on these thresholds. Ghosting is automatic. ); }