-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
studio: show a message or error component when there are no claimants #669 #924
Changes from 1 commit
ac358c5
1521be2
f928b53
ec53326
f375bf7
585b680
8fe848a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import { | |
Typography, | ||
Tooltip, | ||
ConfigProvider, | ||
Result | ||
} from 'antd'; | ||
import { PlusOutlined, SearchOutlined } from '@ant-design/icons'; | ||
import { Link, useLocation, useHistory } from 'react-router-dom'; | ||
|
@@ -23,6 +24,8 @@ import getUrlParams from '../../utils/getUrlParams'; | |
import Loader from '../../components/Loader'; | ||
import { Helmet } from 'react-helmet'; | ||
import Filters from '../../utils/filters'; | ||
import { getRatings } from '../../actions/ratings'; | ||
import { getClaimants } from '../../actions/claimants'; | ||
|
||
const { Option } = Select; | ||
|
||
|
@@ -65,6 +68,33 @@ function Claims({ permission }) { | |
dispatch(getClaims(params)); | ||
}; | ||
|
||
React.useEffect(() => { | ||
fetchClaimants(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
const fetchClaimants = () => { | ||
dispatch(getClaimants()); | ||
}; | ||
|
||
useEffect(() => { | ||
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 { claims, total, loading } = useSelector((state) => { | ||
const node = state.claims.req.find((item) => { | ||
return deepEqual(item.query, params); | ||
|
@@ -86,6 +116,8 @@ function Claims({ permission }) { | |
return { claims: [], total: 0, loading: state.claims.loading }; | ||
}); | ||
|
||
console.log(ratingsCount, loading) | ||
|
||
const onSave = (values) => { | ||
let searchFilter = new URLSearchParams(); | ||
Object.keys(values).forEach(function (key) { | ||
|
@@ -115,7 +147,34 @@ function Claims({ permission }) { | |
}); | ||
}; | ||
|
||
return loading ? ( | ||
if (!loading && !claimantsLoading && claimantsCount === 0){ | ||
return ( | ||
<Result | ||
status={'403'} | ||
title={'Please create a claimant.'} | ||
subTitle="You cannot create a claim without a claimant." | ||
extra={ | ||
<Link to="/claimants/create"> | ||
<Button type="primary">Create claimant</Button> | ||
</Link> | ||
} | ||
/>) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ishpaul777 can the case when both ratings and claimants aren't present be handled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean showing both at same time ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we can refactor this to have create rating and create claimants button inside and then conditionally render both or one. |
||
if (!loading && ratingsCount === 0){ | ||
return (<Result | ||
status={'403'} | ||
title={'Please create Ratings.'} | ||
subTitle="You cannot create a claim without a ratings." | ||
extra={ | ||
<Link to="/ratings/create"> | ||
<Button type="primary">Create Ratings</Button> | ||
</Link> | ||
} | ||
/>) | ||
} | ||
|
||
return (loading) ? ( | ||
<Loader /> | ||
) : ( | ||
<Space direction="vertical"> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishpaul777 remove logs