Skip to content

Commit

Permalink
updated oidn
Browse files Browse the repository at this point in the history
  • Loading branch information
remko48 committed Nov 22, 2023
1 parent f1b42e8 commit e82d74f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions pwa/src/apiService/resources/availableFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export default class AvailableFilters {
}

public getCategories = async (): Promise<any> => {
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);
Expand Down
4 changes: 2 additions & 2 deletions pwa/src/apiService/resources/openWoo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ export default class OpenWoo {
public getAll = async (filters: IFiltersContext, currentPage: number, limit: number): Promise<any> => {
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);
Expand Down
12 changes: 6 additions & 6 deletions pwa/src/context/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down
4 changes: 2 additions & 2 deletions pwa/src/services/filtersToQueryParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export const filtersToUrlQueryParams = (filters: Record<string, any>): 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;
Expand Down
14 changes: 7 additions & 7 deletions pwa/src/templates/templateParts/filters/FiltersTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ 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,
});
};

Expand Down Expand Up @@ -112,7 +112,7 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ 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(),
}));
Expand All @@ -138,7 +138,7 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ 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 }}
Expand All @@ -151,7 +151,7 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ 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 }}
Expand Down

0 comments on commit e82d74f

Please sign in to comment.