@@ -55,16 +55,13 @@ const couponSchema = Yup.object().shape({
5555 . required ( "Field is required." ) ,
5656 active : Yup . boolean ( )
5757 . required ( "Field is required." ) ,
58- min_product_mrp : Yup . number ( ) . when ( 'mode' , {
59- is : ( val ) => val == "flat" ,
60- then : Yup . number ( )
61- . min ( 1 , 'must be greater or eqauls to 1' )
62- . typeError ( 'min product price is required' )
63- . required ( 'min product price is required.' ) ,
64- otherwise : Yup . number ( )
65- . min ( 1 , 'must be greater or eqauls to 1' )
66- . nullable ( ) . notRequired ( )
67- } ) ,
58+ min_product_mrp : Yup . number ( )
59+ . positive ( ) . nullable ( ) . notRequired ( ) ,
60+ max_product_mrp : Yup . number ( )
61+ . positive ( )
62+ . moreThan ( Yup . ref ( 'min_product_mrp' ) ,
63+ "must be greater than min product mrp" )
64+ . nullable ( ) . notRequired ( )
6865} ) ;
6966
7067const initialValues = {
@@ -83,7 +80,8 @@ const initialValues = {
8380 amount : null ,
8481 valid_start : Date . now ( ) ,
8582 valid_end : new Date ( ) . setMonth ( new Date ( ) . getMonth ( ) + 1 ) ,
86- min_product_mrp : null
83+ min_product_mrp : null ,
84+ max_product_mrp : null
8785}
8886
8987class CouponForm extends React . Component {
@@ -123,7 +121,8 @@ class CouponForm extends React.Component {
123121 valid_start : new Date ( this . props . data . coupon . valid_start ) ,
124122 valid_end : new Date ( this . props . data . coupon . valid_end ) ,
125123 comment : this . props . data . coupon . comment ,
126- min_product_mrp : this . props . data . coupon . min_product_mrp
124+ min_product_mrp : this . props . data . coupon . min_product_mrp ,
125+ max_product_mrp : this . props . data . coupon . max_product_mrp
127126 }
128127 }
129128
@@ -508,7 +507,6 @@ class CouponForm extends React.Component {
508507 setFieldTouched ( "percentage" , false )
509508 setFieldValue ( "max_discount" , null )
510509 setFieldTouched ( "max_discount" , false )
511- setFieldTouched ( "min_product_mrp" , false )
512510 } }
513511 value = { values . mode } >
514512 < option value = "flat" > Flat</ option >
@@ -584,6 +582,21 @@ class CouponForm extends React.Component {
584582 />
585583 </ FieldWithElement >
586584
585+ < FieldWithElement
586+ name = { "Max product Mrp" } nameCols = { 3 } elementCols = { 9 }
587+ elementClassName = { "pl-4" } errorColor = { 'tomato' }
588+ errors = { touched . max_product_mrp && errors . max_product_mrp } >
589+ < input
590+ type = "number"
591+ className = { "input-text" }
592+ placeholder = "Enter min product price"
593+ name = "max_product_mrp"
594+ onBlur = { handleBlur }
595+ onChange = { handleChange }
596+ value = { values . max_product_mrp }
597+ />
598+ </ FieldWithElement >
599+
587600 { /* Total number of times a coupon can be used*/ }
588601 < FieldWithElement name = { "How many times it can be used?*" } nameCols = { 6 }
589602 elementCols = { 6 } elementClassName = { "pl-4" } errorColor = { 'tomato' }
0 commit comments