@@ -4,11 +4,11 @@ import useSWRInfinite, { SWRInfiniteResponse } from 'swr/infinite'
4
4
import { EnvironmentConfig } from '~/config'
5
5
import { xhrGetAsync , xhrPatchAsync , xhrPostAsync } from '~/libs/core'
6
6
import { buildUrl } from '~/libs/shared/lib/utils/url'
7
-
8
- import { CopilotRequest } from '../models/CopilotRequest'
9
7
import { Sort } from '~/apps/admin/src/platform/gamification-admin/src/game-lib'
10
8
import { getPaginatedAsync , PaginatedResponse } from '~/libs/core/lib/xhr/xhr-functions/xhr.functions'
11
9
10
+ import { CopilotRequest } from '../models/CopilotRequest'
11
+
12
12
const baseUrl = `${ EnvironmentConfig . API . V5 } /projects`
13
13
const PAGE_SIZE = 20
14
14
@@ -46,7 +46,7 @@ export type CopilotRequestsResponse = {
46
46
* @returns {CopilotRequestsResponse } - The response containing copilot requests.
47
47
*/
48
48
export const useCopilotRequests = ( sort : Sort , projectId ?: string ) : CopilotRequestsResponse => {
49
-
49
+
50
50
const getKey = ( pageIndex : number , previousPageData : CopilotRequest [ ] ) : string | undefined => {
51
51
if ( previousPageData && previousPageData . length < PAGE_SIZE ) return undefined
52
52
const url = buildUrl ( `${ baseUrl } ${ projectId ? `/${ projectId } ` : '' } /copilots/requests` )
@@ -55,13 +55,15 @@ export const useCopilotRequests = (sort: Sort, projectId?: string): CopilotReque
55
55
`
56
56
}
57
57
58
- const fetcher = ( url : string ) : Promise < PaginatedResponse < CopilotRequest [ ] > > => getPaginatedAsync < CopilotRequest [ ] > ( url )
59
- . then ( ( data : any ) => {
60
- return {
58
+ const fetcher = (
59
+ url : string ,
60
+ ) : Promise < PaginatedResponse < CopilotRequest [ ] > > => getPaginatedAsync < CopilotRequest [ ] > ( url )
61
+ . then ( ( data : any ) => (
62
+ {
61
63
...data ,
62
64
data : data . data . map ( copilotRequestFactory ) ,
63
65
}
64
- } )
66
+ ) )
65
67
66
68
const {
67
69
isValidating,
0 commit comments