Skip to content

Commit 4bd0493

Browse files
committed
add infos for registered and failed
1 parent 463006d commit 4bd0493

File tree

5 files changed

+39
-16
lines changed

5 files changed

+39
-16
lines changed

public/css/css/output.css

+4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ a {
101101
margin: 0 auto;
102102
display: flex;
103103
align-items: center; }
104+
@media only screen and (max-width: 768px) {
105+
.topbar__container {
106+
width: 100%;
107+
padding: 0 1rem; } }
104108
.topbar__buttons {
105109
display: flex;
106110
flex: 1;

public/css/scss/components/_topbar.scss

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
margin: 0 auto;
1010
display: flex;
1111
align-items: center;
12+
13+
@media only screen and (max-width: 768px) {
14+
width: 100%;
15+
padding: 0 1rem;
16+
}
1217
}
1318

1419
&__buttons {
+15-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
<div aria-label="dialog" class="modal__container">
22
<div class="modal__header">
3-
<h3 class="heading-tertiary">Zarejestruj</h3>
3+
<h3 class="heading-tertiary">Register</h3>
44
</div>
55
<div class="modal__body">
6-
<form id="registerForm" data-ng-submit="register()">
6+
<form id="registerForm" data-ng-submit="register()" data-ng-if="!success">
77
<div class="form-group">
88
<label for="email">E-Mail:</label>
9-
<input type="email" placeholder="[email protected]" class="form-control" id="email" data-ng-model="email">
9+
<input type="email" placeholder="[email protected]" class="form-control" id="email" data-ng-model="$parent.email">
1010
</div>
1111
<div class="form-group">
12-
<label for="password">Hasło:</label>
13-
<input type="password" placeholder="******" class="form-control" id="password" data-ng-model="password">
12+
<label for="password">Password:</label>
13+
<input type="password" placeholder="******" class="form-control" id="password" data-ng-model="$parent.password">
1414
</div>
1515
<div class="form-group">
16-
<label for="password_confirm">Potwierdź hasło:</label>
17-
<input type="password" placeholder="******" class="form-control" id="password_confirm" data-ng-model="passwordConf">
16+
<label for="password_confirm">Repeat password:</label>
17+
<input type="password" placeholder="******" class="form-control" id="password_confirm" data-ng-model="$parent.passwordConf">
1818
</div>
19+
<p data-ng-if="$parent.errorConflict">Email already exists in our database. Go to login modal and recover your account.</p>
20+
<p data-ng-if="$parent.errorPass">Email must contain "@" and password must contain at least 6 signs.</p>
1921
</form>
22+
<div data-ng-if="success">
23+
<p class="success">Successfully registered.</p>
24+
<p class="help-block">Go to your email account to activate account.</p>
25+
</div>
2026
</div>
2127
<div class="modal__footer">
22-
<button type="submit" class="button" form="registerForm">Zarejestruj</button>
23-
<button type="button" class="button" data-ng-click="hideModal()">Zamknij</button>
28+
<button type="submit" class="button" form="registerForm">Register</button>
29+
<button type="button" class="button" data-ng-click="hideModal()">Close</button>
2430
</div>
2531
</div>

public/js/directives/modalRegister.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,25 @@
1515
$scope.email = '';
1616
$scope.password = '';
1717
$scope.passwordConf = '';
18+
$scope.success = false;
19+
$scope.errorPass = false;
20+
$scope.errorConflict = false;
21+
1822
$scope.hideModal = () => stateService.set('modalRegister', false);
1923
$scope.register = async () => {
2024
if($scope.password !== $scope.passwordConf) {
2125
alert('Passwords are not equal!')
2226
} else {
23-
const params = {
24-
email: $scope.email,
25-
password: $scope.password
26-
};
27+
const params = { email: $scope.email, password: $scope.password };
2728
const response = await registerService.register(params);
28-
console.log(response);
29+
if(response && response.status === 201) {
30+
$scope.success = true;
31+
} else if(response && response.status === 409) {
32+
$scope.errorConflict = true;
33+
} else {
34+
$scope.errorPass = true;
35+
}
36+
$scope.$apply();
2937
}
3038
}
3139
}

public/js/services/registerService.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
method: 'POST',
1616
data: params
1717
})
18-
.then(response => { return response.data })
19-
.catch(err => { console.log(err) })
18+
.then(response => { return response })
19+
.catch(err => { return err })
2020
};
2121
}
2222
})();

0 commit comments

Comments
 (0)