Skip to content

Commit c597947

Browse files
committed
improve(home): throttle email resending
1 parent 5870c6a commit c597947

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

apps/client/src/pages/home/FinishRegistration.vue

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
<Gap style="height: 24px" />
1515

1616
<DeepBtn
17-
label="Resend verification email"
17+
:label="`Resend verification email${
18+
secondsRemaining > 0 ? ` (${secondsRemaining}s)` : ''
19+
}`"
1820
color="primary"
1921
style="font-size: 16px; padding: 10px 22px"
2022
@click="resendVerificationEmail()"
23+
:disabled="secondsRemaining > 0"
2124
/>
2225

2326
<Gap style="height: 64px" />
@@ -34,22 +37,31 @@
3437
</template>
3538

3639
<script setup lang="ts">
40+
import { useIntervalFn } from '@vueuse/core';
3741
import { handleError } from 'src/code/utils/misc';
3842
3943
useMeta(() => ({
4044
title: 'Finish registration - DeepNotes',
4145
}));
4246
47+
const secondsRemaining = ref(60);
48+
49+
useIntervalFn(() => {
50+
secondsRemaining.value--;
51+
}, 1000);
52+
4353
async function resendVerificationEmail() {
4454
try {
4555
await trpcClient.users.account.resendVerificationEmail.mutate({
46-
email: internals.sessionStorage?.getItem('email'),
56+
email: internals.sessionStorage?.getItem('email')!,
4757
});
4858
4959
$quasar().notify({
5060
message: 'Verification email resent.',
5161
type: 'positive',
5262
});
63+
64+
secondsRemaining.value = 60;
5365
} catch (error) {
5466
handleError(error);
5567
}

0 commit comments

Comments
 (0)