'use client'; import { useState } from 'react'; import { redirect } from 'next/navigation'; import type { Account, AccountParams, BmiThresholds, } from '@/packages/features/accounts/src/types/accounts'; import { Database } from '@/packages/supabase/src/database.types'; import { format } from 'date-fns'; import { enGB, et } from 'date-fns/locale'; import { CalendarIcon, ChevronRight, Euro, User } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import { createPath, pathsConfig } from '@kit/shared/config'; import { Card } from '@kit/ui/card'; import { Trans } from '@kit/ui/makerkit/trans'; import { Button } from '@kit/ui/shadcn/button'; import { DateRange } from '@kit/ui/shadcn/calendar'; import { TeamAccountBenefitExpensesOverview } from '../_lib/server/load-team-account-benefit-expenses-overview'; import { AccountBenefitStatistics } from '../_lib/server/load-team-account-benefit-statistics'; import TeamAccountBenefitStatistics from './team-account-benefit-statistics'; import TeamAccountHealthDetails from './team-account-health-details'; export interface TeamAccountStatisticsProps { teamAccount: Account; memberParams: Pick[]; bmiThresholds: Omit[]; members: Database['medreport']['Functions']['get_account_members']['Returns']; accountBenefitStatistics: AccountBenefitStatistics; expensesOverview: TeamAccountBenefitExpensesOverview; } export default function TeamAccountStatistics({ teamAccount, memberParams, bmiThresholds, members, accountBenefitStatistics, expensesOverview, }: TeamAccountStatisticsProps) { const currentDate = new Date(); const [date, setDate] = useState({ from: new Date(currentDate.getFullYear(), currentDate.getMonth(), 1), to: new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0), }); const { i18n: { language }, } = useTranslation(); const dateFormatOptions = { locale: language === 'et' ? et : enGB, }; return ( <>

redirect( createPath( pathsConfig.app.accountMembers, teamAccount.slug || '', ), ) } >

redirect( createPath(pathsConfig.app.accountBilling, teamAccount.slug!), ) } >

); }