@@ -52,11 +52,13 @@ const useEnvironmentalData = (origin: string) => {
52
52
method = 'GET' ,
53
53
headers,
54
54
body,
55
+ signal,
55
56
} : {
56
57
url : string ;
57
58
headers ?: HeadersInit ;
58
59
method : string ;
59
60
body ?: BodyInit ;
61
+ signal ?: AbortSignal ;
60
62
} ) => {
61
63
setAwaitingResponse ( true ) ;
62
64
@@ -65,6 +67,7 @@ const useEnvironmentalData = (origin: string) => {
65
67
headers,
66
68
method,
67
69
body,
70
+ signal,
68
71
} ) ;
69
72
const stream = response ?. body ;
70
73
return stream ?. constructor ?. name === 'ReadableStream'
@@ -85,7 +88,10 @@ const useEnvironmentalData = (origin: string) => {
85
88
}
86
89
} ;
87
90
88
- const commitSubmission = async ( id : string ) : Promise < CommitSubmissionResult > => {
91
+ const commitSubmission = async (
92
+ id : string ,
93
+ { signal } : { signal ?: AbortSignal } = { } ,
94
+ ) : Promise < CommitSubmissionResult > => {
89
95
return handleRequest ( {
90
96
url : urlJoin (
91
97
NEXT_PUBLIC_ENVIRONMENTAL_SUBMISSION_API_URL ,
@@ -96,6 +102,7 @@ const useEnvironmentalData = (origin: string) => {
96
102
id ,
97
103
) ,
98
104
method : 'POST' ,
105
+ signal,
99
106
} ) ;
100
107
} ;
101
108
@@ -104,14 +111,20 @@ const useEnvironmentalData = (origin: string) => {
104
111
* @param id
105
112
* @returns
106
113
*/
107
- const fetchSubmissionById = async ( id : string ) : Promise < Submission > => {
114
+ const fetchSubmissionById = async (
115
+ id : string ,
116
+ { signal } : { signal ?: AbortSignal } = { } ,
117
+ ) : Promise < Submission > => {
108
118
return handleRequest ( {
109
119
url : urlJoin ( NEXT_PUBLIC_ENVIRONMENTAL_SUBMISSION_API_URL , 'submission' , id ) ,
110
120
method : 'GET' ,
121
+ signal,
111
122
} ) ;
112
123
} ;
113
124
114
- const fetchPreviousSubmissions = async ( ) : Promise < { data : DataRecord [ ] } > => {
125
+ const fetchPreviousSubmissions = async ( { signal } : { signal ?: AbortSignal } = { } ) : Promise < {
126
+ data : DataRecord [ ] ;
127
+ } > => {
115
128
const response = await handleRequest ( {
116
129
url : urlJoin (
117
130
NEXT_PUBLIC_ENVIRONMENTAL_SUBMISSION_API_URL ,
@@ -120,6 +133,7 @@ const useEnvironmentalData = (origin: string) => {
120
133
NEXT_PUBLIC_ENVIRONMENTAL_SUBMISSION_CATEGORY_ID ,
121
134
) ,
122
135
method : 'GET' ,
136
+ signal,
123
137
} ) ;
124
138
125
139
return { data : response . records } ;
@@ -181,7 +195,11 @@ const useEnvironmentalData = (origin: string) => {
181
195
* @param records
182
196
* @returns
183
197
*/
184
- const getAnalysisIds = async ( organization : string , records : UploadData [ ] ) => {
198
+ const getAnalysisIds = async (
199
+ organization : string ,
200
+ records : UploadData [ ] ,
201
+ { signal } : { signal ?: AbortSignal } = { } ,
202
+ ) => {
185
203
// Construct query parameters
186
204
const queryParams = new URLSearchParams ( {
187
205
entityName : 'sample' ,
@@ -217,6 +235,7 @@ const useEnvironmentalData = (origin: string) => {
217
235
method : 'POST' ,
218
236
headers : { 'Content-Type' : 'application/json' } ,
219
237
body : JSON . stringify ( sqonFilter ) ,
238
+ signal,
220
239
} ) ;
221
240
222
241
if ( ! queryResponse . records ) {
0 commit comments