Skip to content

Commit

Permalink
Merge pull request #475 from OpenCatalogi/publications
Browse files Browse the repository at this point in the history
added publication page
  • Loading branch information
remko48 authored Jul 3, 2024
2 parents a8d03bb + d66ad3c commit 7a6af75
Show file tree
Hide file tree
Showing 13 changed files with 1,500 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pwa/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ module.exports = {
pathname: "/github/[md]",
crumbLabel: "Markdown file",
},
{
pathname: "/publications/[publicationId]",
crumbLabel: "Publication",
},
],
},
},
Expand Down
13 changes: 13 additions & 0 deletions pwa/src/apiService/apiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Login from "./services/login";
import Me from "./services/me";
import { DEFAULT_HEADER_CONTENT_URL } from "../templates/templateParts/header/HeaderTemplate";
import HeaderContent from "./resources/headerContent";
import Publication from "./resources/publication";

export default class APIService {
public JWT?: string;
Expand Down Expand Up @@ -100,6 +101,14 @@ export default class APIService {
});
}

public get PublicationClient(): AxiosInstance {
return axios.create({
baseURL: removeFileNameFromUrl(
"https://raw.githubusercontent.com/ConductionNL/OpenCatalogApp/feature/AQ212-8/publicatie-modal/docs/dcat_example.json",
),
});
}

// Resources
public get Case(): Case {
return new Case(this.apiClient);
Expand Down Expand Up @@ -145,6 +154,10 @@ export default class APIService {
return new HeaderContent(this.HeaderContentClient);
}

public get Publication(): Publication {
return new Publication(this.PublicationClient);
}

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

export default class Publication {
private _instance: AxiosInstance;

constructor(_instance: AxiosInstance) {
this._instance = _instance;
}

public getContent = async (fileName: string): Promise<any> => {
const { data } = await Send(this._instance, "GET", fileName);

return data;
};
}
23 changes: 23 additions & 0 deletions pwa/src/hooks/publication.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from "react";
import { useQuery } from "react-query";
import APIService from "../apiService/apiService";
import APIContext from "../apiService/apiContext";
import { getFileNameFromUrl } from "../services/FileNameFromUrl";
import { DEFAULT_HEADER_CONTENT_URL } from "../templates/templateParts/header/HeaderTemplate";

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

const fileName = getFileNameFromUrl(
"https://raw.githubusercontent.com/ConductionNL/OpenCatalogApp/feature/AQ212-8/publicatie-modal/docs/dcat_example.json",
);

const getContent = () =>
useQuery<any, Error>(["contents", fileName], () => API?.Publication.getContent(fileName), {
onError: (error) => {
console.warn(error.message);
},
});

return { getContent };
};
2 changes: 1 addition & 1 deletion pwa/src/pages/components/ComponentsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PageProps } from "gatsby";
import * as React from "react";
import { PageProps } from "gatsby";
import { ComponentsTemplate } from "../../templates/components/ComponentsTemplate";

const ComponentsPage: React.FC<PageProps> = () => {
Expand Down
9 changes: 9 additions & 0 deletions pwa/src/pages/publications/PublicationsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from "react";
import { PageProps } from "gatsby";
import { ComponentsTemplate } from "../../templates/components/ComponentsTemplate";

const PublicationsPage: React.FC<PageProps> = () => {
return <ComponentsTemplate />;
};

export default PublicationsPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from "react";
import { PageProps } from "gatsby";
import { PublicationsDetailTemplate } from "../../../templates/publicationDetail/PublicationsDetailTemplate";

const PublicationsDetailPage: React.FC<PageProps> = (props: PageProps) => {
return <PublicationsDetailTemplate publicationId={props.params.componentId} />;
};
export default PublicationsDetailPage;
3 changes: 3 additions & 0 deletions pwa/src/pages/publications/[publicationId]/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PublicationsDetailPage from "./PublicationsDetailPage";

export default PublicationsDetailPage;
3 changes: 3 additions & 0 deletions pwa/src/pages/publications/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import PublicationsPage from "./PublicationsPage";

export default PublicationsPage;
Loading

0 comments on commit 7a6af75

Please sign in to comment.