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
2 changes: 1 addition & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"fs-extra": "^11.3.4",
"i18next": "^24.2.0",
"lucide-react-native": "^0.475.0",
"react": "^19.1.0",
"react": "19.1.0",
"react-hook-form": "^7.54.0",
"react-i18next": "^15.4.0",
"react-native": "0.81.5",
Expand Down
30 changes: 1 addition & 29 deletions apps/web/__tests__/stores/chat-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ describe('chat store', () => {
useChatStore.setState({
messages: [],
isTyping: false,
isStreaming: false,
})
})

Expand All @@ -31,10 +30,9 @@ describe('chat store', () => {
expect(state.messages).toEqual([])
})

it('starts with typing and streaming false', () => {
it('starts with typing false', () => {
const state = useChatStore.getState()
expect(state.isTyping).toBe(false)
expect(state.isStreaming).toBe(false)
})
})

Expand Down Expand Up @@ -122,25 +120,6 @@ describe('chat store', () => {
})
})

// -------------------------------------------------------------------------
// setIsStreaming
// -------------------------------------------------------------------------

describe('setIsStreaming', () => {
it('sets streaming to true', () => {
const { setIsStreaming } = useChatStore.getState()
setIsStreaming(true)
expect(useChatStore.getState().isStreaming).toBe(true)
})

it('sets streaming to false', () => {
useChatStore.setState({ isStreaming: true })
const { setIsStreaming } = useChatStore.getState()
setIsStreaming(false)
expect(useChatStore.getState().isStreaming).toBe(false)
})
})

// -------------------------------------------------------------------------
// clearMessages
// -------------------------------------------------------------------------
Expand All @@ -162,12 +141,5 @@ describe('chat store', () => {
clearMessages()
expect(useChatStore.getState().isTyping).toBe(false)
})

it('resets streaming state', () => {
useChatStore.setState({ isStreaming: true })
const { clearMessages } = useChatStore.getState()
clearMessages()
expect(useChatStore.getState().isStreaming).toBe(false)
})
})
})
17 changes: 15 additions & 2 deletions apps/web/app/(app)/calendar-sync/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useTranslations } from 'next-intl'
import { plural } from '@/lib/plural'
import { useProfile, useHasProAccess } from '@/hooks/use-profile'
import { useBulkCreateHabits } from '@/hooks/use-habits'
import { getSupabaseClient } from '@/lib/supabase'
import { API } from '@orbit/shared/api'
import { getErrorMessage } from '@orbit/shared/utils'
import type { FrequencyUnit } from '@orbit/shared/types/habit'
Expand Down Expand Up @@ -215,8 +216,20 @@ export default function CalendarSyncPage() {
}

async function connectGoogle() {
// Redirect to auth flow with Google Calendar scope
window.location.href = '/api/auth/google?scope=calendar'
const supabase = getSupabaseClient()
const redirectTo = `${window.location.origin}/auth-callback`
sessionStorage.setItem('auth_return_url', '/calendar-sync')

await supabase.auth.signInWithOAuth({
provider: 'google',
options: {
redirectTo,
scopes: 'https://www.googleapis.com/auth/calendar.readonly',
queryParams: {
access_type: 'offline',
},
},
})
}

return (
Expand Down
39 changes: 34 additions & 5 deletions apps/web/app/(app)/calendar/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useState, useMemo, useCallback } from 'react'
import { useState, useMemo, useCallback, useRef } from 'react'
import { addMonths, subMonths, startOfMonth, format } from 'date-fns'
import { enUS, ptBR } from 'date-fns/locale'
import { ChevronLeft, ChevronRight, Search } from 'lucide-react'
Expand All @@ -9,6 +9,8 @@ import { useCalendarData } from '@/hooks/use-calendar-data'
import { CalendarGrid } from '@/components/calendar/calendar-grid'
import { CalendarDayDetail } from '@/components/calendar/calendar-day-detail'

const SWIPE_THRESHOLD = 50

export default function CalendarPage() {
const t = useTranslations()
const locale = useLocale()
Expand Down Expand Up @@ -43,8 +45,33 @@ export default function CalendarPage() {
return dayMap.get(selectedDay) ?? []
}, [selectedDay, dayMap])

// Swipe navigation
const touchStartX = useRef<number | null>(null)

const handleTouchStart = useCallback((e: React.TouchEvent) => {
const touch = e.touches[0]
if (touch) touchStartX.current = touch.clientX
}, [])

const handleTouchEnd = useCallback((e: React.TouchEvent) => {
if (touchStartX.current === null) return
const touch = e.changedTouches[0]
if (!touch) return
const deltaX = touch.clientX - touchStartX.current
touchStartX.current = null
if (Math.abs(deltaX) < SWIPE_THRESHOLD) return
if (deltaX < 0) {
setCurrentMonth((m) => addMonths(m, 1))
} else {
setCurrentMonth((m) => subMonths(m, 1))
}
}, [])

return (
<div>
<div
onTouchStart={handleTouchStart}
onTouchEnd={handleTouchEnd}
>
{/* Header */}
<header className="pt-8 pb-2 flex flex-col gap-4">
<div className="flex items-center justify-between">
Expand Down Expand Up @@ -100,9 +127,11 @@ export default function CalendarPage() {
)}

{/* Refetch loading bar */}
{isFetching && !isLoading && (
<div className="loading-bar w-full" />
)}
<div
className={`loading-bar w-full transition-opacity duration-300 ${
isFetching && !isLoading ? 'opacity-100' : 'opacity-0 pointer-events-none'
}`}
/>

{/* Calendar grid */}
{(!isLoading || isFetching) && (
Expand Down
34 changes: 34 additions & 0 deletions apps/web/app/(app)/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use client'

import { useEffect } from 'react'
import { AlertTriangle } from 'lucide-react'
import { useTranslations } from 'next-intl'

export default function AppError({
error,
reset,
}: {
error: Error & { digest?: string }
reset: () => void
}) {
const t = useTranslations()

useEffect(() => {
// Log error for debugging (server-side only via digest)
}, [error])

return (
<div className="flex flex-col items-center justify-center py-16 gap-4 text-center">
<AlertTriangle className="size-10 text-text-muted" />
<p className="text-sm text-text-secondary">
{error.message || t('auth.genericError')}
</p>
<button
className="px-5 py-2.5 rounded-[var(--radius-xl)] bg-primary text-white font-semibold text-sm hover:bg-primary/90 transition-colors"
onClick={reset}
>
{t('common.retry')}
</button>
</div>
)
}
Loading