Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( submit === true ) {
- const promise = new Promise<any>( ( resolve, reject ) => {
- let temp: tableType = []
- table.forEach( tab => {
- priority.enq( {
- branchCode: tab.branchCode,
- actual: tab.govtSeatsActual,
- expected: tab.govtSeats,
- intake: tab.sanctionedIntake
- } )
- } )
- while ( priority.size() > 0 ) {
- let branch = priority.deq()
- axios.get( `/api/portals/${ branch.branchCode }` ).then( ( resp ) => {
- resp.data.forEach( ( dat: any, i: number ) => {
- let { available, total } = userObject.minorityStatus === 'Minority' ? dat.minority : dat.nonMinority
- console.log( Math.round( totaller( 'sanctionedIntake' ) * userObject.percent / 100 ), totaller( 'govtSeats' ) )
- let bool1 = Math.round( totaller( 'sanctionedIntake' ) * userObject.percent / 100 ) != totaller( 'govtSeats' )
- table.forEach( ( tab, j ) => {
- if ( tab.branchCode == dat.branchCode ) {
- let bool2 = Math.round( ( total + parseInt( tab.sanctionedIntake! ) ) * userObject.percent / 100 ) === available + parseInt(tab.govtSeats as unknown as string)
- console.log( Math.round( ( total + parseInt( tab.sanctionedIntake! ) ) * userObject.percent / 100 ), available + parseInt(tab.govtSeats as unknown as string) )
- if ( bool1 && bool2 ) {
- tab.govtSeats!--
- tab.managementSeats!++
- tab.totalSeats = parseInt( tab.govtSeats! as unknown as string ) + parseInt( tab.surrenderedSeats! as unknown as string )
- }
- console.log( table )
- }
- temp.push(tab)
- } )
- } )
- } )
- }
- if ( table.length == temp.length ) {
- console.log(temp)
- resolve(temp)
- }
- else {
- reject('no')
- }
- } )
- promise.then( (object) => {
- setLoading( true )
- console.log(object) // 'no'
- axios.post( `/api/seats/post`,
- object
- ).then( resp => {
- console.log( resp )
- setLoading( false )
- toast.success( "Seats Saved Successfully", { theme: "colored" } )
- } )
- }, (err) => console.log(err))
- // table.forEach( tab => {
- // let community = userObject.minorityStatus === 'Minority' ? 'minority' : 'nonMinority'
- // axios.post( `/api/portals/${ tab.branchCode }/${ community }`, {
- // available: tab.govtSeats,
- // total: parseInt( tab.sanctionedIntake as unknown as string )
- // } )
- // } )
- return
- }
Add Comment
Please, Sign In to add comment