-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from ConductionNL/development
Development to main, week 47
- Loading branch information
Showing
10 changed files
with
4,231 additions
and
5,790 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { TSendFunction } from "../apiService"; | ||
import { AxiosInstance } from "axios"; | ||
|
||
export default class FooterContent { | ||
private _instance: AxiosInstance; | ||
private _send: TSendFunction; | ||
|
||
constructor(_instance: AxiosInstance, send: TSendFunction) { | ||
this._instance = _instance; | ||
this._send = send; | ||
} | ||
|
||
public getContent = async (fileName: string): Promise<any> => { | ||
const { data } = await this._send(this._instance, "GET", fileName); | ||
|
||
return data; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
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_FOOTER_CONTENT_URL } from "../templates/templateParts/footer/FooterTemplate"; | ||
|
||
export const useFooterContent = () => { | ||
const API: APIService | null = React.useContext(APIContext); | ||
|
||
const fileName = getFileNameFromUrl(window.sessionStorage.getItem("FOOTER_CONTENT") ?? DEFAULT_FOOTER_CONTENT_URL); | ||
|
||
const getContent = () => | ||
useQuery<any, Error>(["footer-content", fileName], () => API?.FooterContent.getContent(fileName), { | ||
onError: (error) => { | ||
console.warn(error.message); | ||
}, | ||
}); | ||
|
||
return { getContent }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const getFileNameFromUrl = (url: string) => { | ||
const finalSlashIndex = url.lastIndexOf("/"); | ||
return url.substring(finalSlashIndex + 1); | ||
}; | ||
|
||
export const removeFileNameFromUrl = (url: string) => { | ||
const finalSlashIndex = url.lastIndexOf("/"); | ||
return url.replace(`/${url.substring(finalSlashIndex + 1)}`, ""); | ||
}; |
Oops, something went wrong.