Skip to content

Commit

Permalink
fixed the dega-api issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vsumit89 committed Sep 4, 2022
1 parent dffb1e6 commit 348f669
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions studio/src/pages/claims/CreateClaim.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import ClaimCreateForm from './components/ClaimForm';
import { useDispatch } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { createClaim } from '../../actions/claims';
import { useHistory } from 'react-router-dom';
import { Link, useHistory } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import { Button, Result } from 'antd';

function CreateClaim() {
const history = useHistory();
Expand All @@ -12,10 +13,33 @@ function CreateClaim() {
const onCreate = (values) => {
dispatch(createClaim(values)).then(() => history.push('/claims'));
};

const { claimantsCount } = useSelector(({ claimants }) => {
return {
claimantsCount: (claimants?.req?.[0]?.data) ? claimants?.req?.[0]?.data : 0
}
})

return (
<>
<Helmet title={'Create Claim'} />
<ClaimCreateForm onCreate={onCreate} />
{
claimantsCount ? (
<ClaimCreateForm onCreate={onCreate} />
)
: (
<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>
}
/>
)
}
</>
);
}
Expand Down

0 comments on commit 348f669

Please sign in to comment.