Skip to content

Commit 0940ece

Browse files
authored
Merge pull request #24 from SwapnilTechVariable/bug/confirmation-password
showing message for role already present
2 parents dd93d9f + 8029f28 commit 0940ece

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/components/permissionPage/add-role/add-role.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@ export class AddRole {
2626
roleName: this.value,
2727
});
2828
await this.refresh();
29-
3029
Swal.fire({
3130
position: 'center',
3231
icon: 'success',
3332
text: 'Added new role!',
3433
showConfirmButton: false,
3534
timer: 1500,
3635
});
37-
3836
this.value = '';
3937
this.toggleModalState();
4038
} catch (error) {
4139
Swal.fire({
4240
icon: 'error',
4341
title: 'Oops...',
44-
text: 'Something went wrong!',
42+
text: error?.response?.data || "Failed to create a new role",
4543
});
4644
}
4745
}

src/components/profilePage/profile-component/profile-component.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class ProfileComponent {
1212
@Prop() url : string;
1313
@State() user: any;
1414
@State() password : string= "";
15+
@State() repassword : string= "";
1516
@State() name : string = "";
1617
@State() error:any = null;
1718

@@ -26,12 +27,16 @@ export class ProfileComponent {
2627
if(this.name === ""){
2728
this.error = "User name is empty"
2829
}
29-
if(this.password.length < 7){
30+
else if(this.password.length < 7){
3031
this.error = "Password length is less than 7 characters"
3132
}
3233
else if(!this.password.match(/([!,%,&,@,#,$,^,*,?,_,~])/)){
3334
this.error = "Password does not contain any special character"
34-
}else{
35+
}
36+
else if(this.password !== this.repassword){
37+
this.error = "Password does not match with re-entered password"
38+
}
39+
else{
3540
try {
3641
await axios
3742
.put(`${this.url}api/users/password`, {
@@ -63,6 +68,9 @@ export class ProfileComponent {
6368
passwordHandler(e){
6469
this.password = e.target.value;
6570
}
71+
repasswordHandler(e){
72+
this.repassword = e.target.value;
73+
}
6674
nameChangeHandler(e){
6775
this.name = e.target.value;
6876
}
@@ -112,6 +120,20 @@ export class ProfileComponent {
112120
<p class="text-gray-600 text-xs italic">Enter updated password</p>
113121
</div>
114122
</div>
123+
<div class="flex flex-wrap -mx-3 mb-6">
124+
<div class="w-full px-3">
125+
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">Re-enter Password</label>
126+
<input
127+
onInput={e=>this.repasswordHandler(e)}
128+
class="appearance-none block w-full bg-white text-gray-700 border border-gray-200 rounded py-3 px-4 mb-3 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
129+
id="grid-password"
130+
type="password"
131+
placeholder="******************"
132+
value={this.repassword}
133+
/>
134+
<p class="text-gray-600 text-xs italic">Re-enter the password</p>
135+
</div>
136+
</div>
115137
<div class="flex flex-row-reverse -mx-3 mb-6 ">
116138
<button class="border-2 border-gray-800 w-32 py-4 px-6 mx-4 font-medium text-lg text-white bg-gray-500 rounded-lg hover:bg-gray-400">Update</button>
117139
{this.error?<p class="rounded-lg mx-4 my-2 px-3 py-2 bg-red-200 text-red-800 border-l-4 border-red-600 w-full">{this.error}</p>:null}

0 commit comments

Comments
 (0)