diff --git a/components/dataproducts/dataproductList.tsx b/components/dataproducts/dataproductList.tsx
index e71a2a14..8c0a6f78 100644
--- a/components/dataproducts/dataproductList.tsx
+++ b/components/dataproducts/dataproductList.tsx
@@ -59,6 +59,7 @@ export const DataproductsList = ({ datasets }: DataproductsListProps) => {
type={'Dataset'}
keywords={dataset.keywords}
link={`/dataproduct/${dataset.dataproductID}/${dataset.dataproduct.slug}/${dataset.id}`}
+ productAreas={[]}
/>
})
}
diff --git a/components/productArea/content.tsx b/components/productArea/content.tsx
index 6fe8c197..fe496d11 100644
--- a/components/productArea/content.tsx
+++ b/components/productArea/content.tsx
@@ -1,9 +1,10 @@
import { Tabs } from "@navikt/ds-react";
import { PAItem } from "../../pages/productArea/[id]";
import SearchResultLink from "../search/searchResultLink";
-import { useProductAreasQuery, useTeamkatalogenQuery } from "../../lib/schema/graphql";
+import { useTeamkatalogenQuery } from "../../lib/schema/graphql";
import { useContext } from "react";
import { UserState } from "../../lib/context";
+import { useGetProductAreas } from "../../lib/rest/productAreas";
interface ProductAreaContentProps {
currentItem: PAItem
@@ -15,9 +16,11 @@ const ProductAreaContent = ({ currentItem, currentTab, setCurrentTab }: ProductA
const tk = useTeamkatalogenQuery({
variables: { q: '' },
})
- const po = useProductAreasQuery()
+ const {productAreas, loading, error} = useGetProductAreas()
const userInfo= useContext(UserState)
+ if (loading) return
Laster...
+ if (error) return
diff --git a/components/productArea/productAreaMobileMenu.tsx b/components/productArea/productAreaMobileMenu.tsx
index e3a1cad3..1a0e4209 100644
--- a/components/productArea/productAreaMobileMenu.tsx
+++ b/components/productArea/productAreaMobileMenu.tsx
@@ -1,7 +1,6 @@
import { Back, Next } from "@navikt/ds-icons"
import { Button, Heading, Modal } from "@navikt/ds-react"
import { useState } from "react"
-import { ProductAreasQuery } from "../../lib/schema/graphql"
import { PAItems } from "../../pages/productArea/[id]"
interface MobileMenuProps {
@@ -9,7 +8,7 @@ interface MobileMenuProps {
setOpen: (value: boolean) => void
productAreaItems: PAItems
setCurrentItem: (newCurrent: number) => void
- productAreas: ProductAreasQuery['productAreas']
+ productAreas: any[]
selectProductArea: (productAreaId: string) => void
}
diff --git a/components/productArea/productAreaView.tsx b/components/productArea/productAreaView.tsx
index 6cdc5001..fb4b7833 100644
--- a/components/productArea/productAreaView.tsx
+++ b/components/productArea/productAreaView.tsx
@@ -2,7 +2,6 @@ import { System } from '@navikt/ds-icons'
import { Heading } from '@navikt/ds-react'
import { useRouter } from 'next/router'
import { useState } from 'react'
-import { ProductAreasQuery } from '../../lib/schema/graphql'
import { PAItem, PAItems } from '../../pages/productArea/[id]'
import ProductAreaContent from './content'
import ProductAreaMobileMenu from './productAreaMobileMenu'
@@ -10,12 +9,12 @@ import ProductAreaSidebar from './sidebar'
interface ProductAreaViewProps {
paItems: PAItems
- productAreas: ProductAreasQuery['productAreas']
+ productAreas: any[]
}
const ProductAreaView = ({ paItems, productAreas }: ProductAreaViewProps) => {
const router = useRouter()
- const currentItemName = (router.query.team as string) || paItems[0].name
+ const currentItemName = (router.query.team as string) || paItems.length && paItems[0].name || ''
const teamIdx = paItems.findIndex(
(it) => it.name.toLowerCase() === currentItemName.toLowerCase() || it.id === currentItemName
)
@@ -23,11 +22,16 @@ const ProductAreaView = ({ paItems, productAreas }: ProductAreaViewProps) => {
const currentItem = teamIdx > 0 ? teamIdx : 0
const initialTab = (item: PAItem) => {
- return item.dashboardURL ? 'dashboard' : 'stories'
+ return item?.dashboardURL ? 'dashboard' : 'stories'
}
const [currentTab, setCurrentTab] = useState(initialTab(paItems[teamIdx]))
const [open, setOpen] = useState(false)
+
+ if(!currentItemName){
+ return
Ingen produktområder samsvarer med søkekriteriene
+ }
+
const pathComponents = router.asPath.split('?')[0].split('/')
const currentProductAreaId = pathComponents[pathComponents.length - 1]
diff --git a/components/productArea/sidebar.tsx b/components/productArea/sidebar.tsx
index b1f2c60f..fc3cfd92 100644
--- a/components/productArea/sidebar.tsx
+++ b/components/productArea/sidebar.tsx
@@ -2,7 +2,6 @@ import { Data } from '@navikt/ds-icons'
import { Select } from '@navikt/ds-react'
import { useRouter } from 'next/router'
import * as React from 'react'
-import { ProductAreasQuery } from '../../lib/schema/graphql'
import { PAItems } from '../../pages/productArea/[id]'
import DataproductLogo from '../lib/icons/dataproductLogo'
@@ -10,7 +9,7 @@ interface ProductAreaSidebarProps {
productAreaItems: PAItems
setCurrentItem: (newCurrent: number) => void
currentItem: number
- productAreas: ProductAreasQuery['productAreas']
+ productAreas: any
selectProductArea: (productAreaId: string) => void
}
@@ -23,11 +22,11 @@ const ProductAreaSidebar = ({
}: ProductAreaSidebarProps) => {
const relevantProductAreas = productAreas
.filter(
- (it) =>
- it.dataproducts.length ||
- it.stories.length ||
- it.insightProducts.length
- ).sort((l, r) => (l.name < r.name ? -1 : 1))
+ (it: any) =>
+ it.dataproductsNumber ||
+ it.storiesNumber ||
+ it.insightProductsNumber
+ ).sort((l: any, r: any) => (l.name < r.name ? -1 : 1))
return (