diff --git a/pwa/src/context/pagination.ts b/pwa/src/context/pagination.ts index b3ddd388..2e8e2652 100644 --- a/pwa/src/context/pagination.ts +++ b/pwa/src/context/pagination.ts @@ -11,15 +11,11 @@ export const defaultPaginationContext: IPaginationContext = { export const usePaginationContext = () => { const [globalContext, setGlobalContext] = React.useContext(GlobalContext); - const [currentPage, setCurrentPage] = React.useState(globalContext.pagination.currentPage); - - React.useEffect(() => { - setPagination({ currentPage }); - }, [currentPage]); + const pagination: IPaginationContext = globalContext.pagination; const setPagination = (newFilters: IPaginationContext) => { - setGlobalContext((oldGlobalContext) => ({ ...oldGlobalContext, pagination: newFilters })); + setGlobalContext((context) => ({ ...context, pagination: { ...globalContext.pagination, ...newFilters } })); }; - return { currentPage, setCurrentPage }; + return { pagination, setPagination }; }; diff --git a/pwa/src/context/queryLimit.ts b/pwa/src/context/queryLimit.ts index 164c5eac..9e5d794a 100644 --- a/pwa/src/context/queryLimit.ts +++ b/pwa/src/context/queryLimit.ts @@ -5,10 +5,12 @@ export const QUERY_LIMIT_DEFAULT = 12; export interface IQueryLimitContext { openWooObjectsQueryLimit: number; + previousOpenWooObjectsQueryLimit: number; } export const defaultQueryLimitContext: IQueryLimitContext = { openWooObjectsQueryLimit: QUERY_LIMIT_DEFAULT, + previousOpenWooObjectsQueryLimit: QUERY_LIMIT_DEFAULT, }; export const useQueryLimitContext = () => { diff --git a/pwa/src/services/getConfig.ts b/pwa/src/services/getConfig.ts index 71805827..2032c34f 100644 --- a/pwa/src/services/getConfig.ts +++ b/pwa/src/services/getConfig.ts @@ -1,6 +1,11 @@ import Conduction from "./../../static/configFiles/conduction.json"; +import Dinkelland from "./../../static/configFiles/dinkelland.json"; import Epe from "./../../static/configFiles/epe.json"; +import Noaberkracht from "./../../static/configFiles/noaberkracht.json"; import Noordwijk from "./../../static/configFiles/noordwijk.json"; +import Rotterdam from "./../../static/configFiles/rotterdam.json"; +import Tubbergen from "./../../static/configFiles/tubbergen.json"; +import Xxllnc from "./../../static/configFiles/xxllnc.json"; export const getConfig = (domain: string): Record | undefined => { switch (domain) { @@ -8,6 +13,16 @@ export const getConfig = (domain: string): Record | undefined => { return Epe as Record; case "open.noordwijk.nl": return Noordwijk as Record; + // case "open.rotterdam.nl": + // return Rotterdam as Record; + // case "open.noaberkracht.nl": + // return Noaberkracht as Record; + // case "open.tubbergen.nl": + // return Tubbergen as Record; + // case "open.dinkelland.nl": + // return Dinkelland as Record; + // case "open.xxllnc.nl": + // return Xxllnc as Record; default: return Conduction as Record; } diff --git a/pwa/src/services/initiateEnvironment.ts b/pwa/src/services/initiateEnvironment.ts index 6ffa76dc..be65bf24 100644 --- a/pwa/src/services/initiateEnvironment.ts +++ b/pwa/src/services/initiateEnvironment.ts @@ -10,7 +10,7 @@ export const initiateEnvironment = () => { window.sessionStorage.setItem("ORGANISATION_NAME", process.env.GATSBY_ORGANISATION_NAME ?? ""); window.sessionStorage.setItem("JUMBOTRON_IMAGE_URL", process.env.GATSBY_JUMBOTRON_IMAGE_URL ?? ""); window.sessionStorage.setItem("FOOTER_LOGO_HREF", process.env.GATSBY_FOOTER_LOGO_HREF ?? ""); - window.sessionStorage.setItem("FOOTER_CONTENT", process.env.FOOTER_CONTENT ?? ""); + window.sessionStorage.setItem("FOOTER_CONTENT", process.env.GATSBY_FOOTER_CONTENT ?? ""); window.sessionStorage.setItem("FOOTER_CONTENT_HEADER", process.env.GATSBY_FOOTER_CONTENT_HEADER ?? ""); window.sessionStorage.setItem("OIDN_NUMBER", process.env.GATSBY_OIDN_NUMBER ?? ""); diff --git a/pwa/src/templates/landing/LandingTemplate.tsx b/pwa/src/templates/landing/LandingTemplate.tsx index 195fb473..6b554faf 100644 --- a/pwa/src/templates/landing/LandingTemplate.tsx +++ b/pwa/src/templates/landing/LandingTemplate.tsx @@ -15,16 +15,19 @@ import { useQueryLimitContext } from "../../context/queryLimit"; import { PaginationLimitSelectComponent } from "../../components/paginationLimitSelect/PaginationLimitSelect"; export const LandingTemplate: React.FC = () => { - const { currentPage, setCurrentPage } = usePaginationContext(); - const { filters } = useFiltersContext(); const { t } = useTranslation(); - const { queryLimit } = useQueryLimitContext(); + const { filters } = useFiltersContext(); + const { pagination, setPagination } = usePaginationContext(); + const { queryLimit, setQueryLimit } = useQueryLimitContext(); const queryClient = new QueryClient(); - const getItems = useOpenWoo(queryClient).getAll(filters, currentPage, queryLimit.openWooObjectsQueryLimit); + const getItems = useOpenWoo(queryClient).getAll(filters, pagination.currentPage, queryLimit.openWooObjectsQueryLimit); React.useEffect(() => { - setCurrentPage(1); + if (queryLimit.openWooObjectsQueryLimit === queryLimit.previousOpenWooObjectsQueryLimit) return; + + setPagination({ currentPage: 1 }); + setQueryLimit({ ...queryLimit, previousOpenWooObjectsQueryLimit: queryLimit.openWooObjectsQueryLimit }); }, [queryLimit.openWooObjectsQueryLimit]); return ( @@ -43,7 +46,8 @@ export const LandingTemplate: React.FC = () => { setPagination({ currentPage: page })} /> diff --git a/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx b/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx index 60c62f53..16a68374 100644 --- a/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx +++ b/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx @@ -16,6 +16,7 @@ import { filtersToUrlQueryParams } from "../../../services/filtersToQueryParams" import { navigate } from "gatsby"; import { useGatsbyContext } from "../../../context/gatsby"; import { useAvailableFilters } from "../../../hooks/availableFilters"; +import { usePaginationContext } from "../../../context/pagination"; interface FiltersTemplateProps { isLoading: boolean; @@ -24,6 +25,7 @@ interface FiltersTemplateProps { export const FiltersTemplate: React.FC = ({ isLoading }) => { const { t } = useTranslation(); const { filters, setFilters } = useFiltersContext(); + const { setPagination } = usePaginationContext(); const { gatsbyContext } = useGatsbyContext(); const [queryParams, setQueryParams] = React.useState(defaultFiltersContext); const [categoryParams, setCategoryParams] = React.useState(); @@ -102,6 +104,7 @@ export const FiltersTemplate: React.FC = ({ isLoading }) = setQueryParams(filters); navigate(`/${filtersToUrlQueryParams(filters)}`); + setPagination({ currentPage: 1 }); }, [filters]); const getCategories = useAvailableFilters().getCategories(); diff --git a/pwa/static/configFiles/dinkelland.json b/pwa/static/configFiles/dinkelland.json new file mode 100644 index 00000000..06df029c --- /dev/null +++ b/pwa/static/configFiles/dinkelland.json @@ -0,0 +1,11 @@ +{ + "GATSBY_API_BASE_URL": "https://api.gateway.commonground.nu/api", + "GATSBY_NL_DESIGN_THEME_CLASSNAME": "dinkelland-theme", + "GATSBY_FAVICON_URL": "https://www.tubbergen.nl/sites/all/themes/tubbergen/favicon-32x32.png", + "GATSBY_ORGANISATION_NAME": "Gemeente Dinkelland", + "GATSBY_JUMBOTRON_IMAGE_URL": "https://www.dinkelland.nl/sites/all/themes/dinkelland/dist/assets/img/header_dinkelland.jpg", + "GATSBY_FOOTER_LOGO_HREF": "https://dinkelland.nl/", + "GATSBY_FOOTER_CONTENT": "https://raw.githubusercontent.com/ConductionNL/woo-website-dinkelland/main/FooterContent.json", + "GATSBY_FOOTER_CONTENT_HEADER": "heading-2", + "GATSBY_OIDN_NUMBER": "00000001809245206000" +} diff --git a/pwa/static/configFiles/noaberkracht.json b/pwa/static/configFiles/noaberkracht.json new file mode 100644 index 00000000..9a4a6443 --- /dev/null +++ b/pwa/static/configFiles/noaberkracht.json @@ -0,0 +1,11 @@ +{ + "GATSBY_API_BASE_URL": "https://api.gateway.commonground.nu/api", + "GATSBY_NL_DESIGN_THEME_CLASSNAME": "noaberkracht-theme", + "GATSBY_FAVICON_URL": "https://werkenbijnoaberkracht.nl/favicon-32x32.png", + "GATSBY_ORGANISATION_NAME": "Noaberkracht", + "GATSBY_JUMBOTRON_IMAGE_URL": "https://werkenbijnoaberkracht.nl/imager/hero/2253/862_0d33baa1153e758942327cdee707898a.webp", + "GATSBY_FOOTER_LOGO_HREF": "https://werkenbijnoaberkracht.nl/", + "GATSBY_FOOTER_CONTENT": "https://raw.githubusercontent.com/ConductionNL/woo-website-noaberkracht/main/FooterContent.json", + "GATSBY_FOOTER_CONTENT_HEADER": "", + "GATSBY_OIDN_NUMBER": "00000001852070706000" +} diff --git a/pwa/static/configFiles/rotterdam.json b/pwa/static/configFiles/rotterdam.json new file mode 100644 index 00000000..5da62c1e --- /dev/null +++ b/pwa/static/configFiles/rotterdam.json @@ -0,0 +1,11 @@ +{ + "GATSBY_API_BASE_URL": "https://api.gateway.commonground.nu/api", + "GATSBY_NL_DESIGN_THEME_CLASSNAME": "rotterdam-theme", + "GATSBY_FAVICON_URL": "https://www.rotterdam.nl/favicon.ico?v=2", + "GATSBY_ORGANISATION_NAME": "Rotterdam", + "GATSBY_JUMBOTRON_IMAGE_URL": "https://www.rotterdam.nl/_next/image?url=https%3A%2F%2Fbackend-dvg.rotterdam.nl%2Fsites%2Fdefault%2Ffiles%2Fstyles%2Fhero_large%2Fpublic%2F2022-12%2F22500-Arnoud-Verhey_0.jpg%3Fh%3D940640a5%26itok%3Dl9pnN9Gq&w=3840&q=75", + "GATSBY_FOOTER_LOGO_HREF": "https://rotterdam.nl/", + "GATSBY_FOOTER_CONTENT": "https://raw.githubusercontent.com/ConductionNL/woo-website-rotterdam/main/FooterContent.json", + "GATSBY_FOOTER_CONTENT_HEADER": "", + "GATSBY_OIDN_NUMBER": "" +} diff --git a/pwa/static/configFiles/tubbergen.json b/pwa/static/configFiles/tubbergen.json new file mode 100644 index 00000000..38284ea3 --- /dev/null +++ b/pwa/static/configFiles/tubbergen.json @@ -0,0 +1,11 @@ +{ + "GATSBY_API_BASE_URL": "https://api.gateway.commonground.nu/api", + "GATSBY_NL_DESIGN_THEME_CLASSNAME": "tubbergen-theme", + "GATSBY_FAVICON_URL": "https://www.tubbergen.nl/sites/all/themes/tubbergen/favicon-32x32.png", + "GATSBY_ORGANISATION_NAME": "Gemeente Tubbergen", + "GATSBY_JUMBOTRON_IMAGE_URL": "https://www.tubbergen.nl/sites/all/themes/tubbergen/dist/assets/img/header_tubbergen.jpg", + "GATSBY_FOOTER_LOGO_HREF": "https://tubbergen.nl/", + "GATSBY_FOOTER_CONTENT": "https://raw.githubusercontent.com/ConductionNL/woo-website-tubbergen/main/FooterContent.json", + "GATSBY_FOOTER_CONTENT_HEADER": "heading-2", + "GATSBY_OIDN_NUMBER": "00000001002172859000" +} diff --git a/pwa/static/configFiles/xxllnc.json b/pwa/static/configFiles/xxllnc.json new file mode 100644 index 00000000..7c789ced --- /dev/null +++ b/pwa/static/configFiles/xxllnc.json @@ -0,0 +1,11 @@ +{ + "GATSBY_API_BASE_URL": "https://api.gateway.commonground.nu/api", + "GATSBY_NL_DESIGN_THEME_CLASSNAME": "xxllnc-theme", + "GATSBY_FAVICON_URL": "https://xxllnc.nl/wp-content/uploads/2021/07/cropped-fav-xxllnc-32x32.png", + "GATSBY_ORGANISATION_NAME": "xxllnc", + "GATSBY_JUMBOTRON_IMAGE_URL": "https://uploads.magnetme-images.com/bf3b2064d7a7c8a51b2c66608b62160f01ee478ab2df8a493635c92069405d35?auto=compress&auto=format&fit=crop&frame=0&h=1125&w=2000", + "GATSBY_FOOTER_LOGO_HREF": "https://xxllnc.nl/", + "GATSBY_FOOTER_CONTENT": "https://raw.githubusercontent.com/ConductionNL/woo-website-xxllnc/main/FooterContent.json", + "GATSBY_FOOTER_CONTENT_HEADER": "", + "GATSBY_OIDN_NUMBER": "" +}