Skip to content

Commit 7202742

Browse files
author
Fahd
committed
chore(issuer): disable custom restriction when active
1 parent 5824126 commit 7202742

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

packages/polymath-issuer/src/pages/restrictions/RestrictionsPage.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
getVolumeRestrictionModule,
3333
archiveVolumeRestrictionModule,
3434
} from '../../actions/restrictions';
35+
import moment from 'moment';
3536

3637
class RestrictionsPage extends Component {
3738
state = {
@@ -63,6 +64,14 @@ class RestrictionsPage extends Component {
6364
}
6465
};
6566

67+
checkRestrictionActive = () => {
68+
const { defaultRestriction } = this.props;
69+
const today = moment();
70+
const restrictionDay = moment(defaultRestriction);
71+
const isActive = today.diff(restrictionDay, 'seconds') > 0;
72+
return isActive;
73+
};
74+
6675
render() {
6776
const {
6877
token,
@@ -210,6 +219,7 @@ class RestrictionsPage extends Component {
210219
/>
211220
<ButtonLarge
212221
className="card-button"
222+
disabled={this.checkRestrictionActive()}
213223
onClick={() => this.handleOpen('custom')}
214224
>
215225
Configure Custom Restriction

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ 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;
190193
return (
191194
<Form className="global-restrictions" onSubmit={handleSubmit}>
192195
<Grid>
@@ -319,7 +322,7 @@ class AddIndividualRestriction extends Component {
319322
</Grid.Row>
320323
</Fragment>
321324
)}
322-
{values.customRestriction && (
325+
{!isCustomActive && values.customRestriction && (
323326
<Fragment>
324327
<Grid.Row>
325328
<Grid.Col gridSpan={12}>
@@ -497,6 +500,7 @@ const formikEnhancer = withFormik({
497500
.startOf('day')
498501
.unix();
499502
return {
503+
customDateTime: props.individualRestriction.customStartTime || null,
500504
dailyModified: props.individualRestriction ? true : false,
501505
customModified: props.individualRestriction ? true : false,
502506
address: props.individualRestriction.address,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ class IndividualRestrictionsTable extends Component<Props, State> {
7979
if (address === '0') return;
8080
const { individualRestrictions } = this.props;
8181
let restriction = individualRestrictions.find(i => i.address === address);
82+
if (!restriction.dailyAllowedTokens && restriction.customAllowedTokens)
83+
return;
8284
this.props.modifyIndividualRestriction(restriction);
8385
this.setState({ isIndividualRestrictionModalOpen: true });
8486
};

0 commit comments

Comments
 (0)