From e82d74f6ef2a2870bed8448f407ac84b8f2e5dd5 Mon Sep 17 00:00:00 2001 From: Remko Date: Wed, 22 Nov 2023 14:02:38 +0100 Subject: [PATCH] updated oidn --- pwa/src/apiService/resources/availableFilters.ts | 4 ++-- pwa/src/apiService/resources/openWoo.ts | 4 ++-- pwa/src/context/filters.ts | 12 ++++++------ pwa/src/services/filtersToQueryParams.ts | 4 ++-- .../templateParts/filters/FiltersTemplate.tsx | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pwa/src/apiService/resources/availableFilters.ts b/pwa/src/apiService/resources/availableFilters.ts index 0a488ffe..21444fd9 100644 --- a/pwa/src/apiService/resources/availableFilters.ts +++ b/pwa/src/apiService/resources/availableFilters.ts @@ -11,10 +11,10 @@ export default class AvailableFilters { } public getCategories = async (): Promise => { - let endpoint = "/openWOO?_queries[]=Categorie"; + let endpoint = "/openWOO?_queries[]=categorie"; if (window.sessionStorage.getItem("OIDN_NUMBER")) { - endpoint += `&behandelendBestuursorgaan.oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`; + endpoint += `&embedded.behandelendBestuursorgaan.oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`; } const { data } = await this._send(this._instance, "GET", endpoint); diff --git a/pwa/src/apiService/resources/openWoo.ts b/pwa/src/apiService/resources/openWoo.ts index f9ee2e18..99a05a27 100644 --- a/pwa/src/apiService/resources/openWoo.ts +++ b/pwa/src/apiService/resources/openWoo.ts @@ -17,10 +17,10 @@ export default class OpenWoo { public getAll = async (filters: IFiltersContext, currentPage: number, limit: number): Promise => { let endpoint = `/openWOO?extend[]=all${filtersToQueryParams( filters, - )}&_order[Publicatiedatum]=desc&_limit=${limit}&_page=${currentPage}`; + )}&_order[publicatiedatum]=desc&_limit=${limit}&_page=${currentPage}`; if (window.sessionStorage.getItem("OIDN_NUMBER")) { - endpoint += `&behandelendBestuursorgaan.oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`; + endpoint += `&embedded.behandelendBestuursorgaan.oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`; } const { data } = await this._send(this._instance, "GET", endpoint); diff --git a/pwa/src/context/filters.ts b/pwa/src/context/filters.ts index 10736825..c6bf39ee 100644 --- a/pwa/src/context/filters.ts +++ b/pwa/src/context/filters.ts @@ -3,16 +3,16 @@ import { GlobalContext } from "./global"; export interface IFiltersContext { _search: string | undefined; - "Publicatiedatum[after]": string | undefined; - "Publicatiedatum[before]": string | undefined; - Categorie: string | undefined; + "publicatiedatum[after]": string | undefined; + "publicatiedatum[before]": string | undefined; + categorie: string | undefined; } export const defaultFiltersContext: IFiltersContext = { _search: "", - "Publicatiedatum[after]": undefined, - "Publicatiedatum[before]": undefined, - Categorie: undefined, + "publicatiedatum[after]": undefined, + "publicatiedatum[before]": undefined, + categorie: undefined, }; export const useFiltersContext = () => { diff --git a/pwa/src/services/filtersToQueryParams.ts b/pwa/src/services/filtersToQueryParams.ts index 09745d85..6dcfcbe9 100644 --- a/pwa/src/services/filtersToQueryParams.ts +++ b/pwa/src/services/filtersToQueryParams.ts @@ -37,8 +37,8 @@ export const filtersToUrlQueryParams = (filters: Record): string => ? value.map((v: string) => v.replace(/\s+/g, "_")).join(`&${key}[]=`) : (value as string).replace(/\s+/g, "_"); - if (key == "Publicatiedatum[after]") return; - if (key == "Publicatiedatum[before]") + if (key == "publicatiedatum[after]") return; + if (key == "publicatiedatum[before]") return `year=${ generateYearsArray(currentYear - 1995).find((year: any) => { return year.before === value; diff --git a/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx b/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx index 16a68374..2e56a945 100644 --- a/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx +++ b/pwa/src/templates/templateParts/filters/FiltersTemplate.tsx @@ -66,16 +66,16 @@ export const FiltersTemplate: React.FC = ({ isLoading }) = getCategories.isSuccess && setValue( "category", - categoryOptions.find((option: any) => option.value === params.Categorie?.replace(/_/g, " ")), + categoryOptions.find((option: any) => option.value === params.categorie?.replace(/_/g, " ")), ); }; const onSubmit = (data: any) => { setFilters({ _search: data._search, - "Publicatiedatum[after]": data.year?.after, - "Publicatiedatum[before]": data.year?.before, - Categorie: data.category?.value, + "publicatiedatum[after]": data.year?.after, + "publicatiedatum[before]": data.year?.before, + categorie: data.category?.value, }); }; @@ -112,7 +112,7 @@ export const FiltersTemplate: React.FC = ({ isLoading }) = React.useEffect(() => { if (!getCategories.isSuccess) return; - const categoriesWithData = getCategories.data.Categorie.map((category: any) => ({ + const categoriesWithData = getCategories.data.categorie.map((category: any) => ({ label: _.upperFirst(category._id.toLowerCase()), value: category._id.toLowerCase(), })); @@ -138,7 +138,7 @@ export const FiltersTemplate: React.FC = ({ isLoading }) = isClearable defaultValue={generateYearsArray(currentYear - 2021).find((year: any) => { return ( - year.after === filters["Publicatiedatum[after]"] && year.before === filters["Publicatiedatum[before]"] + year.after === filters["publicatiedatum[after]"] && year.before === filters["publicatiedatum[before]"] ); })} {...{ register, errors, control }} @@ -151,7 +151,7 @@ export const FiltersTemplate: React.FC = ({ isLoading }) = options={categoryOptions} name="category" placeholder={t("Category")} - defaultValue={categoryOptions && categoryOptions.find((option: any) => option.value === filters.Categorie)} + defaultValue={categoryOptions && categoryOptions.find((option: any) => option.value === filters.categorie)} isClearable disabled={getCategories.isLoading} {...{ register, errors, control }}