diff --git a/apps/dolly-frontend/src/main/js/src/allRoutes.tsx b/apps/dolly-frontend/src/main/js/src/allRoutes.tsx index 967c4ba14d1..456c17b626a 100644 --- a/apps/dolly-frontend/src/main/js/src/allRoutes.tsx +++ b/apps/dolly-frontend/src/main/js/src/allRoutes.tsx @@ -5,8 +5,9 @@ import GruppeConnector from '@/pages/gruppe/GruppeConnector' const GruppeOversikt = lazy(() => import('@/pages/gruppeOversikt/GruppeOversiktConnector')) const Organisasjon = lazy(() => import('@/pages/organisasjoner/OrganisasjonerConnector')) const BestillingsveilederConnector = lazy( - () => import('@/components/bestillingsveileder/BestillingsveilederConnector') + () => import('@/components/bestillingsveileder/BestillingsveilederConnector'), ) +const Statistikk = lazy(() => import('@/pages/statistikk/Statistikk')) const MinSide = lazy(() => import('@/pages/minSide/MinSide')) const UI = lazy(() => import('@/pages/ui/index')) const TestnorgePage = lazy(() => import('@/pages/testnorgePage/index')) @@ -43,6 +44,7 @@ const allRoutes = [ element: () => , }, { path: '/minside', breadcrumb: 'Min side', element: () => }, + { path: '/statistikk', breadcrumb: 'Statistikk', element: () => }, { path: '/ui', breadcrumb: 'UI demo', element: () => }, { path: '/testnorge', breadcrumb: 'Test-Norge', element: () => }, { diff --git a/apps/dolly-frontend/src/main/js/src/components/layout/header/BrukerDropdown.tsx b/apps/dolly-frontend/src/main/js/src/components/layout/header/BrukerDropdown.tsx index a68906a5823..48bc8aaf4e0 100644 --- a/apps/dolly-frontend/src/main/js/src/components/layout/header/BrukerDropdown.tsx +++ b/apps/dolly-frontend/src/main/js/src/components/layout/header/BrukerDropdown.tsx @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom' import './Header.less' import { useBrukerProfil, useBrukerProfilBilde } from '@/utils/hooks/useBruker' import logoutBruker from '@/components/utlogging/logoutBruker' -import { getDefaultImage } from '@/pages/minSide/Profil' +import { getDefaultImage } from '@/pages/profil/Profil' import { Dropdown, DropdownContext } from '@navikt/ds-react-internal' import Icon from '@/components/ui/icon/Icon' import styled from 'styled-components' diff --git a/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx b/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx index b61b7fa174d..33b9db82459 100644 --- a/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx +++ b/apps/dolly-frontend/src/main/js/src/pages/minSide/MinSide.tsx @@ -1,5 +1,5 @@ import Maler from './maler/Maloversikt' -import Profil from './Profil' +import Profil from '../profil/Profil' import './MinSide.less' import { useBrukerProfil, useCurrentBruker } from '@/utils/hooks/useBruker' diff --git a/apps/dolly-frontend/src/main/js/src/pages/minSide/Profil.tsx b/apps/dolly-frontend/src/main/js/src/pages/profil/Profil.tsx similarity index 100% rename from apps/dolly-frontend/src/main/js/src/pages/minSide/Profil.tsx rename to apps/dolly-frontend/src/main/js/src/pages/profil/Profil.tsx diff --git a/apps/dolly-frontend/src/main/js/src/pages/statistikk/Statistikk.tsx b/apps/dolly-frontend/src/main/js/src/pages/statistikk/Statistikk.tsx new file mode 100644 index 00000000000..ff982f954d5 --- /dev/null +++ b/apps/dolly-frontend/src/main/js/src/pages/statistikk/Statistikk.tsx @@ -0,0 +1,17 @@ +import Profil from '../profil/Profil' + +import { useBrukerProfil, useCurrentBruker } from '@/utils/hooks/useBruker' +import DollyStatistikk from '@/pages/statistikk/dollyStatistikk/DollyStatistikk' + +export default () => { + const { brukerProfil } = useBrukerProfil() + const { currentBruker } = useCurrentBruker() + + return ( + <> +

Statistikk

+ + {brukerProfil && } + + ) +} diff --git a/apps/dolly-frontend/src/main/js/src/pages/statistikk/dollyStatistikk/DollyStatistikk.tsx b/apps/dolly-frontend/src/main/js/src/pages/statistikk/dollyStatistikk/DollyStatistikk.tsx new file mode 100644 index 00000000000..89e31bf7a24 --- /dev/null +++ b/apps/dolly-frontend/src/main/js/src/pages/statistikk/dollyStatistikk/DollyStatistikk.tsx @@ -0,0 +1,17 @@ +import Loading from '@/components/ui/loading/Loading' +import { useCurrentBrukerStatistikk } from '@/utils/hooks/useDollyStatistikk' + +export default (brukerId: string) => { + const { dollyStatistikk, loading } = useCurrentBrukerStatistikk(brukerId) + if (loading) { + return + } + + return ( + <> +

Dolly statistikk

+

Antall bestillinger

+ {dollyStatistikk.antallBestillinger} + + ) +} diff --git a/apps/dolly-frontend/src/main/js/src/utils/hooks/useDollyStatistikk.tsx b/apps/dolly-frontend/src/main/js/src/utils/hooks/useDollyStatistikk.tsx new file mode 100644 index 00000000000..7d924b88c40 --- /dev/null +++ b/apps/dolly-frontend/src/main/js/src/utils/hooks/useDollyStatistikk.tsx @@ -0,0 +1,23 @@ +import useSWR from 'swr' +import { fetcher } from '@/api' + +const getStatistikkUrl = (brukerId: string) => + `/dolly-backend/api/v1/statistikk?brukerId=${brukerId}` + +type DollyStatistikk = { + antallBestillinger: number + antallIdenter: number +} + +export const useCurrentBrukerStatistikk = (brukerId: string) => { + const { data, isLoading, error } = useSWR( + getStatistikkUrl(brukerId), + fetcher, + ) + + return { + dollyStatistikk: data, + loading: isLoading, + error: error, + } +}