Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOT FIX] change phonNumber to phone to hide from user/self API #952

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions app/components/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
href={{this.STATUS_URL}}
>Status</a></li>
{{#if @dev}}
<li>
<LinkTo @route="subscribe" class="nav__element">Subscribe</LinkTo>
</li>
<li>
{{! TODO - remove query for dev when it goes to production }}
<LinkTo
Expand Down
3 changes: 3 additions & 0 deletions app/components/join-section.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
yet, but it won't be okay to not put in any efforts for yourself. We want
to value everyone's time and efforts.
</p>
<div class='links__container'>
<LinkTo data-test-join-link @route='subscribe' class='subscribe__link join__link'>Subscribe <span>🔔</span></LinkTo>
<LinkTo data-test-join-link @route='join' class='join__link'>Join the Squad</LinkTo>
</div>
</section>
{{else}}
<section data-test-join class='join'>
Expand Down
2 changes: 2 additions & 0 deletions app/constants/regex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const phoneNumberRegex =
/^[+]{1}(?:[0-9\-\\(\\)\\/.]\s?){6,15}[0-9]{1}$/;
17 changes: 9 additions & 8 deletions app/controllers/subscribe.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { action } from '@ember/object';
import { inject as service } from '@ember/service';
import { RDS_TWITTER, APPS } from '../constants/urls';
import { TOAST_OPTIONS } from '../constants/toast-options';
import { phoneNumberRegex } from '../constants/regex';

export default class SubscribeController extends Controller {
@service login;
Expand All @@ -13,6 +14,8 @@ export default class SubscribeController extends Controller {
@tracked userData = null;
@tracked isLoading = false;
@tracked showSubscribedMessage = false;
@service toast;
@tracked isPhoneValid = true;

RDS_TWITTER = RDS_TWITTER;

Expand All @@ -30,7 +33,8 @@ export default class SubscribeController extends Controller {
}

get isSubmitDisabled() {
return !this.email || (this.phone && !/^\+?\d*$/.test(this.phone));
const isPhoneValid = !this.phone || phoneNumberRegex.test(this.phone);
return !this.email || !isPhoneValid;
}

@action
Expand All @@ -45,11 +49,8 @@ export default class SubscribeController extends Controller {

@action
updatePhone(event) {
const input = event.target.value;
const isValidPhone = /^\+?\d*$/.test(input);
if (isValidPhone) {
this.phone = input;
}
this.phone = event.target.value;
this.isPhoneValid = !this.phone || phoneNumberRegex.test(this.phone);
}

@action
Expand All @@ -63,7 +64,7 @@ export default class SubscribeController extends Controller {
method: 'POST',
body: JSON.stringify({
email: this.email,
phoneNumber: this.phone,
phone: this.phone,
}),
headers: {
'Content-Type': 'application/json',
Expand All @@ -80,7 +81,7 @@ export default class SubscribeController extends Controller {
this.login.userData.isSubscribed = true;
this.isFormOpen = false;
this.showSubscribedMessage = true;
this.toast.info('🎉 You are already subscribed!', '', TOAST_OPTIONS);
this.toast.success('🎉 Thankyou for subscribing!', '', TOAST_OPTIONS);
}
} catch (error) {
console.log(error);
Expand Down
27 changes: 27 additions & 0 deletions app/styles/join-section.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
line-height: 175%;
}

.links__container {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
}

.join__link {
display: inline-block;
margin-top: 2rem;
Expand All @@ -54,11 +61,23 @@
padding: 1.25rem 3rem;
}

.subscribe__link {
display: flex;
justify-content: center;
align-items: center;
gap: 5px;
padding: 1.125rem 3.75rem;
}

.join__link:hover {
background-color: var(--color-pink);
transition-duration: 250ms;
}

.subscribe__link span {
font-size: 1.125rem;
}

.join__link--new {
background-color: var(--color-button-disabled);
cursor: not-allowed;
Expand Down Expand Up @@ -126,6 +145,10 @@
font-size: 1.25rem;
padding: 1rem 2.5rem;
}

.subscribe__link span {
font-size: 0.75rem;
}
}

@media (width <=425px) {
Expand All @@ -147,4 +170,8 @@
font-size: 1rem;
padding: 0.75rem 2rem;
}

.subscribe__link span {
font-size: 0.75rem;
}
}
11 changes: 10 additions & 1 deletion app/styles/subscribe.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
color: #374151;
}

.input__group input::placeholder {
color: #6b7280;
}

.input__group input {
padding: 0.75rem;
border: 1px solid #d1d5db;
Expand All @@ -155,7 +159,12 @@
font-weight: 400;
line-height: 17.5px;
text-align: left;
color: #6b7280;
color: #000;
}

.invalid-input {
border-color: #dc2626;
color: red;
}

.submit__btn {
Expand Down
23 changes: 11 additions & 12 deletions app/templates/subscribe.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@
<form {{on "submit" this.handleSubmit}}>
<div class="input__group">
<label for="email">Email Address</label>
<input type="email" id="email" placeholder="eg: [email protected]" required value={{this.email}} {{on "input" this.updateEmail}} />
</div>

<div class="input__group">
<label for="phone">Phone Number <span class="input__group__span">(Optional)</span></label>
<input
type="text"
id="phone"
value={{this.phone}}
{{on "input" this.updatePhone}}
placeholder="eg: +91 1234567890"
>
<input type="email" id="email" placeholder="eg: [email protected]" required value={{this.email}} {{on "input" this.updateEmail}} />
</div>

<div class="input__group">
<label for="phone" class="{{if this.isPhoneValid '' 'invalid-input'}}">Phone Number <span class="input__group__span" >(Optional)</span></label>
<input
type="tel"
id="phone"
value="{{this.phone}}"
{{on "input" this.updatePhone}}
placeholder="Please enter with the country code (e.g., +91 1234567890)."
>
</div>
<button class="notify__btn subscribe__button" disabled={{this.isSubmitDisabled}} type="submit">{{#if this.isLoading}} Subscribing... {{else}} Subscribe {{/if}}</button>
</form>
</div>
Expand Down
Loading