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 45 #159

Merged
merged 29 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
74aae11
added h1 to jumbotron
remko48 Nov 8, 2023
10ea413
Merge remote-tracking branch 'origin/development' into feature/NDT-38…
remko48 Nov 8, 2023
5bca8ee
updated package
remko48 Nov 8, 2023
4875f63
Merge pull request #157 from ConductionNL/feature/NDT-38/logo-component
remko48 Nov 8, 2023
59da34a
added full width card container
remko48 Nov 8, 2023
2944329
Merge pull request #158 from ConductionNL/feature/NDT-38/logo-component
remko48 Nov 8, 2023
2b68222
added dynamic select content
remko48 Nov 9, 2023
2db458f
cleanup
remko48 Nov 9, 2023
226c24c
Merge pull request #160 from ConductionNL/feature/XW-105/Dropdown-con…
remko48 Nov 9, 2023
13f2c63
Merge pull request #161 from ConductionNL/feature/XW-105/Dropdown-con…
remko48 Nov 9, 2023
c445263
added oidn number to count
remko48 Nov 9, 2023
1dee596
Merge pull request #162 from ConductionNL/feature/XW-105/Dropdown-con…
remko48 Nov 9, 2023
93b6666
added commonground theme
remko48 Nov 10, 2023
a78a80d
Merge pull request #163 from ConductionNL/feature/NDT-18/Commonground…
remko48 Nov 13, 2023
a207cab
INIT
lencodes Nov 13, 2023
3439899
requested changes renaming
remko48 Nov 14, 2023
b44778c
cleanup unused files
remko48 Nov 14, 2023
f39688b
ADD Epe theme
lencodes Nov 14, 2023
88de4da
CLEANUP redndant code
lencodes Nov 14, 2023
b161512
REVERT pathPrefix changes'
lencodes Nov 14, 2023
a2b4066
cleanup
remko48 Nov 14, 2023
fb89a2b
CLEANUP
lencodes Nov 14, 2023
ea27f49
IMPLEMENT feedback and fallback theme
lencodes Nov 14, 2023
0729655
Merge pull request #166 from ConductionNL/feature/XW-106/JSON-config
lencodes Nov 14, 2023
5000bed
Merge remote-tracking branch 'origin/development' into Feature/OP-131…
remko48 Nov 14, 2023
eaf21ee
Merge pull request #164 from ConductionNL/Feature/OP-131/Dropdown-con…
remko48 Nov 14, 2023
3d91794
ADD Noordwijk json-config file
lencodes Nov 14, 2023
462108a
Merge pull request #167 from ConductionNL/feature/XW-106/JSON-config
lencodes Nov 14, 2023
6ad5b6d
BUGFIX noordwijk json
lencodes Nov 14, 2023
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
16 changes: 8 additions & 8 deletions pwa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"prepare": "cd .. && husky install"
},
"dependencies": {
"@conduction/components": "2.2.23",
"@conduction/theme": "1.0.53",
"@conduction/components": "2.2.25",
"@conduction/theme": "1.0.55",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-brands-svg-icons": "6.4.2",
"@fortawesome/free-regular-svg-icons": "6.4.2",
Expand Down
15 changes: 15 additions & 0 deletions pwa/src/apiService/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DEFAULT_FOOTER_CONTENT_URL } from "../templates/templateParts/footer/Fo
import OpenWoo from "./resources/openWoo";
import FooterContent from "./resources/footerContent";
import Markdown from "./resources/markdown";
import FilterCount from "./resources/filterCount";

interface PromiseMessage {
loading?: string;
Expand All @@ -32,6 +33,16 @@ export default class APIService {
});
}

public get FilterCountClient(): AxiosInstance {
return axios.create({
baseURL: process.env.GATSBY_API_BASE_URL,
headers: {
Accept: "application/json+aggregations",
"Content-Type": "application/json",
},
});
}

public get FooterContentClient(): AxiosInstance {
return axios.create({
baseURL: removeFileNameFromUrl(
Expand All @@ -55,6 +66,10 @@ export default class APIService {
return new OpenWoo(this.BaseClient, this.Send);
}

public get FilterCount(): FilterCount {
return new FilterCount(this.FilterCountClient, this.Send);
}

public get FooterContent(): FooterContent {
return new FooterContent(this.FooterContentClient, this.Send);
}
Expand Down
24 changes: 24 additions & 0 deletions pwa/src/apiService/resources/filterCount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { TSendFunction } from "../apiService";
import { AxiosInstance } from "axios";

export default class FilterCount {
remko48 marked this conversation as resolved.
Show resolved Hide resolved
private _instance: AxiosInstance;
private _send: TSendFunction;

constructor(_instance: AxiosInstance, send: TSendFunction) {
this._instance = _instance;
this._send = send;
}

public getCategoryCount = async (): Promise<any> => {
let endpoint = "/openWOO?_queries[]=Categorie";

if (process.env.GATSBY_OIDN_NUMBER) {
endpoint += `&oidn=${process.env.GATSBY_OIDN_NUMBER}`;
}

const { data } = await this._send(this._instance, "GET", endpoint);

return data;
};
}
17 changes: 17 additions & 0 deletions pwa/src/hooks/filterCount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import * as React from "react";
import { useQuery } from "react-query";
import APIService from "../apiService/apiService";
import APIContext from "../apiService/apiContext";

export const useFilterCount = () => {
const API: APIService | null = React.useContext(APIContext);

const getCategoryCount = () =>
useQuery<any, Error>(["CategoryCount"], () => API?.FilterCount.getCategoryCount(), {
remko48 marked this conversation as resolved.
Show resolved Hide resolved
onError: (error) => {
console.warn(error.message);
},
});

return { getCategoryCount };
};
12 changes: 8 additions & 4 deletions pwa/src/hooks/openWoo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ export const useOpenWoo = (queryClient: QueryClient) => {
const API: APIService | null = React.useContext(APIContext);

const getAll = (filters: IFiltersContext, currentPage: number, limit: number) =>
useQuery<any, Error>(["OpenWoo", filters, currentPage, limit], () => API?.OpenWoo.getAll(filters, currentPage, limit), {
onError: (error) => {
console.warn(error.message);
useQuery<any, Error>(
["OpenWoo", filters, currentPage, limit],
() => API?.OpenWoo.getAll(filters, currentPage, limit),
{
onError: (error) => {
console.warn(error.message);
},
},
});
);

const getOne = (requestId: string) =>
useQuery<any, Error>(["OpenWoo", requestId], () => API?.OpenWoo.getOne(requestId), {
Expand Down
1 change: 1 addition & 0 deletions pwa/src/styling/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@import "../../node_modules/@conduction/theme/municipalities/rotterdam-design-tokens/dist/index.css";
@import "../../node_modules/@conduction/theme/municipalities/open-webconcept-design-tokens/dist/index.css";
@import "../../node_modules/@conduction/theme/municipalities/dimpact-design-tokens/dist/index.css";
@import "../../node_modules/@conduction/theme/municipalities/commonground-design-tokens/dist/index.css";

/* Design Tokens maintained by Frameless */
@import "../../node_modules/@utrecht/design-tokens/dist/theme.css";
Expand Down
6 changes: 3 additions & 3 deletions pwa/src/templates/jumbotronTemplate/JumbotronTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from "react";
import * as styles from "./JumbotronTemplate.module.css";
import { Heading2, Paragraph, Page, PageContent } from "@utrecht/component-library-react/dist/css-module";
import { Heading1, Paragraph, Page, PageContent } from "@utrecht/component-library-react/dist/css-module";
import { CardWrapper } from "@conduction/components";
import { useTranslation } from "react-i18next";

Expand All @@ -17,9 +17,9 @@ export const JumbotronTemplate: React.FC = () => {
<Page>
<PageContent>
<CardWrapper aria-label={t("Jumbotron card")} role="contentinfo" className={styles.card}>
<Heading2 className={styles.title}>
<Heading1 className={styles.title}>
{t("Woo-publications of")} {process.env.GATSBY_ORGANISATION_NAME}
</Heading2>
</Heading1>

<Paragraph className={styles.description}>
{t("On this page you will find the Woo-publications of")} {process.env.GATSBY_ORGANISATION_NAME}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
.tableRow {
cursor: pointer;
}

.tableRow > * {
vertical-align: middle !important;
}

.componentsGrid {
display: grid;
grid-gap: 24px;
Expand All @@ -18,6 +10,16 @@
flex-direction: column;
}

.cardHeader:before {
z-index: 1;
content: "";
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}

.title {
overflow-wrap: break-word;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const CardsResultsTemplate: React.FC<CardsResultsTemplateProps> = ({ requ
request.Publicatiedatum ? translateDate(i18n.language, request.Publicatiedatum) : t("N/A")
}`}
>
<CardHeader>
<CardHeader className={styles.cardHeader}>
<CardHeaderDate>
{request.Publicatiedatum ? translateDate(i18n.language, request.Publicatiedatum) : t("N/A")}
</CardHeaderDate>
Expand Down
66 changes: 49 additions & 17 deletions pwa/src/templates/templateParts/filters/FiltersTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as styles from "./FiltersTemplate.module.css";
import ResultsDisplaySwitch from "../../../components/resultsDisplaySwitch/ResultsDisplaySwitch";
import _ from "lodash";
import qs from "qs";
import Skeleton from "react-loading-skeleton";
import { useForm } from "react-hook-form";
import { InputText, SelectSingle } from "@conduction/components";
import { IFiltersContext, defaultFiltersContext, useFiltersContext } from "../../../context/filters";
Expand All @@ -15,6 +16,7 @@ import { useTranslation } from "react-i18next";
import { filtersToUrlQueryParams } from "../../../services/filtersToQueryParams";
import { navigate } from "gatsby";
import { useGatsbyContext } from "../../../context/gatsby";
import { useFilterCount } from "../../../hooks/filterCount";

interface FiltersTemplateProps {
isLoading: boolean;
Expand All @@ -25,6 +27,8 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =
const { filters, setFilters } = useFiltersContext();
const { gatsbyContext } = useGatsbyContext();
const [queryParams, setQueryParams] = React.useState<IFiltersContext>(defaultFiltersContext);
const [categoryParams, setCategoryParams] = React.useState<any>();
const [categoryOptions, setCategoryOptions] = React.useState<any>();
const filterTimeout = React.useRef<NodeJS.Timeout | null>(null);

const {
Expand All @@ -51,15 +55,18 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =

setValue(
"year",
generateYearsArray(currentYear - 1995).find((year: any) => {
generateYearsArray(currentYear - 2021).find((year: any) => {
return year.value === params.year;
}),
);
};

setValue(
"category",
TEMP_PUBLICATION_TYPES.find((option) => option.value === params.Categorie?.replace(/_/g, " ")),
);
const handleSetSelectFormValues = (params: any): void => {
getItems.isSuccess &&
setValue(
"category",
categoryOptions.find((option: any) => option.value === params.Categorie?.replace(/_/g, " ")),
);
};

const onSubmit = (data: any) => {
Expand All @@ -79,10 +86,17 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =

React.useEffect(() => {
if (_.isEmpty(parsedParams)) return;

setCategoryParams(parsedParams);
handleSetFormValues(parsedParams);
}, []);

React.useEffect(() => {
if (_.isEmpty(categoryOptions)) return;
if (_.isEmpty(categoryParams)) return;

handleSetSelectFormValues(categoryParams);
}, [categoryOptions]);

React.useEffect(() => {
//Prevents loop that puts user at top of page after scroll
if (_.isEqual(filters, queryParams)) return;
Expand All @@ -91,6 +105,20 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =
navigate(`/${filtersToUrlQueryParams(filters)}`);
}, [filters]);

const getItems = useFilterCount().getCategoryCount();
remko48 marked this conversation as resolved.
Show resolved Hide resolved

React.useEffect(() => {
if (!getItems.isSuccess) return;

const categoriesWithData = getItems.data.Categorie.map((test: any) => {
remko48 marked this conversation as resolved.
Show resolved Hide resolved
return TEMP_PUBLICATION_TYPES?.find((option) => {
return option.value === test._id.toLowerCase();
});
remko48 marked this conversation as resolved.
Show resolved Hide resolved
});

setCategoryOptions(Array.from(new Set(categoriesWithData)));
}, [getItems.isSuccess]);

return (
<div id="filters" className={styles.container}>
<form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
Expand All @@ -103,11 +131,11 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =
/>

<SelectSingle
options={generateYearsArray(currentYear - 1995)}
options={generateYearsArray(currentYear - 2021)}
name="year"
placeholder={t("Year")}
isClearable
defaultValue={generateYearsArray(currentYear - 1995).find((year: any) => {
defaultValue={generateYearsArray(currentYear - 2021).find((year: any) => {
return (
year.after === filters["Publicatiedatum[after]"] && year.before === filters["Publicatiedatum[before]"]
);
Expand All @@ -116,15 +144,19 @@ export const FiltersTemplate: React.FC<FiltersTemplateProps> = ({ isLoading }) =
ariaLabel={t("Select year")}
/>

<SelectSingle
options={TEMP_PUBLICATION_TYPES}
name="category"
placeholder={t("Category")}
defaultValue={TEMP_PUBLICATION_TYPES.find((option) => option.value === filters.Categorie)}
isClearable
{...{ register, errors, control }}
ariaLabel={t("Select category")}
/>
{getItems.isLoading && <Skeleton height="50px" />}
{getItems.isSuccess && (
<SelectSingle
options={categoryOptions}
name="category"
placeholder={t("Category")}
defaultValue={TEMP_PUBLICATION_TYPES.find((option) => option.value === filters.Categorie)}
isClearable
disabled={getItems.isLoading}
{...{ register, errors, control }}
ariaLabel={t("Select category")}
/>
)}

<Button
type="submit"
Expand Down
Loading