Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions forms/ProductLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const initialValues = {
user: '',
applyCredits: false,
category: '',
sub_category_id: '',
coupon: ''
}

Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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}
>
Expand All @@ -321,43 +316,9 @@ class ProductLinkForm extends React.Component {
</Select>
</FormControl>


<FormControl variant="outlined" size={"medium"}
fullWidth={true} className={"mb-4"}>
<InputLabel id="sub_category_id">Coupon sub category</InputLabel>

<Select
value={values.sub_category_id}
name={"Sub Category"}
label="Coupon sub category"
onChange={(e) => {
this.props.handleSubCategoryChange(values.category, e.target.value)
setFieldValue("sub_category_id", e.target.value)
}}>

<MenuItem value="">
<em>Select</em>
</MenuItem>

{
this.props.subCategories.map((subCategory) => {
return (
<MenuItem key={subCategory.id}
value={subCategory.id}>
{subCategory.name}
</MenuItem>
)
})
}
</Select>
</FormControl>


<FormControl variant="outlined" size={"medium"}
fullWidth={true} className={"mb-4"}>



<Autocomplete
autoComplete={true}
fullWidth={true}
Expand Down
37 changes: 9 additions & 28 deletions pages/admin/products/generateLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,11 @@ import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Typography from '@material-ui/core/Typography';


const useStyles = theme => ({
backdrop: {
zIndex: theme.zIndex.drawer + 1,
color: '#fff',
},
title: {
// minWidth: 650,
},
}
});

class GenerateLink extends React.Component {
Expand All @@ -56,7 +52,6 @@ class GenerateLink extends React.Component {
purchasedProductIframeurl: '',
calculatedAmountDetails: '',
loading: false,
subCategories: [],
coupons: []
}
}
Expand Down Expand Up @@ -158,7 +153,6 @@ class GenerateLink extends React.Component {
handleProductChange = async (event, value) => {
this.setState({
product: value,
subCategories: [],
coupons: []
})

Expand Down Expand Up @@ -200,7 +194,6 @@ class GenerateLink extends React.Component {
activeCartIframeUrl: '',
purchasedProductIframeurl: '',
loading: false,
subCategories: [],
coupons: [],
})
} else {
Expand All @@ -212,7 +205,6 @@ class GenerateLink extends React.Component {
activeCartIframeUrl: activeCartDetails.data.iframeUrl,
purchasedProductIframeurl: purchasedProductDetails.data.iframeUrl,
loading: true,
subCategories: [],
coupons: [],
})
}).catch((error) => {
Expand All @@ -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
Expand Down Expand Up @@ -309,11 +294,8 @@ class GenerateLink extends React.Component {

render() {
const { classes } = this.props;

return (
<div>


<Head title="Coding Blocks | Dukaan | Generate Product Link"/>
<Layout/>
<CheckLogin>
Expand All @@ -336,7 +318,6 @@ class GenerateLink extends React.Component {
onApplyCreditsChange={this.onApplyCreditsChange}
ongenerateLink={this.ongenerateLink}
handleCategoryChange={this.handleCategoryChange}
handleSubCategoryChange={this.handleSubCategoryChange}
/>
</div>

Expand Down