@@ -35,7 +35,7 @@ import {
3535import FormError from 'form/FormError';
3636
3737import { useActivateFlow } from './ActivateFlow';
38−import { hasWarnings } from 'form/helpers';
38+import { WARNING } from 'form/helpers';
3939
4040export default function ActivateCode() {
4141 const history = useHistory();
@@ -43,7 +43,7 @@ export default function ActivateCode() {
4343 const { contracts } = useNetwork();
4444 const impliedTicket = useImpliedTicket();
4545 const [hasDisclaimed] = useHasDisclaimed();
46− const warnings = useRef({});
46+ const didWarn = useRef(false);
4747
4848 const {
4949 setDerivedWallet,
@@ -71,7 +71,7 @@ export default function ActivateCode() {
7171 }, [hasDisclaimed, names.DISCLAIMER, names.PASSPORT, push]);
7272
7373 const validateForm = useCallback((values, errors) => {
74− warnings.current.ticket = null;
74+ didWarn.current = false;
7575
7676 if (hasErrors(errors)) {
7777 return errors;
@@ -106,10 +106,14 @@ export default function ActivateCode() {
106106 const incoming = [...owned, ...transferring];
107107
108108 if (incoming.length > 0) {
109− if (incoming.length > 1) {
110− warnings.current.ticket =
111− 'This invite code has multiple points available.\n' +
112− "Once you've activated this point, activate the next with the same process.";
109+ if (incoming.length > 1 && !didWarn.current) {
110+ didWarn.current = true;
111+ return {
112+ [WARNING]:
113+ 'This invite code has multiple points available. ' +
114+ "Once you've activated this point, " +
115+ 'activate the next with the same process.',
116+ };
113117 }
114118
115119 const point = parseInt(incoming[0], 10);
@@ -128,14 +132,6 @@ export default function ActivateCode() {
128132 [contracts, setDerivedPoint, setDerivedWallet, setInviteWallet]
129133 );
130134
131− const afterSubmit = useCallback(() => {
132− if (hasWarnings(warnings.current)) {
133− return;
134− }
135−
136− goToPassport();
137− }, [goToPassport]);
138−
139135 const initialValues = useMemo(() => ({ ticket: impliedTicket || '' }), [
140136 impliedTicket,
141137 ]);
@@ -150,9 +146,9 @@ export default function ActivateCode() {
150146 <BridgeForm
151147 validate={validate}
152148 onSubmit={onSubmit}
153− afterSubmit={afterSubmit}
149+ afterSubmit={goToPassport}
154150 initialValues={initialValues}>
155− {({ validating, submitting, submitSucceeded, handleSubmit }) => (
151+ {({ validating, submitting, handleSubmit }) => (
156152 <>
157153 <Grid.Item
158154 full
@@ -160,33 +156,25 @@ export default function ActivateCode() {
160156 name="ticket"
161157 label="Activation Code"
162158 disabled={!activationAllowed}
163− warning={warnings.current.ticket}
164159 />
165160
166161 <Grid.Item full as={FormError} />
167162
168− {submitSucceeded ? (
169− <Grid.Item
170− full
171− as={ForwardButton}
172− solid
173− className="mt4"
174− onClick={goToPassport}>
175− Continue Activation
176− </Grid.Item>
177− ) : (
178− <Grid.Item
179− full
180− as={SubmitButton}
181− className="mt4"
182− handleSubmit={handleSubmit}>
183− {validating
163+ <Grid.Item
164+ full
165+ as={SubmitButton}
166+ className="mt4"
167+ handleSubmit={handleSubmit}>
168+ {isWarning =>
169+ validating
184170 ? 'Deriving...'
185171 : submitting
186172 ? 'Generating...'
187− : 'Go'}
188− </Grid.Item>
189− )}
173+ : isWarning
174+ ? 'Continue Activation'
175+ : 'Go'
176+ }
177+ </Grid.Item>
190178
191179 {!activationAllowed && (
192180 <Grid.Item full as={WarningBox} className="mt4">