@@ -4,6 +4,12 @@ import React, { useEffect, useState } from 'react';
44import { useFetch } from 'shared/hooks/BackendAPI/useFetch' ;
55
66type KymaResourceType = {
7+ apiVersion : string ;
8+ kind : string ;
9+ metadata : {
10+ name : string ;
11+ namespace : string ;
12+ } ;
713 spec : {
814 modules : {
915 name : string ;
@@ -16,25 +22,25 @@ type KymaResourceType = {
1622 } ;
1723} ;
1824
19- export function useModuleStatus ( resource : any ) {
25+ export function useModuleStatus ( resource : KymaResourceType ) {
2026 const fetch = useFetch ( ) ;
2127 const [ data , setData ] = useState < any > ( null ) ;
2228 const [ loading , setLoading ] = useState ( true ) ;
2329 const [ error , setError ] = useState < Error | null > ( null ) ;
2430
25- const path = resource ?. resource ?. metadata ?. namespace
26- ? `/apis/${ resource ?. resource ?. apiVersion } /namespaces/${
27- resource ?. resource ?. metadata ?. namespace
28- } /${ pluralize ( resource ?. resource ?. kind || '' ) . toLowerCase ( ) } /${
29- resource ?. resource ?. metadata ?. name
31+ const path = resource ?. metadata ?. namespace
32+ ? `/apis/${ resource ?. apiVersion } /namespaces/${
33+ resource ?. metadata ?. namespace
34+ } /${ pluralize ( resource ?. kind || '' ) . toLowerCase ( ) } /${
35+ resource ?. metadata ?. name
3036 } `
31- : `/apis/${ resource ?. resource ?. apiVersion } /${ pluralize (
32- resource ?. resource ?. kind || '' ,
33- ) . toLowerCase ( ) } /${ resource ?. resource ?. metadata ?. name } `;
37+ : `/apis/${ resource ?. apiVersion } /${ pluralize (
38+ resource ?. kind || '' ,
39+ ) . toLowerCase ( ) } /${ resource ?. metadata ?. name } `;
3440
3541 useEffect ( ( ) => {
3642 async function fetchModule ( ) {
37- if ( ! resource ?. resource ) return ;
43+ if ( ! resource ) return ;
3844 try {
3945 const response = await fetch ( { relativeUrl : path } ) ;
4046 const status = ( await response . json ( ) ) ?. status ;
@@ -52,7 +58,7 @@ export function useModuleStatus(resource: any) {
5258 // eslint-disable-next-line react-hooks/exhaustive-deps
5359 } , [ path ] ) ;
5460
55- return { data : data , loading : loading , error : error } ;
61+ return { data, loading, error } ;
5662}
5763
5864export const findStatus = (
0 commit comments