@@ -58,6 +58,8 @@ export class ListItemModal extends FloatElement {
58
58
59
59
private readonly MAX_PRICE_CENTS = 100000 * 100 ; // $100,000
60
60
61
+ private readonly MIN_PRICE_CENTS = 3 ; // $0.03
62
+
61
63
private readonly SALES_FEE_PERCENTAGE = 0.02 ;
62
64
63
65
private readonly DURATION_OPTIONS = [
@@ -150,8 +152,11 @@ export class ListItemModal extends FloatElement {
150
152
}
151
153
152
154
private validatePrice ( price : number | undefined ) : { isValid : boolean ; error ?: { message : string } } {
153
- if ( ! price || isNaN ( price ) || price <= 0 ) {
154
- return { isValid : false , error : { message : 'Please enter a valid price greater than $0.00' } } ;
155
+ if ( ! price || isNaN ( price ) || price < this . MIN_PRICE_CENTS ) {
156
+ return {
157
+ isValid : false ,
158
+ error : { message : `Please enter a valid price of at least $${ ( this . MIN_PRICE_CENTS / 100 ) . toFixed ( 2 ) } ` } ,
159
+ } ;
155
160
}
156
161
157
162
if ( price > this . MAX_PRICE_CENTS ) {
@@ -209,12 +214,23 @@ export class ListItemModal extends FloatElement {
209
214
210
215
// Convert to cents for storage
211
216
const dollars = parseFloat ( value || '0' ) ;
212
- if ( dollars * 100 > this . MAX_PRICE_CENTS ) {
217
+ const cents = Math . ceil ( dollars * 100 ) ;
218
+
219
+ // Validate the price
220
+ if ( cents < this . MIN_PRICE_CENTS ) {
221
+ this . error = {
222
+ message : `Please enter a valid price of at least $${ ( this . MIN_PRICE_CENTS / 100 ) . toFixed ( 2 ) } ` ,
223
+ } ;
224
+ this . customPrice = undefined ;
225
+ } else if ( cents > this . MAX_PRICE_CENTS ) {
226
+ this . error = {
227
+ message : 'Price cannot exceed $100,000 USD' ,
228
+ } ;
213
229
input . value = ( this . MAX_PRICE_CENTS / 100 ) . toString ( ) ;
214
- this . updatePrice ( this . MAX_PRICE_CENTS ) ;
230
+ this . customPrice = this . MAX_PRICE_CENTS ;
215
231
} else {
216
- const cents = Math . ceil ( dollars * 100 ) ;
217
- this . updatePrice ( Math . max ( 1 , cents ) ) ;
232
+ this . error = undefined ;
233
+ this . customPrice = cents ;
218
234
}
219
235
}
220
236
@@ -232,7 +248,22 @@ export class ListItemModal extends FloatElement {
232
248
if ( this . recommendedPrice ) {
233
249
const exactPrice = ( value / 100 ) * this . recommendedPrice ;
234
250
const newPrice = Math . ceil ( exactPrice ) ;
235
- this . updatePrice ( newPrice ) ;
251
+
252
+ // Validate the price
253
+ if ( newPrice < this . MIN_PRICE_CENTS ) {
254
+ this . error = {
255
+ message : `Please enter a valid price of at least $${ ( this . MIN_PRICE_CENTS / 100 ) . toFixed ( 2 ) } ` ,
256
+ } ;
257
+ this . customPrice = undefined ;
258
+ } else if ( newPrice > this . MAX_PRICE_CENTS ) {
259
+ this . error = {
260
+ message : 'Price cannot exceed $100,000 USD' ,
261
+ } ;
262
+ this . customPrice = this . MAX_PRICE_CENTS ;
263
+ } else {
264
+ this . error = undefined ;
265
+ this . customPrice = newPrice ;
266
+ }
236
267
}
237
268
}
238
269
0 commit comments