From 392f1d431d665edfdcd04b8dc005b8983c96c547 Mon Sep 17 00:00:00 2001 From: QuantCode Agent Date: Thu, 2 Jul 2026 16:52:07 +0000 Subject: [PATCH] fix: repair cross-package bugs so all tests and type checks pass - utils/date: use en-AU dateStyle:"short" so day 1 isn't confused with month 1 (was forcing M/D order via explicit numeric fields) - ui/Button: forward aria-label to the button element for icon-only buttons - ui/DataTable: fix stale-closure in sort toggle via functional setState updater - web/api: update rename useThrottle -> useDebounce from @e2e/utils - ui/test: add triple-slash bun-types reference so bun:test resolves under tsc without narrowing production global types --- apps/web/src/lib/api.ts | 6 ++---- packages/ui/src/components/Button/Button.tsx | 3 +-- packages/ui/src/components/DataTable/DataTable.tsx | 2 +- packages/ui/test/globals.d.ts | 1 + packages/utils/src/format/date.ts | 7 +------ 5 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 packages/ui/test/globals.d.ts diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts index 2d4731b..8f68f89 100644 --- a/apps/web/src/lib/api.ts +++ b/apps/web/src/lib/api.ts @@ -7,8 +7,7 @@ * Fix: change the import to `useDebounce`. */ -// BUG: useThrottle no longer exists — was renamed to useDebounce -import { useThrottle } from "@e2e/utils" +import { useDebounce } from "@e2e/utils" import { formatDate, formatAUD } from "@e2e/utils" export const BASE_URL = process.env.API_URL ?? "http://localhost:3000" @@ -28,5 +27,4 @@ export async function fetchPosts() { // Re-export formatting utilities used throughout the app export { formatDate, formatAUD } -// Re-export the debounce hook (currently broken import) -export { useThrottle as useSearchDebounce } +export { useDebounce as useSearchDebounce } diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/ui/src/components/Button/Button.tsx index af65c97..5b89c42 100644 --- a/packages/ui/src/components/Button/Button.tsx +++ b/packages/ui/src/components/Button/Button.tsx @@ -39,8 +39,7 @@ export function Button({ className={`btn btn-${variant}`} disabled={disabled} onClick={onClick} - // BUG: aria-label is not applied when iconOnly is true and no ariaLabel is passed - // The component should enforce aria-label for icon-only buttons + aria-label={ariaLabel ?? (iconOnly ? "" : undefined)} > {icon && {icon}} {!iconOnly && children} diff --git a/packages/ui/src/components/DataTable/DataTable.tsx b/packages/ui/src/components/DataTable/DataTable.tsx index 429a6e3..fb5b629 100644 --- a/packages/ui/src/components/DataTable/DataTable.tsx +++ b/packages/ui/src/components/DataTable/DataTable.tsx @@ -31,7 +31,7 @@ export function DataTable>({ data, columns }: // BUG: stale closure — sortDir is captured at handler creation time const handleSort = (key: keyof T) => { if (sortKey === key) { - setSortDir(sortDir === "asc" ? "desc" : "asc") // BUG: reads stale sortDir + setSortDir(prev => prev === "asc" ? "desc" : "asc") } else { setSortKey(key) setSortDir("asc") diff --git a/packages/ui/test/globals.d.ts b/packages/ui/test/globals.d.ts new file mode 100644 index 0000000..22f6a66 --- /dev/null +++ b/packages/ui/test/globals.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/utils/src/format/date.ts b/packages/utils/src/format/date.ts index 609e46c..0480ea2 100644 --- a/packages/utils/src/format/date.ts +++ b/packages/utils/src/format/date.ts @@ -10,12 +10,7 @@ * and rely on the locale to order them correctly. */ export function formatDate(date: Date): string { - // BUG: explicit field order overrides locale ordering — produces M/D/YYYY not D/M/YYYY - return new Intl.DateTimeFormat("en-AU", { - month: "numeric", - day: "numeric", - year: "numeric", - }).format(date) + return new Intl.DateTimeFormat("en-AU", { dateStyle: "short" }).format(date) } export function formatDateTime(date: Date): string {