@@ -5,6 +5,7 @@ import extractText from '../../common/utils/extractText';
5
5
import Stream from '../../common/utils/Stream' ;
6
6
import Mithril from 'mithril' ;
7
7
import RequestError from '../../common/utils/RequestError' ;
8
+ import ItemList from '../../common/utils/ItemList' ;
8
9
9
10
export interface IForgotPasswordModalAttrs extends IInternalModalAttrs {
10
11
email ?: string ;
@@ -52,38 +53,55 @@ export default class ForgotPasswordModal<CustomAttrs extends IForgotPasswordModa
52
53
) ;
53
54
}
54
55
55
- const emailLabel = extractText ( app . translator . trans ( 'core.forum.forgot_password.email_placeholder' ) ) ;
56
-
57
56
return (
58
57
< div className = "Modal-body" >
59
58
< div className = "Form Form--centered" >
60
59
< p className = "helpText" > { app . translator . trans ( 'core.forum.forgot_password.text' ) } </ p >
61
- < div className = "Form-group" >
62
- < input
63
- className = "FormControl"
64
- name = "email"
65
- type = "email"
66
- placeholder = { emailLabel }
67
- aria-label = { emailLabel }
68
- bidi = { this . email }
69
- disabled = { this . loading }
70
- />
71
- </ div >
72
- < div className = "Form-group" >
73
- { Button . component (
74
- {
75
- className : 'Button Button--primary Button--block' ,
76
- type : 'submit' ,
77
- loading : this . loading ,
78
- } ,
79
- app . translator . trans ( 'core.forum.forgot_password.submit_button' )
80
- ) }
81
- </ div >
60
+ { this . fields ( ) . toArray ( ) }
82
61
</ div >
83
62
</ div >
84
63
) ;
85
64
}
86
65
66
+ fields ( ) {
67
+ const items = new ItemList ( ) ;
68
+
69
+ const emailLabel = extractText ( app . translator . trans ( 'core.forum.forgot_password.email_placeholder' ) ) ;
70
+
71
+ items . add (
72
+ 'email' ,
73
+ < div className = "Form-group" >
74
+ < input
75
+ className = "FormControl"
76
+ name = "email"
77
+ type = "email"
78
+ placeholder = { emailLabel }
79
+ aria-label = { emailLabel }
80
+ bidi = { this . email }
81
+ disabled = { this . loading }
82
+ />
83
+ </ div > ,
84
+ 50
85
+ ) ;
86
+
87
+ items . add (
88
+ 'submit' ,
89
+ < div className = "Form-group" >
90
+ { Button . component (
91
+ {
92
+ className : 'Button Button--primary Button--block' ,
93
+ type : 'submit' ,
94
+ loading : this . loading ,
95
+ } ,
96
+ app . translator . trans ( 'core.forum.forgot_password.submit_button' )
97
+ ) }
98
+ </ div > ,
99
+ - 10
100
+ ) ;
101
+
102
+ return items ;
103
+ }
104
+
87
105
onsubmit ( e : SubmitEvent ) {
88
106
e . preventDefault ( ) ;
89
107
@@ -93,7 +111,7 @@ export default class ForgotPasswordModal<CustomAttrs extends IForgotPasswordModa
93
111
. request ( {
94
112
method : 'POST' ,
95
113
url : app . forum . attribute ( 'apiUrl' ) + '/forgot' ,
96
- body : { email : this . email ( ) } ,
114
+ body : this . requestParams ( ) ,
97
115
errorHandler : this . onerror . bind ( this ) ,
98
116
} )
99
117
. then ( ( ) => {
@@ -104,6 +122,14 @@ export default class ForgotPasswordModal<CustomAttrs extends IForgotPasswordModa
104
122
. then ( this . loaded . bind ( this ) ) ;
105
123
}
106
124
125
+ requestParams ( ) : Record < string , unknown > {
126
+ const data = {
127
+ email : this . email ( ) ,
128
+ } ;
129
+
130
+ return data ;
131
+ }
132
+
107
133
onerror ( error : RequestError ) {
108
134
if ( error . status === 404 && error . alert ) {
109
135
error . alert . content = app . translator . trans ( 'core.forum.forgot_password.not_found_message' ) ;
0 commit comments