Skip to content

Commit 421f686

Browse files
committed
Verify mail and reset password pages
1 parent 8d64a2b commit 421f686

File tree

6 files changed

+122
-68
lines changed

6 files changed

+122
-68
lines changed

src/app/reset-password-page/reset-password-page.component.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
margin-top: 2vh;
5050
margin-bottom: 4vh;
5151
}
52+
.info-book-btn:hover {
53+
background-color: #3750a1;
54+
}
5255
.info-book-btn-disabled {
5356
display: flex;
5457
flex-direction: row;
@@ -95,3 +98,15 @@ input {
9598
margin-top: -2vw;
9699
margin-bottom: 2vw;
97100
}
101+
.back-to-login {
102+
margin-bottom: 2vw;
103+
align-self: center;
104+
color: rgba(169, 63, 5, 1);
105+
font-weight: 600;
106+
font-size: 1vw;
107+
cursor: pointer;
108+
transition: ease-in-out 0.2s;
109+
}
110+
.back-to-login:hover {
111+
color: rgb(115, 44, 5);
112+
}

src/app/reset-password-page/reset-password-page.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<button class="info-book-btn" [class.info-book-btn-disabled]="isButtonDisabled" [disabled]="isButtonDisabled" (click)="sendCodeToMail()">{{ isCodeSend ? "Send letter again" :"Send letter" }}</button>
1010
<span class="timer" *ngIf="isCodeSend">
1111
Didn’t receive the letter? Please check your spam folder or request another one in <b>{{ timer }}</b> seconds.</span>
12+
<span routerLink="/login" class="back-to-login">Return to sign up page</span>
1213
<hr class="down-hr">
1314
<span class="copyright">Copyright © 2024–2025 Orbistay.com™. All rights reserved.</span>
1415
</div>

src/app/reset-password-page/reset-password-page.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component } from '@angular/core';
22
import {TokenService} from '../token.service';
33
import {HttpClient} from '@angular/common/http';
44
import {interval, Subscription} from 'rxjs';
5+
import {ActivatedRoute} from '@angular/router';
56

67
@Component({
78
selector: 'app-reset-password-page',
@@ -15,14 +16,20 @@ export class ResetPasswordPageComponent {
1516
isButtonDisabled = false;
1617
email: string = "";
1718
timer = 60;
19+
isTokenPresent: boolean = false;
1820
private timerSubscription: Subscription | null = null;
1921

2022
constructor(private http : HttpClient,
21-
private tokenService: TokenService) {
23+
private tokenService: TokenService,
24+
private route: ActivatedRoute) {
2225
}
2326

2427
ngOnInit(): void {
25-
28+
this.route.queryParams.subscribe(params => {
29+
if (params['token']) {
30+
this.isTokenPresent = true;
31+
}
32+
});
2633
}
2734

2835
sendCodeToMail() {

src/app/verify-mail-page/verify-mail-page.component.css

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@
2222
gap: 1vh;
2323
text-align: left;
2424
}
25+
.booking-confirm-container {
26+
display: flex;
27+
flex-direction: column;
28+
width: 30%;
29+
gap: 1vh;
30+
text-align: center;
31+
}
32+
.success-icon {
33+
align-self: center;
34+
}
35+
2536
.main-header {
2637
color: rgba(7, 25, 95, 1);
2738
font-weight: 700;
@@ -52,6 +63,23 @@
5263
.info-book-btn:hover {
5364
background-color: #3750a1;
5465
}
66+
.info-book-btn-disabled {
67+
display: flex;
68+
flex-direction: row;
69+
background-color: rgba(217, 217, 217, 1);
70+
color: white;
71+
font-weight: 700;
72+
border-radius: 4px;
73+
font-size: calc(4px + 0.8vw);
74+
transition: ease-in-out 0.2s;
75+
width: 100%;
76+
padding: 0.5vw;
77+
align-self: center;
78+
justify-content: center;
79+
border: none;
80+
margin-top: 2vh;
81+
margin-bottom: 4vh;
82+
}
5583
.down-hr {
5684
background: rgba(217, 217, 217, 1);
5785
opacity: 10;
@@ -105,3 +133,15 @@ input {
105133
border-color: #A93F05;
106134
color: #A93F05;
107135
}
136+
.back-to-login {
137+
margin-bottom: 2vw;
138+
align-self: center;
139+
color: rgba(169, 63, 5, 1);
140+
font-weight: 600;
141+
font-size: 1vw;
142+
cursor: pointer;
143+
transition: ease-in-out 0.2s;
144+
}
145+
.back-to-login:hover {
146+
color: rgb(115, 44, 5);
147+
}

src/app/verify-mail-page/verify-mail-page.component.html

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
11
<div class="body">
22
<hr class="up-hr" style="margin-top: -1px">
33
<div class="booking-page">
4-
<div class="booking-details-container">
5-
<span class="main-header">Please verify your email</span>
6-
<span *ngIf="isCodeSend" class="description">We send you a code to <strong>{{ currentUser.email }}</strong> Please enter the code to continue.</span>
7-
<div class="code-inputs" *ngIf="isCodeSend">
8-
<input class="code-input" (input)="moveToNext($event, 0)" maxlength="1">
9-
<input class="code-input" (input)="moveToNext($event, 1)" maxlength="1">
10-
<input class="code-input" (input)="moveToNext($event, 2)" maxlength="1">
11-
<input class="code-input" (input)="moveToNext($event, 3)" maxlength="1">
12-
<input class="code-input" (input)="moveToNext($event, 4)" maxlength="1">
13-
<input class="code-input" (input)="moveToNext($event, 5)" maxlength="1">
14-
</div>
15-
<button (click)="sendCodeToMail()" class="info-book-btn">Send code</button>
4+
<div class="booking-details-container" *ngIf="!isTokenPresent">
5+
<span class="main-header">{{ isCodeSend ? "Check your email" :"Enter your email" }}</span>
6+
<span class="description" *ngIf="!isCodeSend">Please provide your email so that we can send you a letter with link to reset your password.</span>
7+
<span class="description" *ngIf="isCodeSend">We send email to {{ email }}. Please follow the instructions in the email to continue.</span>
8+
<input type="text" *ngIf="!isCodeSend" [(ngModel)]="email" placeholder="Enter your email"/>
9+
<button class="info-book-btn" [class.info-book-btn-disabled]="isButtonDisabled" [disabled]="isButtonDisabled" (click)="sendCodeToMail()">{{ isCodeSend ? "Send letter again" :"Send letter" }}</button>
10+
<span class="timer" *ngIf="isCodeSend">
11+
Didn’t receive the letter? Please check your spam folder or request another one in <b>{{ timer }}</b> seconds.</span>
12+
<span routerLink="/login" class="back-to-login">Return to sign up page</span>
13+
<hr class="down-hr">
14+
<span class="copyright">Copyright © 2024–2025 Orbistay.com™. All rights reserved.</span>
15+
</div>
16+
<div class="booking-confirm-container" *ngIf="isTokenPresent">
17+
<svg class="success-icon" xmlns="http://www.w3.org/2000/svg" width="5vw" height="5vw" viewBox="0 0 100 100" fill="none">
18+
<g clip-path="url(#clip0_1077_2951)">
19+
<path d="M50 9.375C60.7744 9.375 71.1076 13.6551 78.7262 21.2738C86.3449 28.8925 90.625 39.2256 90.625 50C90.625 60.7744 86.3449 71.1076 78.7262 78.7262C71.1076 86.3449 60.7744 90.625 50 90.625C39.2256 90.625 28.8925 86.3449 21.2738 78.7262C13.6551 71.1076 9.375 60.7744 9.375 50C9.375 39.2256 13.6551 28.8925 21.2738 21.2738C28.8925 13.6551 39.2256 9.375 50 9.375ZM50 100C63.2608 100 75.9785 94.7322 85.3553 85.3553C94.7322 75.9785 100 63.2608 100 50C100 36.7392 94.7322 24.0215 85.3553 14.6447C75.9785 5.26784 63.2608 0 50 0C36.7392 0 24.0215 5.26784 14.6447 14.6447C5.26784 24.0215 0 36.7392 0 50C0 63.2608 5.26784 75.9785 14.6447 85.3553C24.0215 94.7322 36.7392 100 50 100ZM72.0703 40.8203C73.9062 38.9844 73.9062 36.0156 72.0703 34.1992C70.2344 32.3828 67.2656 32.3633 65.4492 34.1992L43.7695 55.8789L34.5898 46.6992C32.7539 44.8633 29.7852 44.8633 27.9688 46.6992C26.1523 48.5352 26.1328 51.5039 27.9688 53.3203L40.4688 65.8203C42.3047 67.6562 45.2734 67.6562 47.0898 65.8203L72.0703 40.8203Z" fill="#9E9EA6"/>
20+
</g>
21+
<defs>
22+
<clipPath id="clip0_1077_2951">
23+
<rect width="100" height="100" fill="white"/>
24+
</clipPath>
25+
</defs>
26+
</svg>
27+
<span class="main-header">Email verified!</span>
28+
<button routerLink="/" class="info-book-btn">Continue</button>
1629
<hr class="down-hr">
1730
<span class="copyright">Copyright © 2024–2025 Orbistay.com™. All rights reserved.</span>
1831
</div>

src/app/verify-mail-page/verify-mail-page.component.ts

Lines changed: 32 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { Component } from '@angular/core';
22
import {HttpClient, HttpHeaders} from '@angular/common/http';
33
import {TokenService} from '../token.service';
44
import {ApiUrls} from '../api-urls';
5+
import {interval, Subscription} from 'rxjs';
6+
import {ActivatedRoute} from '@angular/router';
57

68
@Component({
79
selector: 'app-verify-mail-page',
@@ -12,70 +14,46 @@ import {ApiUrls} from '../api-urls';
1214
})
1315
export class VerifyMailPageComponent {
1416
isCodeSend = false;
15-
currentUser: any;
16-
code: string[] = new Array(6).fill('');
17-
correctCode: string = "F9KN4A";
18-
isError: boolean = false;
19-
17+
isButtonDisabled = false;
18+
email: string = "";
19+
timer = 60;
20+
isTokenPresent: boolean = false;
21+
private timerSubscription: Subscription | null = null;
2022

2123
constructor(private http : HttpClient,
22-
private tokenService: TokenService) {
24+
private tokenService: TokenService,
25+
private route: ActivatedRoute) {
2326
}
2427

2528
ngOnInit(): void {
26-
const storedUser = localStorage.getItem('userData');
27-
console.log("Stored user", storedUser);
28-
if (storedUser) {
29-
this.currentUser = JSON.parse(storedUser);
30-
}
31-
}
32-
33-
sendCodeToMail() {
34-
const token = this.currentUser.emailVerification.token;
35-
36-
const url = `${ApiUrls.POST_VERIFY_EMAIL_URL}?token=${token}`;
37-
38-
this.isCodeSend = true;
39-
40-
this.http.post(url, {}, { withCredentials: true }).subscribe(
41-
(response) => {
42-
console.log(response);
43-
},
44-
(error) => {
45-
console.error("Error sending code:", error);
29+
this.route.queryParams.subscribe(params => {
30+
if (params['token']) {
31+
this.isTokenPresent = true;
32+
console.log('Token найден:', params['token']);
4633
}
47-
);
48-
}
49-
50-
51-
moveToNext(event: any, index: number) {
52-
const inputs = document.querySelectorAll<HTMLInputElement>('.code-input');
53-
const inputValue = event.target.value;
54-
55-
if (inputValue.length === 1 && index < inputs.length - 1) {
56-
inputs[index + 1].focus();
57-
}
58-
59-
if (event.inputType === 'deleteContentBackward' && index > 0) {
60-
inputs[index - 1].focus();
61-
}
34+
});
6235
}
6336

64-
validateCode() {
65-
const enteredCode = this.getEnteredCode();
66-
console.log("Введённый код:", enteredCode);
67-
68-
if (enteredCode !== this.correctCode) {
69-
this.isError = true;
70-
console.log("Код неверный!");
37+
sendCodeToMail() {
38+
if (this.validateEmail(this.email)) {
39+
this.isCodeSend = true;
40+
this.isButtonDisabled = true;
41+
this.timer = 60;
42+
43+
this.timerSubscription = interval(1000).subscribe(() => {
44+
if (this.timer > 0) {
45+
this.timer--;
46+
} else {
47+
this.isButtonDisabled = false;
48+
this.timerSubscription?.unsubscribe();
49+
}
50+
});
7151
} else {
72-
this.isError = false;
73-
console.log("Код правильный!");
52+
alert("Enter a valid email address");
7453
}
7554
}
76-
77-
getEnteredCode(): string {
78-
const inputs = document.querySelectorAll<HTMLInputElement>('.code-input');
79-
return Array.from(inputs).map(input => input.value).join('');
55+
validateEmail(email: string): boolean {
56+
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
57+
return emailPattern.test(email);
8058
}
8159
}

0 commit comments

Comments
 (0)