Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/web/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// 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"
Expand All @@ -29,4 +29,4 @@ export async function fetchPosts() {
export { formatDate, formatAUD }

// Re-export the debounce hook (currently broken import)
export { useThrottle as useSearchDebounce }
export { useDebounce as useSearchDebounce }
16 changes: 5 additions & 11 deletions packages/ui/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import React from "react"

type Variant = "primary" | "secondary" | "danger"

type Props = {
type Props = React.ButtonHTMLAttributes<HTMLButtonElement> & {
children?: React.ReactNode
/** Icon-only button — renders without visible text. Requires aria-label for accessibility. */
icon?: React.ReactNode
iconOnly?: boolean
variant?: Variant
disabled?: boolean
onClick?: () => void
/** Accessible label — REQUIRED when iconOnly is true */
"aria-label"?: string
}

/**
Expand All @@ -30,17 +26,15 @@ export function Button({
icon,
iconOnly = false,
variant = "primary",
disabled = false,
onClick,
"aria-label": ariaLabel,
...rest
}: Props) {
const resolvedAriaLabel = ariaLabel ?? (iconOnly ? "icon button" : undefined)
return (
<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={resolvedAriaLabel}
{...rest}
>
{icon && <span className="btn-icon">{icon}</span>}
{!iconOnly && children}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function DataTable<T extends Record<string, unknown>>({ 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")
Expand Down
37 changes: 16 additions & 21 deletions packages/utils/src/format/date.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
/**
* Date formatting utilities.
*
* BUG: formatDate passes `'en-AU'` as the locale but then uses a US-style
* format string option (`month: 'numeric'` before `day: 'numeric'`), which
* produces MM/DD/YYYY output instead of DD/MM/YYYY for Australian dates.
*
* Fix: use `dateStyle: 'short'` with `'en-AU'` locale, which correctly
* produces DD/MM/YYYY, or explicitly set `day: 'numeric', month: 'numeric', year: 'numeric'`
* and rely on the locale to order them correctly.
*/
const DATE_FIELDS: Intl.DateTimeFormatOptions = {
day: "2-digit",
month: "2-digit",
year: "numeric",
}

function formatDateParts(date: Date, extra?: Intl.DateTimeFormatOptions): string {
const opts = extra ? { ...DATE_FIELDS, ...extra } : DATE_FIELDS
const parts = new Intl.DateTimeFormat("en-AU", opts).formatToParts(date)
return parts
.map((p) => (p.type === "day" ? String(parseInt(p.value, 10)) : p.value))
.join("")
}

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 formatDateParts(date)
}

export function formatDateTime(date: Date): string {
return new Intl.DateTimeFormat("en-AU", {
dateStyle: "short",
timeStyle: "short",
}).format(date)
return formatDateParts(date, { hour: "2-digit", minute: "2-digit" })
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"jsx": "react-jsx",
"strict": true,
"skipLibCheck": true,
"types": ["bun-types"],
"paths": {
"@e2e/ui": ["./packages/ui/src/index.ts"],
"@e2e/utils": ["./packages/utils/src/index.ts"]
Expand Down