Skip to content

Commit

Permalink
fix: only make account details call when user is part of org
Browse files Browse the repository at this point in the history
  • Loading branch information
calvin-codecov committed Jan 28, 2025
1 parent b5435b1 commit 5a43915
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/pages/OwnerPage/HeaderBanners/HeaderBanners.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const AlertBanners = ({ isUploadLimitExceeded, isApproachingUploadLimit }) => {
AlertBanners.propTypes = {
isUploadLimitExceeded: PropTypes.bool.isRequired,
isApproachingUploadLimit: PropTypes.bool.isRequired,
hasGhApp: PropTypes.bool.isRequired,
}

export default function HeaderBanners() {
Expand Down
3 changes: 3 additions & 0 deletions src/pages/OwnerPage/OwnerPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function OwnerPage() {
const { data: accountDetails } = useAccountDetails({
provider,
owner,
opts: {
enabled: !!ownerData?.isCurrentUserPartOfOrg,
},
})

const hasGhApp = !!accountDetails?.integrationId
Expand Down
13 changes: 5 additions & 8 deletions src/services/account/usePlanData.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('usePlanData', () => {
vi.restoreAllMocks()
})

it('returns an empty object', async () => {
it.only('returns an empty object', async () => {
setup({ trialData: undefined })
const { result } = renderHook(
() =>
Expand All @@ -141,13 +141,10 @@ describe('usePlanData', () => {
}),
{ wrapper }
)

await waitFor(() => expect(result.current.isError).toBeTruthy())
await waitFor(() =>
expect(result.current.error).toEqual(
expect.objectContaining({ status: 404 })
)
)
await waitFor(() => {
console.log('data: ', result.current.data)
expect(result.current.data).toStrictEqual({})
})
})
})
})
Expand Down
3 changes: 1 addition & 2 deletions src/services/account/usePlanData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const PlanDataSchema = z
.object({
owner: z
.object({
hasPrivateRepos: z.boolean(),
hasPrivateRepos: z.boolean().nullish(),
plan: PlanSchema.nullish(),
pretrialPlan: PretrialPlanSchema.nullish(),
})
Expand Down Expand Up @@ -118,7 +118,6 @@ export const usePlanData = ({ provider, owner, opts }: UsePlanDataArgs) =>
},
}).then((res) => {
const parsedRes = PlanDataSchema.safeParse(res?.data)

if (!parsedRes.success) {
return Promise.reject({
status: 404,
Expand Down

0 comments on commit 5a43915

Please sign in to comment.