{"version":3,"sources":["./src/app/pages/secure/payouts/payouts.page.html","./src/app/pages/secure/payouts/payouts-routing.module.ts","./src/app/pages/secure/payouts/payouts.page.ts","./src/app/pages/secure/payouts/payouts.module.ts"],"names":["routes","path","component","PayoutsPage","modalController","loadingController","alertController","authService","apiService","observerService","router","spinner","moment","unpaid_released_payout_balance","unpaid_unreleased_payout_balance","payouts","visible_payouts","this","presentSpinner","then","loadPayouts","showInitialVisiblePayouts","loadUnpaidPayoutTransactions","dismiss","catch","subscribe","Promise","resolve","reject","isLoggedIn","getPayouts","error","status","presentAlert","navigate","replaceUrl","window","location","reload","getConsumerTransactions","filter","transactions","i","length","released_for_merchant_payout","merchant_payout","price","event","target","complete","count","position","push","alert","create","header","message","buttons","text","handler","cssClass","releaseConsumerTransactionsForPayout","present","sub_header","subHeader","showBackdrop","refreshPayouts","PayoutsPageRoutingModule","forChild","PayoutsPageModule"],"mappings":"kUAgBgB,YAAgD,cAAG,4EAAsC,sBAAW,OAAI,Q,qEAkBpG,aACI,qBAAmE,QACvE,Q,8BADa,+BAA2B,iBAA+B,+B,kEAKvE,YACI,qBAAgE,Q,iBACpE,Q,8BADa,+BAAwB,iBAA+B,+C,8GAT5E,qBACI,sBACI,qBAGA,YACI,qBAAwE,QAA0D,qBAAiE,QACvM,OACA,oBAGJ,OACJ,Q,mCAZiD,gCAEpC,8BAIQ,+BAAgC,iBAA+B,mEAAmE,gCAAyB,iBAA+B,8DAEnM,8B,yBAbpB,yBACI,2BACI,oBAAW,2BAAgB,OAC/B,OACA,mBACI,4BAaJ,OACJ,Q,oBAdqC,2C,uCAerC,iCAA8F,iFAC1F,yCACJ,QC7CJ,MAAMA,EAAiB,CACrB,CACEC,KAAM,GACNC,UCMG,M,MAAMC,EAST,YACWC,EACAC,EACAC,EACCC,EACAC,EACAC,EACAC,GAND,KAAAN,kBACA,KAAAC,oBACA,KAAAC,kBACC,KAAAC,cACA,KAAAC,aACA,KAAAC,kBACA,KAAAC,SAdZ,KAAAC,QA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A,S,kBACJ,OACA,sBACI,qBACI,cAAI,uBAAW,OACnB,OACA,S,kBACJ,OACJ,OACA,kCAoBA,uCAGJ,Q,MAlCoB,2DAER,2EAMA,yEAGS,oEAoBK,sE,ukCElCnB,KDEA,Y,MAAMC,G,6CAAAA,I,uBAAAA,I,2BAHF,CAAC,IAAaC,SAASpE,IACtB,O,GAEL,GEIA,Q,MAAMqE,G,6CAAAA,I,uBAAAA,I,2BATF,CACP,IACA,IACA,IACA,IACA,M,GAIG","file":"70.ebc225bab961b7802554.js","sourcesContent":["<ion-header class=\"ion-no-border\">\n <ion-toolbar>\n <ion-title>\n Payouts\n </ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content>\n <ion-refresher slot=\"fixed\" pullFactor=\"0.5\" pullMin=\"100\" pullMax=\"200\" (ionRefresh)=\"refreshPayouts($event)\">\n <ion-refresher-content pullingIcon=\"refresh\" pullingText=\"Pull to refresh\" refreshingSpinner=\"crescent\" refreshingText=\"Refreshing\"></ion-refresher-content>\n </ion-refresher>\n <ion-item-group>\n <ion-item slot=\"fixed\" lines=\"full\">\n <ion-label>\n <h3>Awaiting release</h3>\n <p *ngIf=\"unpaid_unreleased_payout_balance > 0\"><a (click)=\"openReleaseForPayoutAlert()\">Release now</a></p>\n </ion-label> \n ${{unpaid_unreleased_payout_balance | number:'1.2'}}\n </ion-item> \n <ion-item slot=\"fixed\" lines=\"full\">\n <ion-label>\n <h3>Next payout</h3>\n </ion-label>\n ${{unpaid_released_payout_balance | number:'1.2'}}\n </ion-item>\n </ion-item-group>\n <ion-item-group *ngIf=\"visible_payouts && visible_payouts.length != 0\">\n <ion-item-divider>\n <ion-label>Previous payouts</ion-label>\n </ion-item-divider>\n <ion-list>\n <ion-item *ngFor=\"let payout of visible_payouts\" routerLink=\"./{{payout.id}}\" routerDirection=\"forward\" lines=\"full\">\n <ion-label class=\"ion-text-wrap\">\n <h3 *ngIf=\"payout.number\">\n <fa-icon [icon]=\"['far', 'hashtag']\" [fixedWidth]=\"true\"></fa-icon>{{payout.number}}\n </h3>\n <p>\n <fa-icon [icon]=\"['far', 'calendar-alt']\" [fixedWidth]=\"true\"></fa-icon>{{this.moment(payout.created_date).format(\"D MMM YYYY\")}} <fa-icon [icon]=\"['far', 'clock']\" [fixedWidth]=\"true\"></fa-icon>{{this.moment(payout.created_date).format(\"HH:mm\")}}\n </p>\n <p *ngIf=\"payout.price\">\n <fa-icon [icon]=\"['far', 'sack']\" [fixedWidth]=\"true\"></fa-icon>${{payout.price | number:'1.2'}}\n </p>\n </ion-label>\n </ion-item>\n </ion-list>\n </ion-item-group>\n <ion-infinite-scroll *ngIf=\"visible_payouts && visible_payouts.length != 0\" threshold=\"100px\" (ionInfinite)=\"showMoreVisiblePayouts($event)\">\n <ion-infinite-scroll-content loadingSpinner=\"crescent\" loadingText=\"Loading\"></ion-infinite-scroll-content>\n </ion-infinite-scroll>\n</ion-content>\n","import { NgModule } from '@angular/core';\nimport { RouterModule, Routes } from '@angular/router';\nimport { PayoutsPage } from './payouts.page';\n\nconst routes: Routes = [\n {\n path: '',\n component: PayoutsPage,\n }\n];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule]\n})\nexport class PayoutsPageRoutingModule {}\n","import { Component } from '@angular/core';\nimport { ModalController, LoadingController, AlertController } from '@ionic/angular';\nimport { Router, ActivatedRoute } from '@angular/router';\nimport { APIService } from \"../../../services/api.service\";\nimport { AuthService } from \"../../../services/auth.service\";\nimport { ObserverService } from 'src/app/services/observer.service';\nimport * as moment from 'moment-timezone';\n\n@Component({\n selector: 'app-payouts',\n templateUrl: 'payouts.page.html',\n styleUrls: ['payouts.page.scss']\n})\nexport class PayoutsPage {\n\n spinner = null;\n moment = moment;\n unpaid_released_payout_balance = 0;\n unpaid_unreleased_payout_balance = 0;\n payouts = null;\n visible_payouts = null;\n\n constructor(\n public modalController: ModalController,\n public loadingController: LoadingController,\n public alertController: AlertController,\n private authService: AuthService,\n private apiService: APIService,\n private observerService: ObserverService,\n private router: Router,\n ) { }\n\n ngOnInit() {\n\n this.presentSpinner(\"Loading payouts\").then(() => {\n this.loadPayouts().then(() => {\n this.showInitialVisiblePayouts();\n this.loadUnpaidPayoutTransactions().then(() => {\n this.spinner.dismiss();\n })\n .catch(() => {\n this.spinner.dismiss();\n })\n })\n .catch(() => {\n this.spinner.dismiss();\n })\n })\n\n this.observerService.subscribe('transaction_intent_approved', () => {\n this.loadUnpaidPayoutTransactions().then(() => {\n this.spinner.dismiss();\n })\n .catch(() => {\n this.spinner.dismiss();\n })\n });\n\n }\n\n loadPayouts() {\n const promise = new Promise<void>((resolve, reject) => {\n this.payouts = null;\n this.visible_payouts = null;\n this.authService.isLoggedIn().then(() => {\n this.apiService.getPayouts({}).then((payouts) => {\n if (payouts) {\n this.payouts = payouts;\n resolve();\n }\n })\n .catch((error) => {\n if (error) {\n if (error.status === 400) {\n this.presentAlert(\"Problem\", \"Unknown error\", \"Unfortunately something went wrong when trying to get a list of payouts.\");\n } else if (error.status === 403) {\n this.presentAlert(\"Problem\", \"Insufficient permissions\", \"You don't have permission to view a list of payouts.\");\n } else if (error.status === 404 || error.status === 0) {\n this.presentAlert(\"Problem\", \"Unavailable\", \"Unfortunately we're unable to retrieve a list of payouts at this time.\");\n }\n }\n reject();\n });\n })\n .catch(() => {\n this.router.navigate([\"logout\"], { replaceUrl: true }).then(() => {\n window.location.reload();\n });\n });\n });\n return promise;\n }\n\n loadUnpaidPayoutTransactions() {\n const promise = new Promise<void>((resolve, reject) => {\n this.authService.isLoggedIn().then(() => {\n this.apiService.getConsumerTransactions({filter: 'unpaid_merchant_payout'}).then((transactions: any) => {\n if (transactions) {\n this.unpaid_released_payout_balance = 0;\n this.unpaid_unreleased_payout_balance = 0;\n for (let i = 0; i < transactions.length; i++) {\n if(transactions[i].released_for_merchant_payout) {\n this.unpaid_released_payout_balance += transactions[i].merchant_payout.price;\n }\n else {\n this.unpaid_unreleased_payout_balance += transactions[i].merchant_payout.price;\n }\n }\n resolve();\n }\n })\n .catch((error) => {\n if (error) {\n if (error.status === 400) {\n this.presentAlert(\"Problem\", \"Unknown error\", \"Unfortunately something went wrong when trying to get a list of transactions.\");\n } else if (error.status === 403) {\n this.presentAlert(\"Problem\", \"Insufficient permissions\", \"You don't have permission to view a list of transactions.\");\n } else if (error.status === 404 || error.status === 0) {\n this.presentAlert(\"Problem\", \"Unavailable\", \"Unfortunately we're unable to retrieve a list of transactions at this time.\");\n }\n }\n reject();\n });\n })\n .catch(() => {\n this.router.navigate([\"logout\"], { replaceUrl: true }).then(() => {\n window.location.reload();\n });\n });\n });\n return promise;\n }\n\n refreshPayouts(event) {\n this.loadPayouts().then(() => {\n this.showInitialVisiblePayouts();\n this.loadUnpaidPayoutTransactions().then(() => {\n event.target.complete()\n })\n .catch(() => {\n event.target.complete()\n })\n })\n .catch(() => {\n event.target.complete()\n })\n }\n\n showInitialVisiblePayouts() {\n let promise = new Promise<void>((resolve, reject) => {\n if (this.payouts && !this.visible_payouts) {\n this.visible_payouts = [];\n }\n let count = this.visible_payouts.length;\n for (let i = 0; i < 15; i++) {\n let position = i + count;\n if (this.payouts.length > position) {\n this.visible_payouts.push(this.payouts[position]);\n }\n else {\n break;\n }\n }\n resolve();\n });\n return promise;\n }\n\n showMoreVisiblePayouts(event) {\n let count = this.visible_payouts.length;\n for (let i = 0; i < 10; i++) {\n let position = i + count;\n if (this.payouts.length > position) {\n this.visible_payouts.push(this.payouts[position]);\n }\n else {\n break;\n }\n }\n event.target.complete();\n }\n \n async openReleaseForPayoutAlert() {\n const alert = await this.alertController.create({\n header: 'Are you sure?',\n message: \"By releasing these transactions for payout you are forfeiting the ability to refund them later.\",\n buttons: [\n {\n text: 'Cancel',\n handler: () => { },\n }, \n {\n text: 'Release now',\n cssClass: 'my-custom-class',\n handler: () => {\n this.presentSpinner('Releasing').then(() => {\n this.authService.isLoggedIn().then(() => {\n this.apiService.releaseConsumerTransactionsForPayout().then(() => {\n this.loadUnpaidPayoutTransactions().then(() => {\n this.spinner.dismiss();\n })\n .catch(() => {\n this.spinner.dismiss();\n })\n })\n .catch((error) => {\n if (error) {\n if (error.status === 400) {\n this.presentAlert(\"Problem\", \"Unknown error\", \"Unfortunately something went wrong when trying to release for payout.\");\n } else if (error.status === 403) {\n this.presentAlert(\"Problem\", \"Insufficient permissions\", \"You don't have permission to release for payout.\");\n } else if (error.status === 404 || error.status === 0) {\n this.presentAlert(\"Problem\", \"Unavailable\", \"Unfortunately we're unable to release for payout at this time.\");\n }\n }\n this.spinner.dismiss();\n }); \n })\n .catch(() => {\n this.spinner.dismiss();\n this.router.navigate(['logout'], {\n replaceUrl: true,\n })\n .then(() => {\n window.location.reload();\n });\n });\n });\n },\n },\n\n ],\n });\n await alert.present();\n }\n\n async presentAlert(header, sub_header, message) {\n const alert = await this.alertController.create({\n header: header,\n subHeader: sub_header,\n message: message,\n buttons: [\"OK\"],\n });\n await alert.present();\n }\n\n async presentSpinner(message) {\n this.spinner = await this.loadingController.create({\n message: message,\n showBackdrop: true,\n cssClass: 'loading-spinner'\n });\n await this.spinner.present();\n }\n\n}\n","import { IonicModule } from '@ionic/angular';\nimport { RouterModule } from '@angular/router';\nimport { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { PayoutsPage } from './payouts.page';\nimport { PayoutsPageRoutingModule } from './payouts-routing.module';\nimport { FontAwesomeModule } from '@fortawesome/angular-fontawesome';\n\n@NgModule({\n imports: [\n FontAwesomeModule,\n IonicModule,\n CommonModule,\n FormsModule,\n PayoutsPageRoutingModule\n ],\n declarations: [PayoutsPage]\n})\nexport class PayoutsPageModule {}\n"],"sourceRoot":"webpack:///"}