fix: react-doctor js-set-map-lookups 1→0, no-barrel-import 1→0, prefer-module-scope-static-value 1→0, rendering-usetransition-loading 1→0, exhaustive-deps 3→0, rerender-state-only-in-handlers 5→0

This commit is contained in:
Nora
2026-06-26 06:52:45 -06:00
parent 3d5988afd0
commit ce2dc8f070
11 changed files with 76 additions and 41 deletions
+15 -16
View File
@@ -10,13 +10,6 @@ import StopsDatePicker from "@/components/admin/stops/StopsDatePicker";
export const dynamic = "force-dynamic";
const emptyGrouped: Record<TimeBucket, readonly DbStopRow[]> = {
Morning: [],
Afternoon: [],
Evening: [],
Anytime: [],
} as const;
/**
* Row shape returned from the stops query. The legacy `stops` table uses
* separate `date` (DATE) and `time` (TEXT) columns, not a combined
@@ -93,6 +86,20 @@ function bucketFor(time: string | null): TimeBucket {
const BUCKET_ORDER: TimeBucket[] = ["Morning", "Afternoon", "Evening", "Anytime"];
/** Bucket a list of stops into the four time-of-day groups. */
function groupStopsByBucket(stops: DbStopRow[]): Record<TimeBucket, DbStopRow[]> {
const grouped: Record<TimeBucket, DbStopRow[]> = {
Morning: [],
Afternoon: [],
Evening: [],
Anytime: [],
};
for (const s of stops) {
grouped[bucketFor(s.time)].push(s);
}
return grouped;
}
/** Build a Google Maps directions URL for a stop's address. */
function mapsUrlFor(stop: DbStopRow): string | null {
const parts = [stop.address, stop.city, stop.state, stop.zip].filter(Boolean);
@@ -252,15 +259,7 @@ export default async function StopsV2Page({
}
// Group by time-of-day bucket. Use Map to preserve insertion order.
const grouped: Record<TimeBucket, DbStopRow[]> = {
Morning: [...emptyGrouped.Morning],
Afternoon: [...emptyGrouped.Afternoon],
Evening: [...emptyGrouped.Evening],
Anytime: [...emptyGrouped.Anytime],
};
for (const s of stops) {
grouped[bucketFor(s.time)].push(s);
}
const grouped = groupStopsByBucket(stops);
return (
<main>
+3 -3
View File
@@ -1508,7 +1508,7 @@ function OrdersTab({ orders, customers, brandId, onMsg, onRefresh }: {
const [openActions, setOpenActions] = useState<string | null>(null);
const [showViewOrder, setShowViewOrder] = useState<WholesaleOrder | null>(null);
const [deleting, setDeleting] = useState<string | null>(null);
const deletingRef = useRef<string | null>(null);
// Close actions dropdown when clicking outside
useEffect(() => {
@@ -1552,10 +1552,10 @@ function OrdersTab({ orders, customers, brandId, onMsg, onRefresh }: {
async function handleDeleteOrder(orderId: string) {
if (!confirm("Delete this order? Fulfilled and paid orders cannot be deleted. This cannot be undone.")) return;
setDeleting(orderId);
deletingRef.current = orderId;
const { deleteWholesaleOrder } = await import("@/actions/wholesale");
const result = await deleteWholesaleOrder(orderId);
setDeleting(null);
deletingRef.current = null;
if (result.success) {
onMsg("success", "Order deleted.");
onRefresh();
+2 -2
View File
@@ -442,7 +442,7 @@ export default function TuxedoPage() {
const [showSchedulePdf, setShowSchedulePdf] = useState(true);
const [showWholesaleLink, setShowWholesaleLink] = useState(true);
const [heroTagline, setHeroTagline] = useState<string | null>(null);
const [heroImageUrl, setHeroImageUrl] = useState<string | null>(null);
const heroImageUrlRef = useRef<string | null>(null);
const [isAdmin, setIsAdmin] = useState(false);
const [customFooterText, setCustomFooterText] = useState<string | null>(null);
const [contactEmail, setContactEmail] = useState<string | null>(null);
@@ -472,7 +472,7 @@ export default function TuxedoPage() {
setLogoUrlDark(s.logo_url_dark ?? null);
setOlatheSweetLogoUrl(s.olathe_sweet_logo_url ?? null);
setOlatheSweetLogoUrlDark(s.olathe_sweet_logo_url_dark ?? null);
setHeroImageUrl(s.hero_image_url ?? null);
heroImageUrlRef.current = s.hero_image_url ?? null;
setHeroTagline(s.hero_tagline ?? null);
setCustomFooterText(s.custom_footer_text ?? null);
setContactEmail(s.email ?? null);