All files / src/routes/_authed/year-summary index.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 37 38 39 40 41                  1x                                                              
import { createFileRoute, useRouter } from '@tanstack/react-router'
import { z } from 'zod'
import { BottomNav } from '#/components/BottomNav'
import { getYearSummary } from '#/features/year-summary/functions'
import { urlPerson, urlYear } from '#/features/year-summary/schemas'
import { personParam } from '#/features/year-summary/holder'
import { YearSummaryPage } from '#/features/year-summary/YearSummaryPage'
import { m } from '#/paraglide/messages.js'
 
export const Route = createFileRoute('/_authed/year-summary/')({
  validateSearch: z.object({ year: urlYear, person: urlPerson }),
  loaderDeps: ({ search }) => ({ year: search.year, person: search.person }),
  loader: ({ deps }) =>
    getYearSummary({ data: { year: deps.year, person: deps.person } }),
  head: () => ({ meta: [{ title: m.year_summary_page_title() }] }),
  component: YearSummaryRoute,
})
 
function YearSummaryRoute() {
  const view = Route.useLoaderData()
  const router = useRouter()
  return (
    <YearSummaryPage
      view={view}
      onYear={(year) => {
        void router.navigate({
          to: '/year-summary',
          search: { year, person: personParam(view.holder) },
        })
      }}
      onPerson={(person) => {
        void router.navigate({
          to: '/year-summary',
          search: { year: view.year, person },
        })
      }}
      bottomNav={<BottomNav current="year-summary" />}
    />
  )
}