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 {
@@ -74,7 +75,11 @@ class ProductLinkForm extends React.Component {
7475 if ( fields . coupon )
7576 couponQueryParams = `&coupon=${ fields . coupon . code } `
7677
77- const link = `https://dukaan.codingblocks.com/buy?productId=${ productId } &oneauthId=${ oneauthId } ${ useCreditsQueryParams } ${ couponQueryParams } `
78+ let stateQueryParams = ''
79+ if ( fields . state )
80+ stateQueryParams = `&state=${ fields . state } `
81+
82+ const link = `https://dukaan.codingblocks.com/buy?productId=${ productId } &oneauthId=${ oneauthId } ${ useCreditsQueryParams } ${ couponQueryParams } ${ stateQueryParams } `
7883
7984 this . props . ongenerateLink ( link )
8085 }
@@ -347,6 +352,36 @@ class ProductLinkForm extends React.Component {
347352 </ FormControl >
348353
349354
355+ < FormControl variant = "outlined" size = { "medium" }
356+ fullWidth = { true } className = { "mb-4" } >
357+ < InputLabel id = "state" > State</ InputLabel >
358+
359+ < Select
360+ value = { values . state }
361+ name = { "state" }
362+ onChange = { ( e ) => {
363+ this . props . unsetGeneratedLink ( )
364+ setFieldValue ( "state" , e . target . value )
365+ } }
366+ label = "State" >
367+
368+ < MenuItem value = "" >
369+ < em > Select</ em >
370+ </ MenuItem >
371+ {
372+ this . props . addressStates . map ( ( state ) => {
373+ return (
374+ < MenuItem
375+ key = { state . id }
376+ value = { state . state_code } > {
377+ state . name
378+ } </ MenuItem >
379+ )
380+ } )
381+ }
382+
383+ </ Select >
384+ </ FormControl >
350385
351386 < FormControlLabel
352387 className = { "mb-4" }
Original file line number Diff line number Diff line change @@ -43,16 +43,17 @@ class GenerateLink extends React.Component {
4343 purchasedProductIframeurl : '' ,
4444 calculatedAmountDetails : '' ,
4545 loading : false ,
46- coupons : [ ]
46+ coupons : [ ] ,
47+ addressStates : [ ]
4748 }
4849 }
4950
5051 componentDidMount ( ) {
51- controller . fetchGenerateLinkData ( {
52- user_id : this . state . user_id
53- } ) . then ( ( organizations ) => {
52+ controller . fetchGenerateLinkData ( )
53+ . then ( ( [ organizations , states ] ) => {
5454 this . setState ( {
5555 organizations : organizations . data ,
56+ addressStates : states . data
5657 } )
5758 } ) . catch ( error => {
5859 ErrorHandler . handle ( error )
@@ -304,6 +305,7 @@ class GenerateLink extends React.Component {
304305 onApplyCreditsChange = { this . onApplyCreditsChange }
305306 ongenerateLink = { this . ongenerateLink }
306307 handleCategoryChange = { this . handleCategoryChange }
308+ unsetGeneratedLink = { this . unsetGeneratedLink }
307309 />
308310 </ div >
309311
You can’t perform that action at this time.
0 commit comments