diff --git a/studio/src/pages/claims/index.js b/studio/src/pages/claims/index.js index 50528f29..dc26f8ac 100644 --- a/studio/src/pages/claims/index.js +++ b/studio/src/pages/claims/index.js @@ -11,7 +11,7 @@ import { Typography, Tooltip, ConfigProvider, - Result + Result, } from 'antd'; import { PlusOutlined, SearchOutlined } from '@ant-design/icons'; import { Link, useLocation, useHistory } from 'react-router-dom'; @@ -78,22 +78,24 @@ function Claims({ permission }) { }; useEffect(() => { - fetchRatings() + fetchRatings(); // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) + }, []); const fetchRatings = () => { dispatch(getRatings()); - } - - const { claimantsCount, ratingsCount, claimantsLoading } = useSelector(({ claimants, ratings }) => { - return { - claimantsCount: claimants?.req?.[0]?.data ? claimants?.req?.[0]?.data.length : 0, - ratingsCount: Object.keys(ratings.details).length, - claimantsLoading: claimants.loading - }; - }); + }; + const { claimantsCount, ratingsCount, claimantsLoading, ratingsLoading } = useSelector( + ({ claimants, ratings }) => { + return { + claimantsCount: claimants?.req?.[0]?.data ? claimants?.req?.[0]?.data.length : 0, + ratingsCount: Object.keys(ratings.details).length, + claimantsLoading: claimants.loading, + ratingsLoading: ratings.loading, + }; + }, + ); const { claims, total, loading } = useSelector((state) => { const node = state.claims.req.find((item) => { @@ -145,34 +147,51 @@ function Claims({ permission }) { }); }; - if (!loading && !claimantsLoading && claimantsCount === 0){ - return ( - - - - } - />) - } + if ( + (!loading && !claimantsLoading && claimantsCount === 0) || + (!ratingsLoading && ratingsCount === 0) + ) { + const isRatingsCountZero = !ratingsLoading && ratingsCount === 0; + const isClaimantsCountZero = !claimantsLoading && claimantsCount === 0; - if (!loading && ratingsCount === 0){ - return ( - - - } - />) + const title = + isClaimantsCountZero && isRatingsCountZero + ? 'No claimants and ratings found' + : isClaimantsCountZero + ? 'No claimants found' + : 'No ratings found'; + + const subTitle = + isClaimantsCountZero && isRatingsCountZero + ? 'Create claimants and ratings first to create claims' + : isClaimantsCountZero + ? 'Create claimants to first to create claims' + : 'Create ratings first to create claims'; + + const extra = + isClaimantsCountZero && isRatingsCountZero ? ( + + + + + + + + + ) : isClaimantsCountZero ? ( + + + + ) : ( + + + + ); + + return ; } - return (loading) ? ( + return loading ? ( ) : (