Skip to content

Commit

Permalink
problem: email error not detected after valid input
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Aug 14, 2024
1 parent 35d69a2 commit 075c366
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/components/NotifyMe.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@
import Login from './Login.svelte';
import { NDKPrivateKeySigner, NDKUser } from '@nostr-dev-kit/ndk';
let email: string;
let email: string = '';
let fax: string = '';
$: emailInValid = true;
$: emailError = '';
$: emailError = 'Email is invalid';
const emailRegex = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
$: if (email) {
if (!emailRegex.test(email)) {
emailInValid = true;
emailError = 'Email is invalid';
} else {
emailInValid = false;
emailError = '';
}
$: {
emailError = emailRegex.test(email) ? '' : 'Email is invalid';
}
$: {
emailInValid = emailRegex.test(email) ? false : true;
}
async function Subscribe() {
Expand Down Expand Up @@ -84,14 +82,15 @@
variant="nostr"
class="flex h-8 shrink-0 items-center justify-center rounded-sm"
>
Nostrocket is totally not ready yet but whatever
u r so early
</Badge>
</Dialog.Trigger>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>Subscribe for Updates</Dialog.Title>
<Dialog.Description>
Subscribe now and we'll ping you when there are new releases/features
Nostrocket is under active development, many things are broken. Subscribe now and we'll ping
you when there are new releases and new features.
</Dialog.Description>
<div class="flex flex-col gap-4 py-4">
{#if $currentUser}
Expand All @@ -101,18 +100,27 @@
{/if}
<Separator />
<span class="ml-auto mr-auto flex"
>If you don't use nostr, you can subscribe to updates with an email address instead</span
>If you don't use nostr, that's SAD! Whatever, I guess we can fax you or email you or
something</span
>
<div class="grid grid-cols-4 items-center gap-4">
<Label for="email" class="text-right">Email</Label>
<Input bind:value={email} id="email" placeholder="Your email" class="col-span-3" />
</div>
{#if emailError}
<!-- {#if emailError}
<div class="ml-4 p-0 text-sm text-red-500">{emailError}</div>
{/if} -->
<div class="grid grid-cols-4 items-center gap-4">
<Label for="fax" class="text-right">Fax number</Label>
<Input bind:value={fax} id="email" placeholder="Your fax number" class="col-span-3" />
</div>
{#if fax.length > 0}
<iframe src="https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1" allow="autoplay"
></iframe>
{/if}
</div>
<Button disabled={emailInValid} on:click={SubmitEmailAndSubscribe}
>Please email me with updates</Button
>{emailError ? emailError : "I'm lame, please email me with updates"}</Button
>
</Dialog.Header>
</Dialog.Content>
Expand Down

0 comments on commit 075c366

Please sign in to comment.