@@ -27,15 +27,6 @@ function copilotOpportunityFactory(data: any): CopilotOpportunity {
27
27
}
28
28
}
29
29
30
- /**
31
- * Creates a CopilotApplication object by merging the provided data and its nested data
32
- * @param data
33
- * @returns
34
- */
35
- function opportunityApplicationFactory ( data : any ) : CopilotApplication [ ] {
36
- return data
37
- }
38
-
39
30
export interface CopilotOpportunitiesResponse {
40
31
isValidating : boolean ;
41
32
data : CopilotOpportunity [ ] ;
@@ -52,7 +43,9 @@ export interface CopilotOpportunitiesResponse {
52
43
export const useCopilotOpportunities = ( ) : CopilotOpportunitiesResponse => {
53
44
const getKey = ( pageIndex : number , previousPageData : CopilotOpportunity [ ] ) : string | undefined => {
54
45
if ( previousPageData && previousPageData . length < PAGE_SIZE ) return undefined
55
- return `${ copilotBaseUrl } /copilots/opportunities?page=${ pageIndex + 1 } &pageSize=${ PAGE_SIZE } &sort=createdAt desc`
46
+ return `
47
+ ${ copilotBaseUrl } /copilots/opportunities?page=${ pageIndex + 1 } &pageSize=${ PAGE_SIZE } &sort=createdAt desc
48
+ `
56
49
}
57
50
58
51
const fetcher = ( url : string ) : Promise < CopilotOpportunity [ ] > => xhrGetAsync < CopilotOpportunity [ ] > ( url )
@@ -106,7 +99,7 @@ export const useCopilotOpportunity = (opportunityId?: string): CopilotOpportunit
106
99
*/
107
100
export const applyCopilotOpportunity = async ( opportunityId : number , request : {
108
101
notes ?: string ;
109
- } ) => {
102
+ } ) : Promise < CopilotApplication > => {
110
103
const url = `${ copilotBaseUrl } /copilots/opportunity/${ opportunityId } /apply`
111
104
112
105
return xhrPostAsync ( url , request , { } )
@@ -119,7 +112,9 @@ export const applyCopilotOpportunity = async (opportunityId: number, request: {
119
112
* @returns {CopilotApplicationResponse } - The response containing the copilot application data.
120
113
*/
121
114
export const useCopilotApplications = ( opportunityId ?: string ) : CopilotApplicationResponse => {
122
- const url = opportunityId ? buildUrl ( `${ copilotBaseUrl } /copilots/opportunity/${ opportunityId } /applications` ) : undefined
115
+ const url = opportunityId
116
+ ? buildUrl ( `${ copilotBaseUrl } /copilots/opportunity/${ opportunityId } /applications` )
117
+ : undefined
123
118
124
119
const fetcher = ( urlp : string ) : Promise < CopilotApplication [ ] > => xhrGetAsync < CopilotApplication [ ] > ( urlp )
125
120
. then ( data => data )
0 commit comments