Skip to content

Commit

Permalink
Merge pull request #24 from danskernesdigitalebibliotek/DDFBRA-163-fi…
Browse files Browse the repository at this point in the history
…x-next-build-issues

Build issue fixes
  • Loading branch information
spaceo authored Oct 31, 2024
2 parents 64b569a + 5fa9920 commit 2fa2fb0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
1 change: 0 additions & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Footer from "@/components/global/footer/Footer"
import GridHelper from "@/components/global/gridHelper/GridHelper"
import Header from "@/components/global/header/Header"
import Theme from "@/components/global/theme/Theme"
import { getEnvironment } from "@/lib/helpers/helper.env"
import ReactQueryProvider from "@/lib/providers/ReactQueryProvider"
import "@/styles/globals.css"

Expand Down
7 changes: 5 additions & 2 deletions app/search/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { dehydrate, HydrationBoundary } from "@tanstack/react-query"
import { HydrationBoundary, dehydrate } from "@tanstack/react-query"
import { Suspense } from "react"

import SearchPageLayout from "@/components/pages/searchPageLayout/SearchPageLayout"
import getQueryClient from "@/lib/getQueryClient"
Expand All @@ -12,7 +13,9 @@ const Page = async ({ searchParams: { q } }: { searchParams: { q: string } }) =>

return (
<HydrationBoundary state={dehydrate(queryClient)}>
<SearchPageLayout searchQuery={q} />
<Suspense fallback={<p>Loading...</p>}>
<SearchPageLayout searchQuery={q} />
</Suspense>
</HydrationBoundary>
)
}
Expand Down
6 changes: 4 additions & 2 deletions components/global/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react"
import React, { Suspense } from "react"

import { Button } from "@/components/shared/button/Button"
import DarkModeToggle from "@/components/shared/darkModeToggle/DarkModeToggle"
Expand Down Expand Up @@ -30,7 +30,9 @@ function Header() {
<div className="h-navigation-search-height">
<div className="content-container">
<div className="flex h-full w-full items-center">
<SearchInput placeholder="Søg" />
<Suspense fallback={<p>Loading...</p>}>
<SearchInput placeholder="Søg" />
</Suspense>
</div>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion components/pages/searchPageLayout/SearchPageLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ const SearchPageLayout = ({ searchQuery }: { searchQuery?: string }) => {
if (isInView) {
handleLoadMore()
}
// We choose to ignore the eslint warning below
// because we do not want to add the handleMore callback which changes on every render.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isInView])

Expand All @@ -139,7 +141,7 @@ const SearchPageLayout = ({ searchQuery }: { searchQuery?: string }) => {
setFacetFilters(facetsForSearchRequest)
setCurrentPage(0)
}
}, [facetsForSearchRequest, facetFilters])
}, [facetFilters, facetsForSearchRequest])

const facetData = dataFacets?.search?.facets
const hitcount = data?.pages?.[0]?.search.hitcount ?? 0
Expand Down
17 changes: 9 additions & 8 deletions components/shared/searchFilters/SearchFilterBar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"

import React, { useState } from "react"
import React, { Suspense, useState } from "react"

import { SearchFacetFragment } from "@/lib/graphql/generated/fbi/graphql"

Expand All @@ -21,13 +21,14 @@ const SearchFilterBar = ({ facets }: SearchFilterBarProps) => {
{facets.map((facet, index) => {
const isLast = index === facets.length - 1
return (
<SearchFiltersColumn
facet={facet}
isLast={isLast}
key={facet.name}
isExpanded={isExpanded}
setIsExpanded={setIsExpanded}
/>
<Suspense key={facet.name} fallback={<p>Loading...</p>}>
<SearchFiltersColumn
facet={facet}
isLast={isLast}
isExpanded={isExpanded}
setIsExpanded={setIsExpanded}
/>
</Suspense>
)
})}
</div>
Expand Down
3 changes: 3 additions & 0 deletions components/shared/searchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const SearchInput = ({ className, placeholder }: SearchInputProps) => {
return () => {
window.removeEventListener("keydown", handleKeydown)
}
// We choose to ignore the eslint warning below
// because we do not want to add the handleKeydown callback which changes on every render.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

useEffect(() => {
Expand Down

0 comments on commit 2fa2fb0

Please sign in to comment.