File tree Expand file tree Collapse file tree 3 files changed +48
-8
lines changed
Expand file tree Collapse file tree 3 files changed +48
-8
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import {axios} from "../DukaanAPI";
22import ErrorHandler from "../helpers/ErrorHandler" ;
33import organizationController from './organizations' ;
44import userController from './users' ;
5-
5+ import resourcesController from "./resources" ;
66
77const querystring = require ( 'querystring' ) ;
88
@@ -126,7 +126,10 @@ const fetchOrganizations = () => {
126126}
127127
128128const fetchGenerateLinkData = ( ) => {
129- return fetchOrganizations ( )
129+ return Promise . all ( [
130+ fetchOrganizations ( ) ,
131+ resourcesController . getStates ( )
132+ ] )
130133}
131134
132135const fetchCenters = ( organizationId ) => {
Original file line number Diff line number Diff line change @@ -53,7 +53,8 @@ const initialValues = {
5353 user : '' ,
5454 applyCredits : false ,
5555 category : '' ,
56- coupon : ''
56+ coupon : '' ,
57+ state : ''
5758}
5859
5960class ProductLinkForm extends React . Component {
@@ -75,7 +76,11 @@ class ProductLinkForm extends React.Component {
7576 if ( fields . coupon )
7677 couponQueryParams = `&coupon=${ fields . coupon . code } `
7778
78- const link = `https://dukaan.codingblocks.com/buy?productId=${ productId } &oneauthId=${ oneauthId } ${ useCreditsQueryParams } ${ couponQueryParams } `
79+ let stateQueryParams = ''
80+ if ( fields . state )
81+ stateQueryParams = `&state=${ fields . state } `
82+
83+ const link = `https://dukaan.codingblocks.com/buy?productId=${ productId } &oneauthId=${ oneauthId } ${ useCreditsQueryParams } ${ couponQueryParams } ${ stateQueryParams } `
7984
8085 this . props . ongenerateLink ( link )
8186 }
@@ -362,6 +367,36 @@ class ProductLinkForm extends React.Component {
362367 </ FormControl >
363368
364369
370+ < FormControl variant = "outlined" size = { "medium" }
371+ fullWidth = { true } className = { "mb-4" } >
372+ < InputLabel id = "state" > State</ InputLabel >
373+
374+ < Select
375+ value = { values . state }
376+ name = { "state" }
377+ onChange = { ( e ) => {
378+ this . props . unsetGeneratedLink ( )
379+ setFieldValue ( "state" , e . target . value )
380+ } }
381+ label = "State" >
382+
383+ < MenuItem value = "" >
384+ < em > Select</ em >
385+ </ MenuItem >
386+ {
387+ this . props . addressStates . map ( ( state ) => {
388+ return (
389+ < MenuItem
390+ key = { state . id }
391+ value = { state . state_code } > {
392+ state . name
393+ } </ MenuItem >
394+ )
395+ } )
396+ }
397+
398+ </ Select >
399+ </ FormControl >
365400
366401 < FormControlLabel
367402 className = { "mb-4" }
Original file line number Diff line number Diff line change @@ -49,16 +49,17 @@ class GenerateLink extends React.Component {
4949 calculatedAmountDetails : '' ,
5050 loading : false ,
5151 coupons : [ ] ,
52- coupon : ''
52+ coupon : '' ,
53+ addressStates : [ ]
5354 }
5455 }
5556
5657 componentDidMount ( ) {
57- controller . fetchGenerateLinkData ( {
58- user_id : this . state . user_id
59- } ) . then ( ( organizations ) => {
58+ controller . fetchGenerateLinkData ( )
59+ . then ( ( [ organizations , states ] ) => {
6060 this . setState ( {
6161 organizations : organizations . data ,
62+ addressStates : states . data
6263 } )
6364 } ) . catch ( error => {
6465 ErrorHandler . handle ( error )
@@ -374,6 +375,7 @@ class GenerateLink extends React.Component {
374375 handleCouponChange = { this . handleCouponChange }
375376 onCustomCouponClick = { this . onCustomCouponClick }
376377 ref = { this . buyLinkForm }
378+ unsetGeneratedLink = { this . unsetGeneratedLink }
377379 />
378380 </ div >
379381
You can’t perform that action at this time.
0 commit comments