All files / src/routes/_authed account.tsx

11.11% Statements 1/9
100% Branches 0/0
0% Functions 0/6
11.11% Lines 1/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36            1x                                                          
import { createFileRoute, useRouter } from '@tanstack/react-router'
import { BottomNav } from '#/components/BottomNav'
import { AccountPage } from '#/features/account/AccountPage'
import { signOut } from '#/features/authentication/functions'
import { m } from '#/paraglide/messages.js'
 
export const Route = createFileRoute('/_authed/account')({
  head: () => ({ meta: [{ title: m.account_page_title() }] }),
  component: AccountRoute,
})
 
function AccountRoute() {
  const { user } = Route.useRouteContext()
  const router = useRouter()
  return (
    <AccountPage
      name={user.name}
      email={user.email}
      locale={user.locale}
      bottomNav={<BottomNav current="account" />}
      onSignOut={() => {
        void signOut().then(() => {
          window.location.assign('/sign-in')
        })
      }}
      // The server stored the language and set the cookie, so a reload
      // renders the page in it. Not Paraglide's setLocale(): it reads the
      // already-changed cookie as the current language and skips the reload.
      onNameSaved={() => router.invalidate()}
      onLanguageChanged={() => {
        window.location.reload()
      }}
    />
  )
}