-
-
Notifications
You must be signed in to change notification settings - Fork 736
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use actionable change request data in UI (#8613)
This PR hooks up the actionable change request data to the counter in the UI. It: - creates a getter for the data. It only exposes data. We don't really care about error or loading for this (it's not an important piece of data), so we don't expose that just yet. - Adds orval-generated schema - Uses the hook in the UI. It also stwitches the previous "notification badge" for MUI's built-in badge. We already use that badge component for the event timeline, so I thought it would make sense to do it here too. Overall, the effect is pretty good, but there's a few kinks we might wanna work out. I'll make a follow-up for that (worked out in this PR after all)
- Loading branch information
1 parent
88e1ec5
commit dc18474
Showing
3 changed files
with
81 additions
and
41 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
30 changes: 30 additions & 0 deletions
30
frontend/src/hooks/api/getters/useActionableChangeRequests/useActionableChangeRequests.ts
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { formatApiPath } from 'utils/formatPath'; | ||
import handleErrorResponses from '../httpErrorResponseHandler'; | ||
import type { ActionableChangeRequestsSchema } from 'openapi/models/actionableChangeRequestsSchema'; | ||
import { useEnterpriseSWR } from '../useEnterpriseSWR/useEnterpriseSWR'; | ||
|
||
interface IUseActionableChangeRequestsOutput { | ||
total?: number; | ||
} | ||
|
||
export const useActionableChangeRequests = ( | ||
projectId: string, | ||
): IUseActionableChangeRequestsOutput => { | ||
const { data } = useEnterpriseSWR<ActionableChangeRequestsSchema>( | ||
{ total: 0 }, | ||
formatApiPath( | ||
`api/admin/projects/${projectId}/change-requests/actionable`, | ||
), | ||
fetcher, | ||
); | ||
|
||
return { | ||
total: data?.total, | ||
}; | ||
}; | ||
|
||
const fetcher = (path: string) => { | ||
return fetch(path) | ||
.then(handleErrorResponses('Actionable change requests')) | ||
.then((res) => res.json()); | ||
}; |
16 changes: 16 additions & 0 deletions
16
frontend/src/openapi/models/actionableChangeRequestsSchema.ts
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Generated by Orval | ||
* Do not edit manually. | ||
* See `gen:api` script in package.json | ||
*/ | ||
|
||
/** | ||
* Data related to actionable change requests in a project. | ||
*/ | ||
export interface ActionableChangeRequestsSchema { | ||
/** | ||
* The number of actionable change requests in the project. | ||
* @minimum 0 | ||
*/ | ||
total: number; | ||
} |