feat: [code-288]: fix endpoint and payloads

This commit is contained in:
calvin 2023-06-07 14:44:17 -06:00
parent 4b4d1c9a08
commit d65d01b3d0
4 changed files with 15 additions and 13 deletions

View File

@ -49,7 +49,9 @@ export default function Compare() {
error: commitsError,
refetch,
response
} = useGet<TypesCommit[]>({
} = useGet<{
commits: TypesCommit[]
}>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: {
limit,
@ -162,10 +164,10 @@ export default function Compare() {
}, [repoMetadata, sourceGitRef, targetGitRef, getString])
useEffect(() => {
if (commits?.length) {
setTitle(commits[0].title as string)
if (commits?.commits?.length) {
setTitle(commits.commits[0].title as string)
}
}, [commits])
}, [commits?.commits])
return (
<Container className={css.main}>
@ -268,14 +270,14 @@ export default function Compare() {
<TabTitleWithCount
icon={CodeIcon.Commit}
title={getString('commits')}
count={commits?.length || 0}
count={commits?.commits?.length || 0}
padding={{ left: 'medium' }}
/>
),
panel: (
<Container padding="xlarge">
<CommitsView
commits={commits || []}
commits={commits?.commits || []}
repoMetadata={repoMetadata}
emptyTitle={getString('compareEmptyDiffTitle')}
emptyMessage={getString('compareEmptyDiffMessage')}

View File

@ -110,7 +110,7 @@ export function FileContent({
const [page, setPage] = usePageIndex()
const { data: commits, response } = useGet<{ commits: TypesCommit[]; rename_details: RenameDetails[] }>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: {
limit: LIST_FETCHING_LIMIT,
page,

View File

@ -29,7 +29,7 @@ const SingleFileRenameHistory = (props: {
commits: TypesCommit[]
rename_details: RenameDetails[]
}>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
lazy: true
})
@ -121,7 +121,7 @@ const AllFilesRenameHistory = (props: {
const { rename_details, repoMetadata, fileVisibility, setFileVisibility, setActiveTab } = props
const [page, setPage] = usePageIndex()
const { response } = useGet<{ commits: TypesCommit[]; rename_details: RenameDetails[] }>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commitsV2`,
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
lazy: true
})

View File

@ -32,7 +32,7 @@ export default function RepositoryCommits() {
response,
error: errorCommits,
loading: loadingCommits
} = useGet<TypesCommit[]>({
} = useGet<{ commits: TypesCommit[]}>({
path: `/api/v1/repos/${repoMetadata?.path}/+/commits`,
queryParams: {
limit: LIST_FETCHING_LIMIT,
@ -55,9 +55,9 @@ export default function RepositoryCommits() {
/>
<PageBody error={getErrorMessage(error || errorCommits)} retryOnError={voidFn(refetch)}>
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits && loadingCommits} />
<LoadingSpinner visible={loading || loadingCommits} withBorder={!!commits?.commits && loadingCommits} />
{(repoMetadata && !!commits?.length && (
{(repoMetadata && !!commits?.commits?.length && (
<Container padding="xlarge" className={css.resourceContent}>
<Container className={css.contentHeader}>
<Layout.Horizontal spacing="medium">
@ -81,7 +81,7 @@ export default function RepositoryCommits() {
</Container>
<CommitsView
commits={commits}
commits={commits?.commits}
repoMetadata={repoMetadata}
emptyTitle={getString('noCommits')}
emptyMessage={getString('noCommitsMessage')}