on master help sign in
Add invite limit message on Invites page (#857)
c9cd5baWill Galebach
src/lib/useRoller.ts+10−1
@@ -244,6 +244,14 @@ export default function useRoller() {
244 [api, wallet, contracts]
244 [api, wallet, contracts]
245 );
245 );
246
246
247+ const getAndUpdatePoint = useCallback(
248+ async (point: number) => {
249+ const updatedPoint = await initPoint(point);
250+ updatePoint(updatedPoint);
251+ },
252+ [initPoint, updatePoint]
253+ );
254+
247 const checkForUpdates = useCallback(
255 const checkForUpdates = useCallback(
248 async ({
256 async ({
249 point,
257 point,
@@ -735,7 +743,7 @@ export default function useRoller() {
735 proxy,
743 proxy,
736 'spawn',
744 'spawn',
737 nonce,
745 nonce,
738− toWallet.spawn.keys.address,
746+ toWallet?.spawn?.keys?.address || to,
739 walletType,
747 walletType,
740 _web3,
748 _web3,
741 connector
749 connector
@@ -1047,6 +1055,7 @@ export default function useRoller() {
1047 config,
1055 config,
1048 configureNetworkKeys,
1056 configureNetworkKeys,
1049 generateInviteCodes,
1057 generateInviteCodes,
1058+ getAndUpdatePoint,
1050 getInvites,
1059 getInvites,
1051 getPoints,
1060 getPoints,
1052 getPointsDetails,
1061 getPointsDetails,
src/views/Invite/Cohort.scss+9
@@ -211,4 +211,13 @@
211 width: 12px;
211 width: 12px;
212 }
212 }
213 }
213 }
214+
215+ .invite-limit-message {
216+ border: 1px solid $light-gray;
217+ border-radius: $medium-border-radius;
218+ margin-top: 16px;
219+ padding: 16px;
220+ font-size: 14px;
221+ line-height: 1.4em;
222+ }
214}
223}
src/views/Invite/Cohort.tsx+13−2
@@ -76,6 +76,7 @@ export default function InviteCohort() {
76 generateInviteCodes,
76 generateInviteCodes,
77 getPendingTransactions,
77 getPendingTransactions,
78 getInvites,
78 getInvites,
79+ getAndUpdatePoint,
79 } = useRoller();
80 } = useRoller();
80 const { contracts }: any = useNetwork();
81 const { contracts }: any = useNetwork();
81 const { syncControlledPoints }: any = usePointCache();
82 const { syncControlledPoints }: any = usePointCache();
@@ -195,6 +196,7 @@ export default function InviteCohort() {
195 try {
196 try {
196 await generateInviteCodes(numInvites);
197 await generateInviteCodes(numInvites);
197 getPendingTransactions();
198 getPendingTransactions();
199+ getAndUpdatePoint(point.value);
198 pop();
200 pop();
199 } catch (error) {
201 } catch (error) {
200 // TODO: error is not used anywhere on the UI
202 // TODO: error is not used anywhere on the UI
@@ -209,6 +211,8 @@ export default function InviteCohort() {
209 getPendingTransactions,
211 getPendingTransactions,
210 pop,
212 pop,
211 setInviteGeneratingNum,
213 setInviteGeneratingNum,
214+ getAndUpdatePoint,
215+ point,
212 ]);
216 ]);
213
217
214 const downloadCsv = useCallback(() => {
218 const downloadCsv = useCallback(() => {
@@ -467,14 +471,21 @@ export default function InviteCohort() {
467 )}
471 )}
468 </BodyPane>
472 </BodyPane>
469 </Window>
473 </Window>
470− {showAddMoreButton && (
474+ {showAddMoreButton ? (
471 <Button
475 <Button
472 onClick={() => setShowInviteForm(true)}
476 onClick={() => setShowInviteForm(true)}
473 className="add-more"
477 className="add-more"
474 accessory={<Icon icon="ChevronEast" />}>
478 accessory={<Icon icon="ChevronEast" />}>
475 Add More
479 Add More
476 </Button>
480 </Button>
477− )}
481+ ) : point.l2Quota < 1 ? (
482+ <Box className="invite-limit-message">
483+ You have hit your weekly invite limit. You will be able to generate
484+ another
485+ <strong>{` ${config?.rollerQuota}`}</strong> invites on
486+ <strong>{` ${ddmmmYYYY(nextQuotaTime)}`}</strong>.
487+ </Box>
488+ ) : null}
478 <LoadingOverlay loading={loading} text={generatingCodesText} />
489 <LoadingOverlay loading={loading} text={generatingCodesText} />
479 </View>
490 </View>
480 );
491 );