From 2f7a4bb3de4ff346a928f6887bc2fb4a5973977d Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 9 Oct 2020 02:12:36 +0300 Subject: feat: show latest release patchnotes on homepage --- src/hooks/APIClient.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/hooks') diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index 68413b0..1d4110c 100644 --- a/src/hooks/APIClient.ts +++ b/src/hooks/APIClient.ts @@ -1,5 +1,6 @@ import useSWR, { responseInterface } from 'swr'; import { User, Poll, Feedback } from 'which-types'; +import axios from 'axios'; import { get } from '../requests'; type Response = responseInterface; @@ -24,3 +25,21 @@ export const useFeed = (): Response => { export const useFeedback = (): Response => { return useSWR('/feedback', fetcher); }; + +interface Release { + url: string; + description: string; + version: string; + name: string; +} + +export const usePatchNotes = (): Response => { + const fetchRelease = () => axios.get('https://api.github.com/repos/which-ecosystem/which/releases/latest') + .then(({ data }) => ({ + name: data.name, + url: data.html_url, + version: data.tag_name, + description: data.body + })); + return useSWR('/patchnotes', fetchRelease, { revalidateOnFocus: false }); +}; -- cgit v1.2.3 From 6514ed55e3f608f468e103cacad547aed276b8bf Mon Sep 17 00:00:00 2001 From: eug-vs Date: Fri, 9 Oct 2020 03:26:42 +0300 Subject: feat: display version chip on ReviewCard --- src/hooks/APIClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/hooks') diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index 1d4110c..1793843 100644 --- a/src/hooks/APIClient.ts +++ b/src/hooks/APIClient.ts @@ -26,7 +26,7 @@ export const useFeedback = (): Response => { return useSWR('/feedback', fetcher); }; -interface Release { +export interface Release { url: string; description: string; version: string; -- cgit v1.2.3