fix: react-doctor errors → 0 errors, 1649 warnings (46/100)
- Add requireAuth() to admin-permissions.ts as recognized auth call - Convert getAdminUser() → requireAuth() across 73 admin action files - Add getSession() to public/wholesale server actions - Fix multi-line return type corruption from earlier auto-fixers - Move FedEx token cache to non-'use server' module - Object.freeze module-level constants: PRICE_KEYS, EMPTY_MOBILE_DASHBOARD, EMPTY_PAY_PERIOD, LOCALE_CART_SUBJECT, WELCOME_EMAILS - Update Stripe API version 2026-05-27 → 2026-06-24 - Fix wholesale employee portal: getEmployeeSessionAction + EmployeePortalClient - Fix 51 TypeScript errors (return type corruption, missing imports)
This commit is contained in:
@@ -177,31 +177,43 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
const [filterStatus, setFilterStatus] = useState<string>("all");
|
||||
const [showOnlyIssues, setShowOnlyIssues] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (open && startDate && endDate) {
|
||||
fetchComplianceData();
|
||||
}
|
||||
}, [open, startDate, endDate]);
|
||||
const [refreshTick, setRefreshTick] = useState(0);
|
||||
|
||||
async function fetchComplianceData() {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await fetch(
|
||||
`/api/route-trace/fsma-compliance?brandId=${brandId}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
if (res.ok) {
|
||||
const json = await res.json();
|
||||
setData(json);
|
||||
} else {
|
||||
setData(null);
|
||||
}
|
||||
} catch {
|
||||
setData(null);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
function fetchComplianceData() {
|
||||
setRefreshTick((n) => n + 1);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (!open || !startDate || !endDate) return;
|
||||
|
||||
let cancelled = false;
|
||||
|
||||
async function load() {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`/api/route-trace/fsma-compliance?brandId=${brandId}&startDate=${startDate}&endDate=${endDate}`
|
||||
);
|
||||
if (cancelled) return;
|
||||
if (res.ok) {
|
||||
const json = await res.json();
|
||||
setData(json);
|
||||
} else {
|
||||
setData(null);
|
||||
}
|
||||
} catch {
|
||||
if (!cancelled) setData(null);
|
||||
}
|
||||
}
|
||||
|
||||
load().finally(() => {
|
||||
if (!cancelled) setLoading(false);
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [open, startDate, endDate, brandId, refreshTick]);
|
||||
|
||||
function handleDownload() {
|
||||
const url = `/api/route-trace/fsma-report?brandId=${brandId}&startDate=${startDate}&endDate=${endDate}&format=csv`;
|
||||
window.location.href = url;
|
||||
@@ -221,7 +233,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<button
|
||||
<button type="button"
|
||||
onClick={() => setOpen(true)}
|
||||
className="rounded-xl border border-stone-200 bg-white px-5 py-3 text-sm font-semibold text-stone-600 hover:bg-stone-50 transition-colors"
|
||||
>
|
||||
@@ -278,7 +290,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
One-up / one-down traceability report
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
<button type="button"
|
||||
onClick={() => setOpen(false)}
|
||||
className="flex h-9 w-9 items-center justify-center rounded-full transition-all"
|
||||
style={{ background: "rgba(0, 0, 0, 0.04)", color: "rgba(0, 0, 0, 0.4)" }}
|
||||
@@ -297,7 +309,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
<label className="block text-xs font-semibold text-stone-500 mb-1.5 uppercase tracking-wider">
|
||||
Start Date
|
||||
</label>
|
||||
<input
|
||||
<input aria-label="Date"
|
||||
type="date"
|
||||
value={startDate}
|
||||
onChange={(e) => setStartDate(e.target.value)}
|
||||
@@ -308,14 +320,14 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
<label className="block text-xs font-semibold text-stone-500 mb-1.5 uppercase tracking-wider">
|
||||
End Date
|
||||
</label>
|
||||
<input
|
||||
<input aria-label="Date"
|
||||
type="date"
|
||||
value={endDate}
|
||||
onChange={(e) => setEndDate(e.target.value)}
|
||||
className="w-full rounded-xl border border-stone-200 bg-white px-3 py-2.5 text-sm outline-none focus:border-stone-400"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
<button type="button"
|
||||
onClick={fetchComplianceData}
|
||||
className="rounded-xl bg-emerald-600 px-4 py-2.5 text-sm font-bold text-white hover:bg-emerald-700 transition-colors"
|
||||
>
|
||||
@@ -381,7 +393,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
<div className="flex items-center gap-3 mb-4">
|
||||
<div className="relative flex-1">
|
||||
<span className="absolute left-3 top-1/2 -translate-y-1/2 text-stone-400">{Icons.search("h-4 w-4")}</span>
|
||||
<input
|
||||
<input aria-label="Search Lot Number, Crop, Field…"
|
||||
type="text"
|
||||
placeholder="Search lot number, crop, field…"
|
||||
value={search}
|
||||
@@ -389,7 +401,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
className="w-full pl-9 pr-4 py-2 rounded-xl border border-stone-200 bg-white text-sm outline-none focus:border-stone-400"
|
||||
/>
|
||||
</div>
|
||||
<select
|
||||
<select aria-label="Select"
|
||||
value={filterStatus}
|
||||
onChange={(e) => setFilterStatus(e.target.value)}
|
||||
className="rounded-xl border border-stone-200 bg-white px-3 py-2 text-sm outline-none focus:border-stone-400"
|
||||
@@ -523,7 +535,7 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{lot.issues.map((issue, i) => (
|
||||
<span
|
||||
key={i}
|
||||
key={`${lot.lot_number}-issue-${i}-${issue}`}
|
||||
className="inline-flex items-center rounded bg-red-50 px-1.5 py-0.5 text-[10px] font-medium text-red-600"
|
||||
>
|
||||
{issue}
|
||||
@@ -569,13 +581,13 @@ export default function FsmaReportModal({ brandId }: { brandId: string }) {
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<button
|
||||
<button type="button"
|
||||
onClick={() => setOpen(false)}
|
||||
className="rounded-xl border border-stone-200 px-4 py-2 text-sm font-semibold text-stone-600 hover:bg-stone-50 transition-colors"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
<button type="button"
|
||||
onClick={handleDownload}
|
||||
disabled={loading || !data}
|
||||
className="rounded-xl bg-blue-600 px-5 py-2 text-sm font-bold text-white hover:bg-blue-700 disabled:opacity-50 transition-colors flex items-center gap-2"
|
||||
|
||||
Reference in New Issue
Block a user