Skip to content

Commit

Permalink
Merge pull request #159 from ConductionNL/development
Browse files Browse the repository at this point in the history
Development to main, week 45
  • Loading branch information
lencodes authored Nov 14, 2023
2 parents 98b152e + 6ad5b6d commit c074b50
Show file tree
Hide file tree
Showing 29 changed files with 253 additions and 251 deletions.
6 changes: 5 additions & 1 deletion pwa/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ require("dotenv").config({
});

module.exports = {
/**
* We do NOT want to set the pathPrefix when we're using a DNS; it's only needed on gh-pages
* We CAN NOT set the pathPrefix when we're using the JSON-config files (due to needing access to window)
*/
pathPrefix:
process.env.USE_GITHUB_REPOSITORY_NAME_AS_PATH_PREFIX === "true"
? `/${process.env.GITHUB_REPOSITORY_NAME}`
: "", // we do NOT want to set the prefix if we're using an DNS
: "",
plugins: [
{
resolve: `gatsby-plugin-layout`,
Expand Down
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
25 changes: 18 additions & 7 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 AvailableFilters from "./resources/availableFilters";

interface PromiseMessage {
loading?: string;
Expand All @@ -24,27 +25,33 @@ export type TSendFunction = (
export default class APIService {
public get BaseClient(): AxiosInstance {
return axios.create({
baseURL: process.env.GATSBY_API_BASE_URL,
baseURL: window.sessionStorage.getItem("API_BASE_URL") ?? "",
headers: {
Accept: "application/json",
"Content-Type": "application/json",
},
});
}

public get AvailableFiltersClient(): AxiosInstance {
return axios.create({
baseURL: window.sessionStorage.getItem("API_BASE_URL") ?? "",
headers: {
Accept: "application/json+aggregations",
"Content-Type": "application/json",
},
});
}

public get FooterContentClient(): AxiosInstance {
return axios.create({
baseURL: removeFileNameFromUrl(
process.env.GATSBY_FOOTER_CONTENT !== undefined && process.env.GATSBY_FOOTER_CONTENT.length !== 0
? process.env.GATSBY_FOOTER_CONTENT
: DEFAULT_FOOTER_CONTENT_URL,
),
baseURL: removeFileNameFromUrl(window.sessionStorage.getItem("FOOTER_CONTENT") ?? DEFAULT_FOOTER_CONTENT_URL),
});
}

public get MarkdownClient(): AxiosInstance {
return axios.create({
baseURL: process.env.GATSBY_BASE_URL ?? undefined,
baseURL: window.sessionStorage.getItem("BASE_URL") ?? undefined,
headers: {
Accept: "application/vnd.github.html",
},
Expand All @@ -55,6 +62,10 @@ export default class APIService {
return new OpenWoo(this.BaseClient, this.Send);
}

public get AvailableFilters(): AvailableFilters {
return new AvailableFilters(this.AvailableFiltersClient, 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/availableFilters.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 AvailableFilters {
private _instance: AxiosInstance;
private _send: TSendFunction;

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

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

if (window.sessionStorage.getItem("OIDN_NUMBER")) {
endpoint += `&oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`;
}

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

return data;
};
}
4 changes: 2 additions & 2 deletions pwa/src/apiService/resources/openWoo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export default class OpenWoo {
filters,
)}&_order[Publicatiedatum]=desc&_limit=${limit}&_page=${currentPage}`;

if (process.env.GATSBY_OIDN_NUMBER) {
endpoint += `&oidn=${process.env.GATSBY_OIDN_NUMBER}`;
if (window.sessionStorage.getItem("OIDN_NUMBER")) {
endpoint += `&oidn=${window.sessionStorage.getItem("OIDN_NUMBER")}`;
}

const { data } = await this._send(this._instance, "GET", endpoint);
Expand Down
71 changes: 0 additions & 71 deletions pwa/src/data/PublicationType.ts

This file was deleted.

98 changes: 0 additions & 98 deletions pwa/src/data/features.ts

This file was deleted.

17 changes: 17 additions & 0 deletions pwa/src/hooks/availableFilters.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 useAvailableFilters = () => {
const API: APIService | null = React.useContext(APIContext);

const getCategories = () =>
useQuery<any, Error>(["available_catagories"], () => API?.AvailableFilters.getCategories(), {
onError: (error) => {
console.warn(error.message);
},
});

return { getCategories };
};
6 changes: 1 addition & 5 deletions pwa/src/hooks/footerContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import { DEFAULT_FOOTER_CONTENT_URL } from "../templates/templateParts/footer/Fo
export const useFooterContent = () => {
const API: APIService | null = React.useContext(APIContext);

const fileName = getFileNameFromUrl(
process.env.GATSBY_FOOTER_CONTENT !== undefined && process.env.GATSBY_FOOTER_CONTENT.length !== 0
? process.env.GATSBY_FOOTER_CONTENT
: DEFAULT_FOOTER_CONTENT_URL,
);
const fileName = getFileNameFromUrl(window.sessionStorage.getItem("FOOTER_CONTENT") ?? DEFAULT_FOOTER_CONTENT_URL);

const getContent = () =>
useQuery<any, Error>(["contents", fileName], () => API?.FooterContent.getContent(fileName), {
Expand Down
2 changes: 1 addition & 1 deletion pwa/src/hooks/htmlParser/anchor/getAnchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const handleInternalLinks = (props: any, targetFile: string, location: string, d
if (!directoryFound) {
const hrefWithLeadingSlash = !props.href.startsWith("/") ? `/${props.href}` : props.href;

open(`${process.env.GATSBY_GITHUB_REPOSITORY_URL}/blob/master${hrefWithLeadingSlash}`);
open(`${window.sessionStorage.getItem("GITHUB_REPOSITORY_URL") ?? ""}/blob/master${hrefWithLeadingSlash}`);
}

return; // ensure no other flow is triggered
Expand Down
2 changes: 1 addition & 1 deletion pwa/src/hooks/htmlParser/image/getImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const getImage = (props: any) => {
let src = props.src;

if (!props.src.includes("https://" || "http://")) {
const sessionUrl = process.env.GATSBY_GITHUB_REPOSITORY_URL;
const sessionUrl = window.sessionStorage.getItem("GITHUB_REPOSITORY_URL");
const url = sessionUrl?.replace("https://github.com/", "");

src = `https://raw.githubusercontent.com/${url}/master/docs/features/${props.src}`;
Expand Down
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
Loading

0 comments on commit c074b50

Please sign in to comment.