diff --git a/forms/ProductLink.js b/forms/ProductLink.js index 8f033b7..624446b 100644 --- a/forms/ProductLink.js +++ b/forms/ProductLink.js @@ -53,7 +53,6 @@ const initialValues = { user: '', applyCredits: false, category: '', - sub_category_id: '', coupon: '' } @@ -116,7 +115,6 @@ class ProductLinkForm extends React.Component { this.props.handleUserChange(e, value) setFieldValue("user", value) setFieldValue("category", '') - setFieldValue("sub_category_id", '') setFieldValue("coupon", '') }} getOptionLabel={(option) => { @@ -245,7 +243,6 @@ class ProductLinkForm extends React.Component { this.props.handleProductChange(e, value) setFieldValue("product", value) setFieldValue("category", '') - setFieldValue("sub_category_id", '') setFieldValue("coupon", '') }} value={values.product} @@ -307,8 +304,6 @@ class ProductLinkForm extends React.Component { onChange={(e) => { this.props.handleCategoryChange(e) setFieldValue("category", e.target.value) - setFieldValue("sub_category_id", '') - }} disabled={!this.props.product || !this.props.user} > @@ -321,43 +316,9 @@ class ProductLinkForm extends React.Component { - - - Coupon sub category - - - - - - - ({ backdrop: { zIndex: theme.zIndex.drawer + 1, color: '#fff', - }, - title: { - // minWidth: 650, - }, + } }); class GenerateLink extends React.Component { @@ -56,7 +52,6 @@ class GenerateLink extends React.Component { purchasedProductIframeurl: '', calculatedAmountDetails: '', loading: false, - subCategories: [], coupons: [] } } @@ -158,7 +153,6 @@ class GenerateLink extends React.Component { handleProductChange = async (event, value) => { this.setState({ product: value, - subCategories: [], coupons: [] }) @@ -200,7 +194,6 @@ class GenerateLink extends React.Component { activeCartIframeUrl: '', purchasedProductIframeurl: '', loading: false, - subCategories: [], coupons: [], }) } else { @@ -212,7 +205,6 @@ class GenerateLink extends React.Component { activeCartIframeUrl: activeCartDetails.data.iframeUrl, purchasedProductIframeurl: purchasedProductDetails.data.iframeUrl, loading: true, - subCategories: [], coupons: [], }) }).catch((error) => { @@ -230,27 +222,20 @@ class GenerateLink extends React.Component { this.unsetGeneratedLink() } - - fillSubCategories = (data) => { - couponController.fetchSubCategories(data).then((subCategories) => { + handleCategoryChange = (event) => { + + if (!event.target.value) { this.setState({ - subCategories: subCategories.data + coupons: [] }) - }).catch((error) => { - ErrorHandler.handle(error) - }) - }; - - handleCategoryChange = (event) => { - this.fillSubCategories({category: event.target.value}) - } + return + } - handleSubCategoryChange = (category, subCategoryId) => { couponController.fetchCouponsApplicableForAUserAndProduct({ user_id: this.state.user.id, product_id: this.state.product.id, - category: category, - sub_category_id: subCategoryId + category: event.target.value, + organization_id: this.state.organizationId }).then((response) => { this.setState({ coupons: response.data @@ -309,11 +294,8 @@ class GenerateLink extends React.Component { render() { const { classes } = this.props; - return (
- - @@ -336,7 +318,6 @@ class GenerateLink extends React.Component { onApplyCreditsChange={this.onApplyCreditsChange} ongenerateLink={this.ongenerateLink} handleCategoryChange={this.handleCategoryChange} - handleSubCategoryChange={this.handleSubCategoryChange} />