Skip to content

Commit 3de9ac3

Browse files
author
JasmeetLuthra
committed
Merge branch 'unstable' into buy_link_coupon_feature
2 parents 9544547 + fe6562c commit 3de9ac3

File tree

5 files changed

+95
-14
lines changed

5 files changed

+95
-14
lines changed

forms/BulkCoupon.js

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import FieldWithElement from '../components/FieldWithElement';
77
import * as controller from '../controllers/v2/couponsV2'
88
import Swal from 'sweetalert2';
99
import config from "../config";
10+
import Tooltip from '@material-ui/core/Tooltip';
1011

1112
const bulkCouponSchema = Yup.object().shape({
1213
authority_doc: Yup.string().min(3)
@@ -67,6 +68,9 @@ const bulkCouponSchema = Yup.object().shape({
6768
.max(Number.MAX_SAFE_INTEGER, 'entered value to large')
6869
.moreThan(Yup.ref('min_product_mrp'),
6970
"must be greater than min product mrp")
71+
.nullable().notRequired(),
72+
cashback: Yup.number()
73+
.min(1).max(100)
7074
.nullable().notRequired()
7175
});
7276

@@ -90,7 +94,8 @@ const initialValues = {
9094
valid_start: Date.now(),
9195
valid_end: new Date().setMonth(new Date().getMonth() + 1),
9296
min_product_mrp: null,
93-
max_product_mrp: null
97+
max_product_mrp: null,
98+
cashback: null
9499
}
95100

96101
class BulkCouponForm extends React.Component {
@@ -338,6 +343,8 @@ class BulkCouponForm extends React.Component {
338343
setFieldTouched("percentage", false)
339344
setFieldValue("max_discount", null)
340345
setFieldTouched("max_discount", false)
346+
setFieldValue("cashback", null)
347+
setFieldTouched("cashback", false)
341348
}}
342349
>
343350
<option value="flat">Flat</option>
@@ -373,7 +380,11 @@ class BulkCouponForm extends React.Component {
373380
placeholder="Enter Percentage"
374381
name="percentage"
375382
onBlur={handleBlur}
376-
onChange={handleChange}
383+
onChange={(e) => {
384+
handleChange(e)
385+
if (e.target.value == 100)
386+
setFieldValue("cashback" , "")
387+
}}
377388
value={values.percentage}
378389
/>
379390
</FieldWithElement>
@@ -393,6 +404,26 @@ class BulkCouponForm extends React.Component {
393404
/>
394405
</FieldWithElement>
395406

407+
<FieldWithElement
408+
name={"cashback(%)"} nameCols={3} elementCols={9}
409+
elementClassName={"pl-4"} errorColor={'tomato'}
410+
errors={touched.cashback && errors.cashback}>
411+
412+
<Tooltip title={<span className={"mui-tooltip"}>% of product price to be added as cashback</span>}
413+
placement="bottom-end">
414+
<input
415+
type="number"
416+
className={"input-text"}
417+
id={values.percentage === 100 ? "disabled-cashback" : "cashback"}
418+
placeholder="Enter cashback"
419+
name="cashback"
420+
onBlur={handleBlur}
421+
onChange={handleChange}
422+
value={values.cashback}
423+
/>
424+
</Tooltip>
425+
</FieldWithElement>
426+
396427
</div>
397428
}
398429

@@ -403,7 +434,7 @@ class BulkCouponForm extends React.Component {
403434
<input
404435
type="number"
405436
className={"input-text"}
406-
placeholder="Enter min product price"
437+
placeholder="Enter min product mrp"
407438
name="min_product_mrp"
408439
onBlur={handleBlur}
409440
onChange={handleChange}
@@ -412,20 +443,22 @@ class BulkCouponForm extends React.Component {
412443
</FieldWithElement>
413444

414445
<FieldWithElement
415-
name={"Min product Mrp"} nameCols={3} elementCols={9}
446+
name={"Max product Mrp"} nameCols={3} elementCols={9}
416447
elementClassName={"pl-4"} errorColor={'tomato'}
417448
errors={touched.max_product_mrp && errors.max_product_mrp}>
418449
<input
419450
type="number"
420451
className={"input-text"}
421-
placeholder="Enter min product price"
452+
placeholder="Enter max product mrp"
422453
name="max_product_mrp"
423454
onBlur={handleBlur}
424455
onChange={handleChange}
425456
value={values.max_product_mrp}
426457
/>
427458
</FieldWithElement>
428459

460+
461+
429462
{/* Total number of times a coupon can be used*/}
430463
<FieldWithElement name={"How many times it can be used?"} nameCols={6}
431464
elementCols={6} elementClassName={"pl-4"} errorColor={'tomato'}

forms/Coupon.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import SelectedUsers from "../components/SelectedUsers";
1111
import config from "../config";
1212
import CouponProductsNotice from '../components/CouponProductsNotice'
1313
import withReactContent from "sweetalert2-react-content";
14+
import Tooltip from '@material-ui/core/Tooltip';
1415

1516
const ReactSwal = withReactContent(Swal);
1617

@@ -62,6 +63,9 @@ const couponSchema = Yup.object().shape({
6263
.max(Number.MAX_SAFE_INTEGER, 'entered value to large')
6364
.moreThan(Yup.ref('min_product_mrp'),
6465
"must be greater than min product mrp")
66+
.nullable().notRequired(),
67+
cashback: Yup.number()
68+
.min(1).max(100)
6569
.nullable().notRequired()
6670
});
6771

@@ -82,7 +86,8 @@ const initialValues = {
8286
valid_start: Date.now(),
8387
valid_end: new Date().setMonth(new Date().getMonth() + 1),
8488
min_product_mrp: null,
85-
max_product_mrp: null
89+
max_product_mrp: null,
90+
cashback: null
8691
}
8792

8893
class CouponForm extends React.Component {
@@ -123,7 +128,8 @@ class CouponForm extends React.Component {
123128
valid_end: new Date(this.props.data.coupon.valid_end),
124129
comment: this.props.data.coupon.comment,
125130
min_product_mrp: this.props.data.coupon.min_product_mrp,
126-
max_product_mrp: this.props.data.coupon.max_product_mrp
131+
max_product_mrp: this.props.data.coupon.max_product_mrp,
132+
cashback: this.props.data.coupon.cashback
127133
}
128134
}
129135

@@ -508,6 +514,8 @@ class CouponForm extends React.Component {
508514
setFieldTouched("percentage", false)
509515
setFieldValue("max_discount", null)
510516
setFieldTouched("max_discount", false)
517+
setFieldValue("cashback", null)
518+
setFieldTouched("cashback", false)
511519
}}
512520
value={values.mode}>
513521
<option value="flat">Flat</option>
@@ -546,7 +554,11 @@ class CouponForm extends React.Component {
546554
placeholder="Enter Percentage"
547555
name="percentage"
548556
onBlur={handleBlur}
549-
onChange={handleChange}
557+
onChange={(e) => {
558+
handleChange(e)
559+
if (e.target.value == 100)
560+
setFieldValue("cashback" , '')
561+
}}
550562
value={values.percentage}
551563
/>
552564
</FieldWithElement>
@@ -565,6 +577,28 @@ class CouponForm extends React.Component {
565577
value={values.max_discount}
566578
/>
567579
</FieldWithElement>
580+
581+
<FieldWithElement
582+
name={"cashback(%)"} nameCols={3} elementCols={9}
583+
elementClassName={"pl-4"} errorColor={'tomato'}
584+
errors={touched.cashback && errors.cashback}>
585+
586+
<Tooltip title={<span className={"mui-tooltip"}>% of product price to be added as cashback</span>}
587+
placement="bottom-end">
588+
<input
589+
type="number"
590+
className={"input-text"}
591+
id={values.percentage === 100 ? "disabled-cashback" : "cashback"}
592+
placeholder="Enter cashback"
593+
name="cashback"
594+
onBlur={handleBlur}
595+
onChange={handleChange}
596+
value={values.cashback}
597+
disabled={values.percentage === 100}
598+
/>
599+
</Tooltip>
600+
</FieldWithElement>
601+
568602
</div>
569603
}
570604

@@ -575,7 +609,7 @@ class CouponForm extends React.Component {
575609
<input
576610
type="number"
577611
className={"input-text"}
578-
placeholder="Enter min product price"
612+
placeholder="Enter min product mrp"
579613
name="min_product_mrp"
580614
onBlur={handleBlur}
581615
onChange={handleChange}
@@ -590,14 +624,16 @@ class CouponForm extends React.Component {
590624
<input
591625
type="number"
592626
className={"input-text"}
593-
placeholder="Enter min product price"
627+
placeholder="Enter max product mrp"
594628
name="max_product_mrp"
595629
onBlur={handleBlur}
596630
onChange={handleChange}
597631
value={values.max_product_mrp}
598632
/>
599633
</FieldWithElement>
600634

635+
636+
601637
{/* Total number of times a coupon can be used*/}
602638
<FieldWithElement name={"How many times it can be used?*"} nameCols={6}
603639
elementCols={6} elementClassName={"pl-4"} errorColor={'tomato'}

pages/admin/coupons2/add.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,13 @@ class AddCoupons extends React.Component {
120120

121121

122122
onProductsSelected = (productTypeId, products) => {
123-
const newCouponProducts = this.state.couponProducts
124-
newCouponProducts[productTypeId] = products
123+
const currentProductsForProductTypeId = {}
124+
currentProductsForProductTypeId[productTypeId] = products
125125
this.setState({
126-
couponProducts: newCouponProducts
126+
couponProducts: {
127+
...this.state.couponProducts,
128+
...currentProductsForProductTypeId
129+
}
127130
})
128131
}
129132

@@ -165,6 +168,9 @@ class AddCoupons extends React.Component {
165168
preFilledProducts={
166169
this.state.couponProducts[this.state.modalProductTypeId]
167170
}
171+
currentCouponProducts={
172+
this.state.couponProducts[this.state.modalProductTypeId]
173+
}
168174
isModalOpen={this.state.isModalOpen}
169175
handleCloseModal={this.handleCloseModal}
170176
onProductsSelected={this.onProductsSelected}

pages/admin/coupons2/bulk.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class AddBulkCoupon extends React.Component {
172172
preFilledProducts={
173173
this.state.couponProducts[this.state.modalProductTypeId]
174174
}
175+
currentCouponProducts={
176+
this.state.couponProducts[this.state.modalProductTypeId]
177+
}
175178
isModalOpen={this.state.isModalOpen}
176179
handleCloseModal={this.handleCloseModal}
177180
onProductsSelected={this.onProductsSelected}

styles/pages/admin/coupons2.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
font-size: 13pt !important;
1111
}
1212

13-
.disabled-category, .disabled-organization, .disabled-subcategory, #disabled-code {
13+
.disabled-category, .disabled-organization, .disabled-subcategory, #disabled-code, #disabled-cashback {
1414
cursor: not-allowed;
1515
}
1616

@@ -30,3 +30,6 @@
3030
padding-top: 5px;
3131
}
3232

33+
.mui-tooltip {
34+
font-size: 10px;
35+
}

0 commit comments

Comments
 (0)