(favorite) save favorite repos

This commit is contained in:
2021-03-19 23:01:31 +01:00
parent 2faabb6c0e
commit 5fcf3c9df5
11 changed files with 308 additions and 44 deletions

View File

@@ -1,10 +1,11 @@
import { Octokit } from '@octokit/rest'
import { RepoBase } from '@/modules/interfaces/RepoBase'
import { useAsyncState } from '@vueuse/core'
import { useGitHubLogin } from '@/hooks/useGitHubLogin.hook'
export const useRepos = () => {
const { username, accessToken } = useGitHubLogin()
const repos = useAsyncState(async () => {
const repos = useAsyncState<RepoBase[]>(async () => {
if (!accessToken.value || !username.value) {
return []
}
@@ -18,7 +19,11 @@ export const useRepos = () => {
per_page: 100
})
return repoList.data.items.map((item) => item.name)
return repoList.data.items.map((item) => ({
id: `${item.id}`,
name: item.name,
isPrivate: item.private
}))
}, [])
return {