From b8eb008dd5927fb736e56699637f5f8549965eae Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Wed, 6 Dec 2023 18:20:54 +0100
Subject: refactor(hooks): replace useGithubApi with useGithubRepoMeta

* use GraphQL API instead of REST (the inconvenient however is that we
now need an authorization token...)
* move fetcher in services
* add tests
* mock response using MSW
---
 src/utils/hooks/use-github-api.tsx | 28 ----------------------------
 1 file changed, 28 deletions(-)
 delete mode 100644 src/utils/hooks/use-github-api.tsx

(limited to 'src/utils/hooks/use-github-api.tsx')

diff --git a/src/utils/hooks/use-github-api.tsx b/src/utils/hooks/use-github-api.tsx
deleted file mode 100644
index aa9e3f7..0000000
--- a/src/utils/hooks/use-github-api.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import useSWR, { Fetcher } from 'swr';
-import { SWRResult } from '../../types';
-
-export type RepoData = {
-  created_at: string;
-  updated_at: string;
-  stargazers_count: number;
-};
-
-const fetcher: Fetcher<RepoData, string> = (...args) =>
-  fetch(...args).then((res) => res.json());
-
-/**
- * Retrieve data from Github API.
- *
- * @param repo - The Github repo (`owner/repo-name`).
- * @returns The repository data.
- */
-export const useGithubApi = (repo: string): SWRResult<RepoData> => {
-  const apiUrl = repo ? `https://api.github.com/repos/${repo}` : null;
-  const { data, error } = useSWR<RepoData>(apiUrl, fetcher);
-
-  return {
-    data,
-    isLoading: !error && !data,
-    isError: error,
-  };
-};
-- 
cgit v1.2.3

