-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use positional arguments for suspense fetcher arguments
- Loading branch information
1 parent
6a8dcee
commit 703f2f6
Showing
5 changed files
with
60 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import { useRequest } from "@prismicio/editor-support/Suspense"; | ||
import { managerClient } from "@src/managerClient"; | ||
|
||
type UseGitReposArgs = Parameters<typeof managerClient.git.fetchRepos>[0]; | ||
|
||
const getGitRepos = async (args?: UseGitReposArgs) => { | ||
if (!args) { | ||
async function getGitRepos( | ||
provider?: "gitHub", | ||
owner?: string, | ||
query?: string, | ||
page?: number, | ||
) { | ||
if (provider === undefined || owner === undefined) { | ||
return; | ||
} | ||
|
||
return await managerClient.git.fetchRepos(args); | ||
}; | ||
return await managerClient.git.fetchRepos({ provider, owner, query, page }); | ||
} | ||
|
||
export const useGitRepos = (args?: UseGitReposArgs) => { | ||
return useRequest(getGitRepos, [args]); | ||
export const useGitRepos = ( | ||
args?: Parameters<typeof managerClient.git.fetchRepos>[0], | ||
) => { | ||
return useRequest(getGitRepos, [ | ||
args?.provider, | ||
args?.owner, | ||
args?.query, | ||
args?.page, | ||
]); | ||
}; |
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
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