Skip to content
Merged
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
10 changes: 7 additions & 3 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,13 @@ export default function DashboardPage() {
<Skeleton className="h-40 w-full" />
</div>
) : recentClaims.length === 0 ? (
<div className="rounded-2xl border border-white/10 bg-white/[0.02] p-6 text-center text-sm text-gray-400">
No claims submitted yet.
</div>
<EmptyState
icon="📋"
title="No claims yet"
description="When you file a claim on one of your active policies, it will appear here."
actionLabel="Browse policies"
actionHref="/policies"
/>
) : (
<div className="rounded-2xl border border-white/10 bg-white/[0.02]">
<table className="w-full text-sm">
Expand Down
2 changes: 1 addition & 1 deletion src/components/BuyPolicyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export function BuyPolicyModal({ product, onClose }: Props) {
</div>
)}

{error && <p className={ERROR_TEXT}>{error}</p>}
{error && <p className={ERROR_TEXT} aria-live="polite">{error}</p>}
</div>

<div className="mt-6 flex gap-3">
Expand Down
7 changes: 5 additions & 2 deletions src/components/DepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,20 @@ export function DepositModal({ pool, onClose }: Props) {
<Modal open title={`Deposit — ${poolLabel} Pool`} onClose={onClose}>
<div className="space-y-4">
<div>
<label className={LABEL_CLASS}>
<label htmlFor="deposit-amount" className={LABEL_CLASS}>
Amount (USDC)
</label>
<input
id="deposit-amount"
type="number"
value={amount}
onChange={(e) => { setAmount(e.target.value); setError(''); }}
placeholder="0.00"
min={0}
step="0.01"
className={INPUT_CLASS}
aria-invalid={!!error}
aria-describedby={error ? 'deposit-amount-error' : undefined}
/>
</div>

Expand Down Expand Up @@ -193,7 +196,7 @@ export function DepositModal({ pool, onClose }: Props) {
{paused && (
<p className={WARNING_TEXT}>This pool is paused. Deposits are temporarily disabled.</p>
)}
{error && <p className={ERROR_TEXT}>{error}</p>}
{error && <p id="deposit-amount-error" className={ERROR_TEXT} aria-live="polite">{error}</p>}
</div>

<button
Expand Down
4 changes: 2 additions & 2 deletions src/components/PolicyCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function PolicyCardComponent({ policy }: PolicyCardProps) {
</div>
<div>
<dt className="text-gray-400">Premium paid</dt>
<dd className="mt-0.5 font-semibold">{formatUSDC(policy.premiumPaid)}</dd>
<dd className="mt-0.5 font-semibold">{policy.premiumPaid != null ? formatUSDC(policy.premiumPaid) : '—'}</dd>
</div>
<div>
<dt className="text-gray-400">Start date</dt>
Expand Down Expand Up @@ -172,7 +172,7 @@ function PolicyCardComponent({ policy }: PolicyCardProps) {
</div>
<div className="flex justify-between gap-2">
<dt className="text-gray-400 shrink-0">Premium</dt>
<dd className="text-gray-200">{formatUSDC(policy.premiumPaid)}</dd>
<dd className="text-gray-200">{policy.premiumPaid != null ? formatUSDC(policy.premiumPaid) : '—'}</dd>
</div>
<div className="flex justify-between gap-2">
<dt className="text-gray-400 shrink-0">Oracle</dt>
Expand Down
3 changes: 2 additions & 1 deletion src/components/WithdrawModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function WithdrawModal({ pool, onClose }: Props) {
min={0}
step="0.01"
aria-invalid={invalidFormat || belowMinimum}
aria-describedby="withdraw-amount-error"
className={`${INPUT_CLASS} ${invalidFormat || belowMinimum ? 'border-red-500' : ''}`}
/>
{invalidFormat && (
Expand Down Expand Up @@ -189,7 +190,7 @@ export function WithdrawModal({ pool, onClose }: Props) {
{paused && (
<p className="text-sm text-amber-400">This pool is paused. Withdrawals are temporarily disabled.</p>
)}
{error && <p className="text-sm text-red-400">{error}</p>}
{error && <p id="withdraw-amount-error" className="text-sm text-red-400" aria-live="polite">{error}</p>}
</div>

<button
Expand Down
15 changes: 12 additions & 3 deletions src/context/ThemeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ interface ThemeContextValue {
const ThemeContext = createContext<ThemeContextValue | null>(null);
const STORAGE_KEY = 'ps_theme';

// Cache the initial theme so localStorage is read only once (#732).
// React's useState lazy initializer calls this during the first render;
// the module-level cache ensures a single read even across provider remounts.
let cachedInitialTheme: Theme | null = null;

function getInitialTheme(): Theme {
if (cachedInitialTheme !== null) return cachedInitialTheme;
if (typeof window === 'undefined') return 'dark';
try {
const stored = localStorage.getItem(STORAGE_KEY);
if (stored === 'light' || stored === 'dark') return stored;
if (stored === 'light' || stored === 'dark') {
cachedInitialTheme = stored;
return stored;
}
} catch { /* ignore */ }
if (window.matchMedia?.('(prefers-color-scheme: light)').matches) return 'light';
return 'dark';
cachedInitialTheme = window.matchMedia?.('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
return cachedInitialTheme;
}

export function ThemeProvider({ children }: { children: ReactNode }) {
Expand Down
Loading