4
4
getIsSuperUser ,
5
5
showToast ,
6
6
updateApplication ,
7
+ getApplicationById ,
7
8
} from './utils.js' ;
8
9
let nextLink ;
9
10
let isDataLoading = false ;
@@ -271,8 +272,33 @@ async function renderApplicationCards(next, status, isInitialRender) {
271
272
} ) ;
272
273
}
273
274
275
+ async function renderApplicationById ( id ) {
276
+ noApplicationFoundText . classList . add ( 'hidden' ) ;
277
+ changeLoaderVisibility ( { hide : false } ) ;
278
+ isDataLoading = true ;
279
+
280
+ try {
281
+ const application = await getApplicationById ( id ) ;
282
+
283
+ if ( ! application ) {
284
+ return noApplicationFoundText . classList . remove ( 'hidden' ) ;
285
+ }
286
+
287
+ const applicationCard = createApplicationCard ( { application } ) ;
288
+ applicationContainer . appendChild ( applicationCard ) ;
289
+ applicationContainer . classList . add ( 'center' ) ;
290
+ } catch ( error ) {
291
+ console . error ( 'Error fetching application by user ID:' , error ) ;
292
+ noApplicationFoundText . classList . remove ( 'hidden' ) ;
293
+ } finally {
294
+ isDataLoading = false ;
295
+ changeLoaderVisibility ( { hide : true } ) ;
296
+ }
297
+ }
298
+
274
299
( async function renderCardsInitial ( ) {
275
300
changeLoaderVisibility ( { hide : false } ) ;
301
+
276
302
const isSuperUser = await getIsSuperUser ( ) ;
277
303
if ( ! isSuperUser ) {
278
304
const unAuthorizedText = createElement ( {
@@ -284,8 +310,19 @@ async function renderApplicationCards(next, status, isInitialRender) {
284
310
changeLoaderVisibility ( { hide : true } ) ;
285
311
return ;
286
312
}
287
- await renderApplicationCards ( '' , status , true ) ;
288
- addIntersectionObserver ( ) ;
313
+
314
+ const queryString = window . location . search ;
315
+ const urlParams = new URLSearchParams ( queryString ) ;
316
+ const applicationId = urlParams . get ( 'id' ) ;
317
+
318
+ if ( applicationId ) {
319
+ await renderApplicationById ( applicationId ) ;
320
+ } else {
321
+ await renderApplicationCards ( '' , status , true ) ;
322
+ addIntersectionObserver ( ) ;
323
+ }
324
+
325
+ changeLoaderVisibility ( { hide : true } ) ;
289
326
} ) ( ) ;
290
327
291
328
const intersectionObserver = new IntersectionObserver ( async ( entries ) => {
0 commit comments