Skip to content

Commit b89e8ec

Browse files
author
Fahd
committed
chore(issuer): disable modal form when active
1 parent 7202742 commit b89e8ec

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

packages/polymath-issuer/src/pages/restrictions/components/IndividualRestrictionsForm.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ class AddIndividualRestriction extends Component {
187187
errors,
188188
touched,
189189
} = this.props;
190-
const today = moment();
191-
const restrictionDay = moment.unix(values.customDateTime);
192-
const isCustomActive = today.diff(restrictionDay, 'seconds') > 0;
193190
return (
194191
<Form className="global-restrictions" onSubmit={handleSubmit}>
195192
<Grid>
@@ -322,7 +319,7 @@ class AddIndividualRestriction extends Component {
322319
</Grid.Row>
323320
</Fragment>
324321
)}
325-
{!isCustomActive && values.customRestriction && (
322+
{values.customRestriction && (
326323
<Fragment>
327324
<Grid.Row>
328325
<Grid.Col gridSpan={12}>
@@ -500,7 +497,6 @@ const formikEnhancer = withFormik({
500497
.startOf('day')
501498
.unix();
502499
return {
503-
customDateTime: props.individualRestriction.customStartTime || null,
504500
dailyModified: props.individualRestriction ? true : false,
505501
customModified: props.individualRestriction ? true : false,
506502
address: props.individualRestriction.address,

packages/polymath-issuer/src/pages/restrictions/components/IndividualRestrictionsTable.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,21 @@ class IndividualRestrictionsTable extends Component<Props, State> {
7575
isUploadCsvModal: false,
7676
};
7777

78+
checkRestrictionActive = customStartTime => {
79+
const today = moment();
80+
const restrictionDay = moment.unix(customStartTime);
81+
const isActive = today.diff(restrictionDay, 'seconds') > 0;
82+
return isActive;
83+
};
84+
7885
editAddress = address => {
7986
if (address === '0') return;
8087
const { individualRestrictions } = this.props;
8188
let restriction = individualRestrictions.find(i => i.address === address);
82-
if (!restriction.dailyAllowedTokens && restriction.customAllowedTokens)
89+
if (
90+
restriction.customAllowedTokens &&
91+
this.checkRestrictionActive(restriction.customStartTime)
92+
)
8393
return;
8494
this.props.modifyIndividualRestriction(restriction);
8595
this.setState({ isIndividualRestrictionModalOpen: true });

0 commit comments

Comments
 (0)