@@ -14,11 +14,11 @@ export const setPostModuleData = (val) => {
1414 }
1515}
1616
17- export function postCallElectionData ( CallElectionData , electionData ) {
17+ export function postCallElectionData ( electionData ) {
1818 //TODO: config ids should get from the front end and the array should be dynamic
1919
2020 let allElectionModuleData = {
21- "moduleId" : electionData . module_id ,
21+ "moduleId" : "1268362183761283718236" ,
2222 "divisionCommonName" :'Provintial' ,
2323 "createdBy" :'admin' ,
2424 "createdAt" :'' ,
@@ -85,7 +85,7 @@ export function postCallElectionData(CallElectionData, electionData) {
8585 return function ( dispatch ) {
8686 const response = axios
8787 . post (
88- `${ API_BASE_URL } /modules/moduleData ` ,
88+ `${ API_BASE_URL } /modules` ,
8989 { ...allElectionModuleData }
9090 )
9191 . then ( response => {
@@ -94,7 +94,6 @@ export function postCallElectionData(CallElectionData, electionData) {
9494 } ) . catch ( err => {
9595 console . log ( err )
9696 } ) ;
97- // import store from '../store';
9897 }
9998}
10099
@@ -118,15 +117,97 @@ export const updateElection = function updateElection(election) {
118117 } ;
119118}
120119
121- export const saveElection = function saveElection ( ) {
120+ export const saveElection = function saveElection ( election ) {
122121
123122 return function ( dispatch ) {
123+
124124 dispatch ( {
125- type : SAVE_ELECTION_MODULE ,
125+ type : UPDATE_ELECTION_MODULE ,
126126 payload : { }
127127 } )
128128 } ;
129129}
130130
131+ export const submitElection = function saveElection ( election ) {
132+
133+ let allElectionModuleData = {
134+ "name" : election . name ,
135+ "id" : "1268362183761283718236" ,
136+ "divisionCommonName" :'Provintial' ,
137+ "createdBy" :'admin' ,
138+ "createdAt" :'' ,
139+ "updatedAt" :'' ,
140+ "candidateFormConfiguration" : [
141+ {
142+ candidateConfigId : '1' ,
143+ } ,
144+ {
145+ candidateConfigId : '2' ,
146+ } ,
147+ {
148+ candidateConfigId : '3' ,
149+ } ,
150+ {
151+ candidateConfigId : '4' ,
152+ } ,
153+ ] ,
154+ "supportingDocuments" : [
155+ {
156+ supportDocConfigId : '15990459-2ea4-413f-b1f7-29a138fd7a97' ,
157+ } ,
158+ {
159+ supportDocConfigId : 'fe2c2d7e-66de-406a-b887-1143023f8e72' ,
160+ } ,
161+ {
162+ supportDocConfigId : 'ff4c6768-bdbe-4a16-b680-5fecb6b1f747' ,
163+ }
164+ ] ,
165+ "divisionConfig" :[
166+ {
167+ divisionName : 'Sample' ,
168+ divisionCode : 'code' ,
169+ noOfCandidates : '1' ,
170+ } ,
171+ {
172+ divisionName : 'Sample3' ,
173+ divisionCode : 'code' ,
174+ noOfCandidates : '2' ,
175+ } ,
176+ {
177+ divisionName : 'Sample5' ,
178+ divisionCode : 'code' ,
179+ noOfCandidates : '3' ,
180+ }
181+ ] ,
182+ "electionConfig" : [
183+ {
184+ electionModuleConfigId : '15990459-2ea4-413f-b1f7-29a138fd7a97' ,
185+ value :'allowed' ,
186+ }
187+ ] ,
188+ }
189+
190+ return function ( dispatch ) {
191+ const response = axios
192+ . post (
193+ `${ API_BASE_URL } /election-modules` ,
194+ { ...allElectionModuleData }
195+ )
196+ . then ( response => {
197+ console . log ( "response.data" , response . data ) ;
198+ if ( response . data ) {
199+ election . submited = true ;
200+ dispatch ( {
201+ type : UPDATE_ELECTION_MODULE ,
202+ payload : election
203+ } ) ;
204+ }
205+ } ) . catch ( err => {
206+ console . log ( err )
207+ } ) ;
208+ }
209+ }
210+
211+
131212
132213//----------- End of save Create Election Data ----------------
0 commit comments