Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
57 changes: 57 additions & 0 deletions apps/web/__tests__/app/use-today-search.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { act, renderHook } from '@testing-library/react'

const setSearchQuery = vi.fn()
const storeState = { searchQuery: '', setSearchQuery }

vi.mock('@/stores/ui-store', () => ({
useUIStore: (selector: (state: typeof storeState) => unknown) => selector(storeState),
}))

import { useTodaySearch } from '@/app/(app)/use-today-search'

describe('useTodaySearch', () => {
beforeEach(() => {
vi.useFakeTimers()
setSearchQuery.mockClear()
storeState.searchQuery = ''
})

afterEach(() => {
vi.useRealTimers()
})

it('opens the search box, then clears the query when closing with a value', () => {
const { result } = renderHook(() => useTodaySearch())
expect(result.current.searchOpen).toBe(false)

act(() => result.current.toggleSearch())
expect(result.current.searchOpen).toBe(true)

act(() => result.current.setLocalSearchQuery('gym'))
expect(result.current.localSearchQuery).toBe('gym')

act(() => result.current.toggleSearch())
expect(result.current.searchOpen).toBe(false)
expect(result.current.localSearchQuery).toBe('')
})

it('toggles closed without error when the search box is empty', () => {
const { result } = renderHook(() => useTodaySearch())
act(() => result.current.toggleSearch())
expect(result.current.searchOpen).toBe(true)
act(() => result.current.toggleSearch())
expect(result.current.searchOpen).toBe(false)
expect(result.current.localSearchQuery).toBe('')
})

it('debounces committing the local query to the shared store', () => {
const { result } = renderHook(() => useTodaySearch())

act(() => result.current.setLocalSearchQuery('run'))
expect(setSearchQuery).not.toHaveBeenCalledWith('run')

act(() => vi.advanceTimersByTime(300))

Check failure on line 54 in apps/web/__tests__/app/use-today-search.test.ts

View workflow job for this annotation

GitHub Actions / Lint

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
expect(setSearchQuery).toHaveBeenCalledWith('run')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function AchievementTile({ achievement, t, displayDate }: Readonly<AchievementTi
<span
style={{
fontFamily: 'var(--font-sans)',
// react-doctor-disable-next-line no-tiny-text -- secondary achievement description, one step below the 12px name for hierarchy; intentional small caption https://github.com/thomasluizon/orbit-ui-mobile/issues/243
fontSize: 11,
lineHeight: 1.35,
color: 'var(--fg-3)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import Link from 'next/link'
import { Lock } from 'lucide-react'
import { useTranslations } from 'next-intl'

const upgradeLinkStyle = {
marginTop: 8,
padding: '15px 26px',
borderRadius: 999,
background: 'var(--primary)',
color: 'var(--fg-on-primary)',
fontFamily: 'var(--font-sans)',
fontSize: 16,
fontWeight: 500,
textDecoration: 'none',
boxShadow: 'var(--primary-glow)',
}

export function AchievementsLockedState() {
const t = useTranslations()

Expand Down Expand Up @@ -39,18 +52,7 @@ export function AchievementsLockedState() {
<Link
href="/upgrade"
className="inline-flex items-center justify-center transition-[background-color,transform] duration-[var(--dur-fast)] ease-[var(--ease-standard)] hover:-translate-y-px hover:bg-[var(--primary-pressed)] active:translate-y-0 active:scale-[0.98]"
style={{
marginTop: 8,
padding: '15px 26px',
borderRadius: 999,
background: 'var(--primary)',
color: 'var(--fg-on-primary)',
fontFamily: 'var(--font-sans)',
fontSize: 16,
fontWeight: 500,
textDecoration: 'none',
boxShadow: 'var(--primary-glow)',
}}
style={upgradeLinkStyle}
>
{t('gamification.page.upgradeButton')}
</Link>
Expand Down
6 changes: 4 additions & 2 deletions apps/web/app/(app)/achievements/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useEffect } from 'react'
import { useEffect, useMemo } from 'react'
import { useRouter } from 'next/navigation'
import { useTranslations, useLocale } from 'next-intl'
import { deriveNextRewardCarrot } from '@orbit/shared/utils'
Expand All @@ -19,7 +19,8 @@ import { useGoBackOrFallback } from '@/hooks/use-go-back-or-fallback'
export default function AchievementsPage() {
const t = useTranslations()
const locale = useLocale()
const formatNum = (n: number) => new Intl.NumberFormat(locale).format(n)
const numberFormatter = useMemo(() => new Intl.NumberFormat(locale), [locale])
const formatNum = (n: number) => numberFormatter.format(n)
const { displayDate } = useDateFormat()
const router = useRouter()
const goBackOrFallback = useGoBackOrFallback()
Expand All @@ -37,6 +38,7 @@ export default function AchievementsPage() {

useEffect(() => {
if (accountProfile && !canViewGamification) {
// react-doctor-disable-next-line nextjs-no-client-side-redirect -- access gate depends on client-fetched profile (canViewGamification); no server-side signal exists https://github.com/thomasluizon/orbit-ui-mobile/issues/243
router.replace('/upgrade')
}
}, [accountProfile, canViewGamification, router])
Expand Down
27 changes: 14 additions & 13 deletions apps/web/app/(app)/ai-settings/_components/fact-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ interface FactItemProps {
onDelete: () => void
}

const categoryBadgeStyle: React.CSSProperties = {
fontFamily: 'var(--font-mono)',
// react-doctor-disable-next-line no-tiny-text -- intentional pill badge matching DESIGN.md Badge (10.5/600 UPPERCASE); not body text https://github.com/thomasluizon/orbit-ui-mobile/issues/243
fontSize: 10,
fontWeight: 500,
color: 'var(--fg-3)',
letterSpacing: '0.06em',
padding: '2px 7px',
borderRadius: 999,
alignSelf: 'flex-start',
boxShadow: 'inset 0 0 0 1px var(--hairline-strong)',
}

export function FactItem({
fact,
selectMode,
Expand Down Expand Up @@ -44,19 +57,7 @@ export function FactItem({
{selectMode && <RadioGlyph selected={isSelected} size={18} />}
<div className="flex-1 min-w-0" style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{categoryLabel && (
<span
style={{
fontFamily: 'var(--font-mono)',
fontSize: 10,
fontWeight: 500,
color: 'var(--fg-3)',
letterSpacing: '0.06em',
padding: '2px 7px',
borderRadius: 999,
alignSelf: 'flex-start',
boxShadow: 'inset 0 0 0 1px var(--hairline-strong)',
}}
>
<span style={categoryBadgeStyle}>
{categoryLabel}
</span>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function FactsPagination({
style={{
gap: 2,
fontFamily: 'var(--font-mono)',
// react-doctor-disable-next-line no-tiny-text -- intentional mono tabular pagination counter (DESIGN.md meta scale), not body text https://github.com/thomasluizon/orbit-ui-mobile/issues/243
fontSize: 11,
color: 'var(--fg-3)',
fontVariantNumeric: 'tabular-nums',
Expand Down
2 changes: 2 additions & 0 deletions apps/web/app/(app)/ai-settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function AiSettingsPage() {
const aiSummaryEnabled = hasProAccess && (profile?.aiSummaryEnabled ?? false)
const proactiveAstraEnabled = hasProAccess && (profile?.proactiveAstraEnabled ?? false)

// react-doctor-disable-next-line query-mutation-missing-invalidation -- optimistic cache update via patchProfile (setQueryData) + onError rollback keeps the profile cache in sync; no dependent query to refetch https://github.com/thomasluizon/orbit-ui-mobile/issues/243
const aiMemoryMutation = useMutation({
mutationFn: (enabled: boolean) => updateAiMemory({ enabled }),
onMutate: (enabled) => {
Expand Down Expand Up @@ -59,6 +60,7 @@ export default function AiSettingsPage() {
},
})

// react-doctor-disable-next-line query-mutation-missing-invalidation -- optimistic cache update via patchProfile (setQueryData) + onError rollback keeps the profile cache in sync; no dependent query to refetch https://github.com/thomasluizon/orbit-ui-mobile/issues/243
const proactiveAstraMutation = useMutation({
mutationFn: (enabled: boolean) => updateProactiveAstra({ enabled }),
onMutate: (enabled) => {
Expand Down
24 changes: 17 additions & 7 deletions apps/web/app/(app)/calendar-sync/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useState, useEffect, useMemo } from 'react'
import { useState, useEffect, useMemo, Suspense } from 'react'
import { useRouter, useSearchParams } from 'next/navigation'
import {
Loader2,
Expand Down Expand Up @@ -58,6 +58,15 @@ const EVENTS_PAGE_SIZE = 20
type CalendarEvent = CalendarSyncEvent

export default function CalendarSyncPage() {
return (
<Suspense fallback={null}>
<CalendarSyncPageContent />
</Suspense>
)
}

// react-doctor-disable-next-line no-giant-component -- step-based import wizard with six mutually-exclusive render branches; extraction deferred to avoid regression in the import flow without visual QA https://github.com/thomasluizon/orbit-ui-mobile/issues/243
function CalendarSyncPageContent() {
const t = useTranslations()
const goBackOrFallback = useGoBackOrFallback()
const router = useRouter()
Expand Down Expand Up @@ -139,6 +148,7 @@ export default function CalendarSyncPage() {

useEffect(() => {
if (profile && !hasProAccess) {
// react-doctor-disable-next-line nextjs-no-client-side-redirect -- access gate depends on client-fetched profile (hasProAccess); no server-side signal exists https://github.com/thomasluizon/orbit-ui-mobile/issues/243
router.replace('/upgrade')
}
}, [profile, hasProAccess, router])
Expand Down Expand Up @@ -216,12 +226,12 @@ export default function CalendarSyncPage() {
}
setImportResult({
imported: successCount,
habits: result.results
.filter((item) => item.status === 'Success' && item.habitId && item.title)
.map((item) => ({
id: item.habitId as string,
title: item.title as string,
})),
habits: result.results.reduce<{ id: string; title: string }[]>((accumulator, item) => {
if (item.status === 'Success' && item.habitId && item.title) {
accumulator.push({ id: item.habitId, title: item.title })
}
return accumulator
}, []),
})
setWizardStage('done')
if (isReviewMode) {
Expand Down
3 changes: 3 additions & 0 deletions apps/web/app/(app)/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function resolveMonthSlideClass(monthSlide: MonthSlide): string {
return ''
}

// react-doctor-disable-next-line no-giant-component -- calendar shell hosting four distinct views (month/week/range/agenda); extraction deferred to avoid regression without visual QA https://github.com/thomasluizon/orbit-ui-mobile/issues/243
export default function CalendarPage() {
const t = useTranslations()
const locale = useLocale()
Expand Down Expand Up @@ -92,10 +93,12 @@ export default function CalendarPage() {

const weekStart = useMemo(
() => startOfWeek(weekAnchor, { weekStartsOn }),
// react-doctor-disable-next-line exhaustive-deps -- weekStartsOn is derived from profile.weekStartDay every render and already listed; no staleness possible https://github.com/thomasluizon/orbit-ui-mobile/issues/243
[weekAnchor, weekStartsOn],
)
const weekEnd = useMemo(
() => endOfWeek(weekAnchor, { weekStartsOn }),
// react-doctor-disable-next-line exhaustive-deps -- weekStartsOn is derived from profile.weekStartDay every render and already listed; no staleness possible https://github.com/thomasluizon/orbit-ui-mobile/issues/243
[weekAnchor, weekStartsOn],
)
const rangeBounds = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/(app)/insights/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function InsightsPage() {
const topbarRangeSelector = useMemo(
() =>
isDesktop && hasProAccess ? <RangeSelector value={preset} onChange={setPreset} /> : null,
// react-doctor-disable-next-line exhaustive-deps -- hasProAccess is derived from profile.hasProAccess every render and already listed; no staleness possible https://github.com/thomasluizon/orbit-ui-mobile/issues/243
[isDesktop, hasProAccess, preset],
)
useTopbarSlot(topbarRangeSelector)
Expand Down
10 changes: 8 additions & 2 deletions apps/web/app/(app)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useState, useEffect, useCallback, useRef } from 'react'
import { useState, useEffect, useCallback, useRef, Suspense } from 'react'
import { useRouter, usePathname, useSearchParams } from 'next/navigation'
import { useTranslations } from 'next-intl'
import { Providers } from '@/lib/providers'
Expand Down Expand Up @@ -71,7 +71,9 @@ export default function AppLayout({
return (
<Providers>
<TodayProvider>
<AppLayoutContent>{children}</AppLayoutContent>
<Suspense fallback={null}>
<AppLayoutContent>{children}</AppLayoutContent>
</Suspense>
</TodayProvider>
</Providers>
)
Expand Down Expand Up @@ -159,6 +161,7 @@ function AppLayoutContent({ children }: Readonly<{ children: React.ReactNode }>)
return
}
setShowCreateModal(true)
// react-doctor-disable-next-line exhaustive-deps -- hasProAccess is derived from profile.hasProAccess every render and already listed; no staleness possible https://github.com/thomasluizon/orbit-ui-mobile/issues/243
}, [activeView, hasProAccess, totalHabitCount, router, setShowCreateModal, setShowCreateGoalModal])

const handleDismissCalendarPrompt = useCallback(() => {
Expand Down Expand Up @@ -286,6 +289,7 @@ function AppLayoutContent({ children }: Readonly<{ children: React.ReactNode }>)
)
}

// react-doctor-disable-next-line no-many-boolean-props -- private layout-internal overlay aggregator, not a reusable API; the flags are independent render gates, not a combinatorial surface https://github.com/thomasluizon/orbit-ui-mobile/issues/243
function GlobalOverlays({
profile,
hasProAccess,
Expand Down Expand Up @@ -404,6 +408,7 @@ function GlobalOverlays({
{t('onboarding.wizard.calendarButton')}
</PillButton>
<button
type="button"
className="w-full py-3 text-[var(--fg-2)] text-sm font-medium hover:text-[var(--fg-1)] transition-colors"
onClick={onDismissCalendarPrompt}
>
Expand All @@ -426,6 +431,7 @@ function GlobalOverlays({
{t('onboarding.wizard.importButton')}
</PillButton>
<button
type="button"
className="w-full py-3 text-[var(--fg-2)] text-sm font-medium hover:text-[var(--fg-1)] transition-colors"
onClick={onDismissImportPrompt}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function MarketingConsentSection() {
const { profile, patchProfile } = useProfile()
const enabled = profile?.marketingEmailConsent === true

// react-doctor-disable-next-line query-mutation-missing-invalidation -- optimistic cache update via patchProfile (setQueryData) + onError rollback keeps the profile cache in sync; no dependent query to refetch https://github.com/thomasluizon/orbit-ui-mobile/issues/243
const mutation = useMutation({
mutationFn: (next: boolean) => updateMarketingConsent({ enabled: next }),
onMutate: (next) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function usePreferenceControls() {
},
})

// react-doctor-disable-next-line query-mutation-missing-invalidation -- optimistic cache update via patchProfile (setQueryData) + onError rollback keeps the profile cache in sync; no dependent query to refetch https://github.com/thomasluizon/orbit-ui-mobile/issues/243
const colorSchemeMutation = useMutation({
mutationFn: (scheme: string) => updateColorSchemeAction({ colorScheme: scheme }),
onMutate: (scheme) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export function DeleteAccountModal({
open,
onOpenChange,
profile,
// react-doctor-disable-next-line prefer-useReducer -- the state pieces are updated in varying independent combinations across handlers (setCode alone, setLoading+setError, full reset), not one coordinated transition https://github.com/thomasluizon/orbit-ui-mobile/issues/243
}: Readonly<DeleteAccountModalProps>) {
const t = useTranslations()
const { displayDate } = useDateFormat()
Expand Down Expand Up @@ -115,6 +116,7 @@ export function DeleteAccountModal({
})
}
return t('profile.deleteAccount.warningFree')
// react-doctor-disable-next-line exhaustive-deps -- hasProAccess/planExpiresAt are derived from profile every render and already listed; no staleness possible https://github.com/thomasluizon/orbit-ui-mobile/issues/243
}, [hasProAccess, planExpiresAt, displayDate, t])

const formattedDeletionDate = useMemo(() => {
Expand Down
22 changes: 12 additions & 10 deletions apps/web/app/(app)/profile/_components/next-reward-carrot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ import { Lock, Sparkles } from 'lucide-react'
import { useTranslations } from 'next-intl'
import type { NextRewardCarrotState } from '@orbit/shared/utils'

const upgradeLinkStyle = {
padding: '9px 16px',
background: 'var(--primary)',
color: 'var(--fg-on-primary)',
fontFamily: 'var(--font-sans)',
fontSize: 13,
fontWeight: 500,
textDecoration: 'none',
boxShadow: 'var(--primary-glow)',
}

interface NextRewardCarrotProps {
carrot: NextRewardCarrotState | null
}
Expand Down Expand Up @@ -91,16 +102,7 @@ export function NextRewardCarrot({ carrot }: Readonly<NextRewardCarrotProps>) {
<Link
href="/upgrade"
className="touch-target-y shrink-0 rounded-full transition-[background-color,box-shadow,transform] duration-[var(--dur-fast)] ease-[var(--ease-standard)] hover:-translate-y-px hover:bg-[var(--primary-pressed)] active:translate-y-0 active:scale-[0.96]"
style={{
padding: '9px 16px',
background: 'var(--primary)',
color: 'var(--fg-on-primary)',
fontFamily: 'var(--font-sans)',
fontSize: 13,
fontWeight: 500,
textDecoration: 'none',
boxShadow: 'var(--primary-glow)',
}}
style={upgradeLinkStyle}
>
{t('common.upgrade')}
</Link>
Expand Down
Loading
Loading