@@ -22,6 +22,7 @@ export default class PasswordResetDemandForm extends Component {
22
22
);
23
23
@tracked emailInputvalidationStatus;
24
24
@tracked emailInputvalidationErrorMessage;
25
+ @tracked isPasswordResetDemandReceived = false ;
25
26
26
27
email;
27
28
@@ -55,11 +56,11 @@ export default class PasswordResetDemandForm extends Component {
55
56
method: ' POST' ,
56
57
body: JSON .stringify ({ email }),
57
58
});
58
- if (response .status == 404 ) {
59
- this .errorMessage = this .intl .t (' components.authentication.password-reset-demand-form.404-message' );
60
- } else if (! response .ok ) {
59
+ if (! response .ok && response .status != 404 ) {
61
60
throw new Error (` Response status: ${ response .status } ` );
62
61
}
62
+
63
+ this .isPasswordResetDemandReceived = true ;
63
64
} catch (error) {
64
65
this .errorMessage = this .intl .t (' common.api-error-messages.internal-server-error' );
65
66
} finally {
@@ -68,55 +69,82 @@ export default class PasswordResetDemandForm extends Component {
68
69
}
69
70
70
71
<template >
71
- <form {{on " submit" this . handlePasswordResetDemand}} class =" authentication-password-reset-demand-form" >
72
- <p class =" authentication-password-reset-demand-form__rule" >
73
- {{t " components.authentication.password-reset-demand-form.rule" }}
74
- </p >
72
+ {{#if this . isPasswordResetDemandReceived }}
73
+ <PasswordResetDemandReceivedInfo />
74
+ {{else }}
75
+ <form {{on " submit" this . handlePasswordResetDemand}} class =" authentication-password-reset-demand-form" >
76
+ <p class =" authentication-password-reset-demand-form__rule" >
77
+ {{t " components.authentication.password-reset-demand-form.rule" }}
78
+ </p >
75
79
76
- {{#if this . errorMessage }}
77
- <PixMessage
78
- @ type =" error"
79
- @ withIcon ={{ true }}
80
- class =" authentication-password-reset-demand-form__error"
81
- role =" alert"
82
- >
83
- {{this .errorMessage }}
84
- </PixMessage >
85
- {{/if }}
86
- <div class =" authentication-password-reset-demand-form__input-block" >
87
- <PixInput
88
- @ value ={{this .email }}
89
- type =" email"
90
- {{on " change" this . handleEmailChange}}
91
- @ validationStatus ={{this .emailInputvalidationStatus }}
92
- @ errorMessage ={{this .emailInputvalidationErrorMessage }}
93
- placeholder ={{this .emailInputPlaceholder }}
94
- required ={{ true }}
95
- >
96
- <: label >{{t " components.authentication.password-reset-demand-form.fields.email.label" }} </: label >
97
- </PixInput >
98
- </div >
99
- <div >
100
- <PixButton
101
- @ type =" submit"
102
- @ size =" large"
103
- @ isLoading ={{this .isLoading }}
104
- class =" authentication-password-reset-demand-form__button"
105
- >
106
- {{t " components.authentication.password-reset-demand-form.actions.receive-reset-button" }}
107
- </PixButton >
108
- </div >
109
- <p class =" authentication-password-reset-demand-form__help" >
110
- {{t " components.authentication.password-reset-demand-form.no-email-question" }}
111
- <PixButtonLink
112
- @ variant =" tertiary"
113
- @ href =" {{t ' components.authentication.password-reset-demand-form.contact-us-link.link-url' }} "
114
- target =" _blank"
115
- class =" authentication-password-reset-demand-form__help-contact-us-link"
116
- >
117
- {{t " components.authentication.password-reset-demand-form.contact-us-link.link-text" }}
118
- </PixButtonLink >
119
- </p >
120
- </form >
80
+ {{#if this . errorMessage }}
81
+ <PixMessage
82
+ @ type =" error"
83
+ @ withIcon ={{ true }}
84
+ class =" authentication-password-reset-demand-form__error"
85
+ role =" alert"
86
+ >
87
+ {{this .errorMessage }}
88
+ </PixMessage >
89
+ {{/if }}
90
+ <div class =" authentication-password-reset-demand-form__input-block" >
91
+ <PixInput
92
+ @ value ={{this .email }}
93
+ type =" email"
94
+ {{on " change" this . handleEmailChange}}
95
+ @ validationStatus ={{this .emailInputvalidationStatus }}
96
+ @ errorMessage ={{this .emailInputvalidationErrorMessage }}
97
+ placeholder ={{this .emailInputPlaceholder }}
98
+ required ={{ true }}
99
+ >
100
+ <: label >{{t " components.authentication.password-reset-demand-form.fields.email.label" }} </: label >
101
+ </PixInput >
102
+ </div >
103
+ <div >
104
+ <PixButton
105
+ @ type =" submit"
106
+ @ size =" large"
107
+ @ isLoading ={{this .isLoading }}
108
+ class =" authentication-password-reset-demand-form__button"
109
+ >
110
+ {{t " components.authentication.password-reset-demand-form.actions.receive-reset-button" }}
111
+ </PixButton >
112
+ </div >
113
+ <p class =" authentication-password-reset-demand-form__help" >
114
+ {{t " components.authentication.password-reset-demand-form.no-email-question" }}
115
+ <PixButtonLink
116
+ @ variant =" tertiary"
117
+ @ href =" {{t ' components.authentication.password-reset-demand-form.contact-us-link.link-url' }} "
118
+ target =" _blank"
119
+ class =" authentication-password-reset-demand-form__help-contact-us-link"
120
+ >
121
+ {{t " components.authentication.password-reset-demand-form.contact-us-link.link-text" }}
122
+ </PixButtonLink >
123
+ </p >
124
+ </form >
125
+ {{/if }}
121
126
</template >
122
127
}
128
+
129
+ const PasswordResetDemandReceivedInfo = <template >
130
+ <div class =" authentication-password-reset-demand-received-info" >
131
+ <img src =" /images/mail.svg" alt =" " />
132
+ <h2 class =" authentication-password-reset-demand-received-info__heading" >
133
+ {{t " components.authentication.password-reset-demand-received-info.heading" }}
134
+ </h2 >
135
+ <p class =" authentication-password-reset-demand-received-info__message" >
136
+ {{t " components.authentication.password-reset-demand-received-info.message" }}
137
+ </p >
138
+ <p class =" authentication-password-reset-demand-received-info__help" >
139
+ {{t " components.authentication.password-reset-demand-received-info.no-email-received-question" }}
140
+ <PixButtonLink
141
+ @ variant =" tertiary"
142
+ @ route =" password-reset-demand"
143
+ target =" _blank"
144
+ class =" authentication-password-reset-demand-form__help-contact-us-link"
145
+ >
146
+ {{t " components.authentication.password-reset-demand-received-info.try-again" }}
147
+ </PixButtonLink >
148
+ </p >
149
+ </div >
150
+ </template >;
0 commit comments