Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Development to main, week 46 #173

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions pwa/src/context/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ export const defaultPaginationContext: IPaginationContext = {

export const usePaginationContext = () => {
const [globalContext, setGlobalContext] = React.useContext(GlobalContext);
const [currentPage, setCurrentPage] = React.useState<number>(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 };
};
2 changes: 2 additions & 0 deletions pwa/src/context/queryLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
15 changes: 15 additions & 0 deletions pwa/src/services/getConfig.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
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<string, any> | undefined => {
switch (domain) {
case "open.epe.nl":
return Epe as Record<string, any>;
case "open.noordwijk.nl":
return Noordwijk as Record<string, any>;
// case "open.rotterdam.nl":
// return Rotterdam as Record<string, any>;
// case "open.noaberkracht.nl":
// return Noaberkracht as Record<string, any>;
// case "open.tubbergen.nl":
// return Tubbergen as Record<string, any>;
// case "open.dinkelland.nl":
// return Dinkelland as Record<string, any>;
// case "open.xxllnc.nl":
// return Xxllnc as Record<string, any>;
default:
return Conduction as Record<string, any>;
}
Expand Down
2 changes: 1 addition & 1 deletion pwa/src/services/initiateEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ?? "");

Expand Down
16 changes: 10 additions & 6 deletions pwa/src/templates/landing/LandingTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -43,7 +46,8 @@ export const LandingTemplate: React.FC = () => {
<Pagination
ariaLabels={{ previousPage: t("Previous page"), nextPage: t("Next page"), page: t("Page") }}
totalPages={getItems.data.pages}
{...{ currentPage, setCurrentPage }}
currentPage={getItems.data.page}
setCurrentPage={(page: any) => setPagination({ currentPage: page })}
/>
<PaginationLimitSelectComponent queryLimitName={"openWooObjectsQueryLimit"} />
</div>
Expand Down
3 changes: 3 additions & 0 deletions pwa/src/templates/templateParts/filters/FiltersTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +25,7 @@ interface FiltersTemplateProps {
export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) => {
const { t } = useTranslation();
const { filters, setFilters } = useFiltersContext();
const { setPagination } = usePaginationContext();
const { gatsbyContext } = useGatsbyContext();
const [queryParams, setQueryParams] = React.useState<IFiltersContext>(defaultFiltersContext);
const [categoryParams, setCategoryParams] = React.useState<any>();
Expand Down Expand Up @@ -102,6 +104,7 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =

setQueryParams(filters);
navigate(`/${filtersToUrlQueryParams(filters)}`);
setPagination({ currentPage: 1 });
}, [filters]);

const getCategories = useAvailableFilters().getCategories();
Expand Down
11 changes: 11 additions & 0 deletions pwa/static/configFiles/dinkelland.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions pwa/static/configFiles/noaberkracht.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions pwa/static/configFiles/rotterdam.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
11 changes: 11 additions & 0 deletions pwa/static/configFiles/tubbergen.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions pwa/static/configFiles/xxllnc.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
Loading