@@ -102,6 +102,32 @@ export default function StudentPay({ actions, settings }) {
102
102
return < Spin /> ;
103
103
}
104
104
105
+ const buttons = showStudentPay ? (
106
+ < Space style = { { margin : "10px 0" , float : "right" } } >
107
+ < Button
108
+ onClick = { ( ) => {
109
+ setShowStudentPay ( false ) ;
110
+ reset ( ) ;
111
+ } }
112
+ >
113
+ Cancel
114
+ </ Button >
115
+ < Button
116
+ disabled = {
117
+ isEqual ( info , settings . get ( "payInfo" ) ?. toJS ( ) ) &&
118
+ when . isSame ( dayjs ( settings . get ( "pay" ) ) )
119
+ }
120
+ type = "primary"
121
+ onClick = { ( ) => {
122
+ actions . configuration . setStudentPay ( { info, when, cost } ) ;
123
+ setShowStudentPay ( false ) ;
124
+ } }
125
+ >
126
+ Save Changes
127
+ </ Button >
128
+ </ Space >
129
+ ) : undefined ;
130
+
105
131
return (
106
132
< Card
107
133
style = { ! paySelected ? { background : "#fcf8e3" } : undefined }
@@ -135,6 +161,7 @@ export default function StudentPay({ actions, settings }) {
135
161
</ Checkbox >
136
162
{ settings ?. get ( "student_pay" ) && (
137
163
< div >
164
+ { buttons }
138
165
< Space style = { { margin : "10px 0" } } >
139
166
< Button
140
167
disabled = { showStudentPay }
@@ -144,31 +171,6 @@ export default function StudentPay({ actions, settings }) {
144
171
>
145
172
< Icon name = "credit-card" /> Start and end dates and upgrades...
146
173
</ Button >
147
- { showStudentPay && (
148
- < >
149
- < Button
150
- onClick = { ( ) => {
151
- setShowStudentPay ( false ) ;
152
- reset ( ) ;
153
- } }
154
- >
155
- Cancel
156
- </ Button >
157
- < Button
158
- disabled = {
159
- isEqual ( info , settings . get ( "payInfo" ) ?. toJS ( ) ) &&
160
- when . isSame ( dayjs ( settings . get ( "pay" ) ) )
161
- }
162
- type = "primary"
163
- onClick = { ( ) => {
164
- actions . configuration . setStudentPay ( { info, when, cost } ) ;
165
- setShowStudentPay ( false ) ;
166
- } }
167
- >
168
- Save Changes
169
- </ Button >
170
- </ >
171
- ) }
172
174
</ Space >
173
175
< div >
174
176
{ showStudentPay && (
@@ -214,8 +216,10 @@ export default function StudentPay({ actions, settings }) {
214
216
setWhen = { setWhen }
215
217
cost = { cost }
216
218
minPayment = { minPayment }
219
+ info = { info }
217
220
/>
218
221
) }
222
+ { buttons }
219
223
</ div >
220
224
}
221
225
/>
@@ -252,15 +256,19 @@ function StudentPayCheckboxLabel({ settings, when }) {
252
256
}
253
257
}
254
258
255
- function RequireStudentsPayWhen ( { when, setWhen, cost, minPayment } ) {
259
+ function RequireStudentsPayWhen ( { when, setWhen, cost, minPayment, info } ) {
260
+ const start = dayjs ( info . start ) ;
256
261
return (
257
262
< div style = { { marginBottom : "15px" } } >
258
263
< div style = { { textAlign : "center" , marginBottom : "15px" } } >
259
264
< DatePicker
260
265
changeOnBlur
261
266
showToday
262
267
allowClear = { false }
263
- disabledDate = { ( current ) => current < dayjs ( ) . subtract ( 1 , "day" ) }
268
+ disabledDate = { ( current ) =>
269
+ current < start . subtract ( 1 , "day" ) ||
270
+ current >= start . add ( 21 , "day" )
271
+ }
264
272
defaultValue = { when }
265
273
onChange = { ( date ) => {
266
274
setWhen ( date ?? dayjs ( ) ) ;
0 commit comments