on master help sign in
Add invite limit message on Invites page (#857)
commitc9cd5baa32063c6be8744f51c140a8eb91e754c3 authorWill Galebach <willbach@gmail.com> dateFri 17 Dec 2021, 15:49 (5 years ago) parentc431ebd
3 files changed+32−3
src/lib/useRoller.ts+10−1 src/views/Invite/Cohort.scss+9 src/views/Invite/Cohort.tsx+13−2
src/lib/useRoller.ts+10−1
@@ -244,6 +244,14 @@ export default function useRoller() {
244244 [api, wallet, contracts]
245245 );
246246
247+ const getAndUpdatePoint = useCallback(
248+ async (point: number) => {
249+ const updatedPoint = await initPoint(point);
250+ updatePoint(updatedPoint);
251+ },
252+ [initPoint, updatePoint]
253+ );
254+
247255 const checkForUpdates = useCallback(
248256 async ({
249257 point,
@@ -735,7 +743,7 @@ export default function useRoller() {
735743 proxy,
736744 'spawn',
737745 nonce,
738− toWallet.spawn.keys.address,
746+ toWallet?.spawn?.keys?.address || to,
739747 walletType,
740748 _web3,
741749 connector
@@ -1047,6 +1055,7 @@ export default function useRoller() {
10471055 config,
10481056 configureNetworkKeys,
10491057 generateInviteCodes,
1058+ getAndUpdatePoint,
10501059 getInvites,
10511060 getPoints,
10521061 getPointsDetails,
src/views/Invite/Cohort.scss+9
@@ -211,4 +211,13 @@
211211 width: 12px;
212212 }
213213 }
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+ }
214223}
src/views/Invite/Cohort.tsx+13−2
@@ -76,6 +76,7 @@ export default function InviteCohort() {
7676 generateInviteCodes,
7777 getPendingTransactions,
7878 getInvites,
79+ getAndUpdatePoint,
7980 } = useRoller();
8081 const { contracts }: any = useNetwork();
8182 const { syncControlledPoints }: any = usePointCache();
@@ -195,6 +196,7 @@ export default function InviteCohort() {
195196 try {
196197 await generateInviteCodes(numInvites);
197198 getPendingTransactions();
199+ getAndUpdatePoint(point.value);
198200 pop();
199201 } catch (error) {
200202 // TODO: error is not used anywhere on the UI
@@ -209,6 +211,8 @@ export default function InviteCohort() {
209211 getPendingTransactions,
210212 pop,
211213 setInviteGeneratingNum,
214+ getAndUpdatePoint,
215+ point,
212216 ]);
213217
214218 const downloadCsv = useCallback(() => {
@@ -467,14 +471,21 @@ export default function InviteCohort() {
467471 )}
468472 </BodyPane>
469473 </Window>
470− {showAddMoreButton && (
474+ {showAddMoreButton ? (
471475 <Button
472476 onClick={() => setShowInviteForm(true)}
473477 className="add-more"
474478 accessory={<Icon icon="ChevronEast" />}>
475479 Add More
476480 </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}
478489 <LoadingOverlay loading={loading} text={generatingCodesText} />
479490 </View>
480491 );