diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-10-09 03:35:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 03:35:31 +0300 |
commit | fcaddcd6ad8607d05279acdb87675de6180ac1cb (patch) | |
tree | 818dc66ce2e45b5f29728b1e6654935d616ad3d5 /src/hooks | |
parent | a5d0f3edcd5478c81262524cbfef8273a065df36 (diff) | |
parent | 5b81a690ed3c407aeb934b92fdad4a37c7e01a4b (diff) | |
download | which-ui-fcaddcd6ad8607d05279acdb87675de6180ac1cb.tar.gz |
Merge pull request #104 from which-ecosystem/feat/patch-notes
Display patch notes on home screen
Diffstat (limited to 'src/hooks')
-rw-r--r-- | src/hooks/APIClient.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hooks/APIClient.ts b/src/hooks/APIClient.ts index 68413b0..1793843 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<T> = responseInterface<T, Error>; @@ -24,3 +25,21 @@ export const useFeed = (): Response<Poll[]> => { export const useFeedback = (): Response<Feedback[]> => { return useSWR('/feedback', fetcher); }; + +export interface Release { + url: string; + description: string; + version: string; + name: string; +} + +export const usePatchNotes = (): Response<Release> => { + 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 }); +}; |