Files
WrenchBoardIonic2023/src/app/components/offers-received/offers-received.component.ts
T
CHIEFSOFT\ameye d0ffbe4444 fix page
2024-09-25 11:19:07 -04:00

164 lines
4.9 KiB
TypeScript

import {Component, OnInit, ViewChild} from '@angular/core';
import {AlertController, LoadingController, NavController} from "@ionic/angular";
import {Router} from "@angular/router";
import {SessionDataProviderService} from "../../store/session-data-provider.service";
import {WrenchService} from "../../services/wrench.service";
import { BannersDataService } from "../../store/banners-data.service";
@Component({
selector: 'app-offers-received',
templateUrl: './offers-received.component.html',
styleUrls: ['./offers-received.component.scss'],
})
export class OffersReceivedComponent implements OnInit {
@ViewChild('offerData') offerData: [];
constructor(
private navctrl: NavController,
private router: Router,
public sessionDataProviderService: SessionDataProviderService,
private alertController:AlertController,
private wrenchService: WrenchService,
private loadingCtrl: LoadingController,
public bannersDataService: BannersDataService
) {
// this.getMyOffersData();
this.session_image_server = this.sessionDataProviderService.session_image_server;
setInterval(()=>{
this.offerData = this.bannersDataService.offerData;
this.session_image_server = this.sessionDataProviderService.session_image_server;
}, 5000);
}
ngOnInit() {
}
session_image_server:string='';
curr_session:string='';
//
usrData: {
action:number, member_id: number, uid: string,
sessionid: string,
limit:20,
page:1, offset:number
};
// total_offers:number = 0;
// myOffersTotalData:any;
// myOffersData: [];
// getMyOffersData(){
// this.usrData = {action:15010,
// member_id: this.sessionDataProviderService.member_id,
// uid: this.sessionDataProviderService.member_uid,
// sessionid: this.sessionDataProviderService.session ,
// limit:20, page:1,offset: 0}
//
// this.curr_session = this.sessionDataProviderService.session;
// this.wrenchService.getMyOffers(this.usrData).subscribe(
// myOffersTotalData => {
// this.myOffersTotalData = myOffersTotalData;
// this.session_image_server = this.myOffersTotalData.session_image_server;
// console.log("myOffersTotalData RETURN->", this.myOffersTotalData);
// this.myOffersData = this.myOffersTotalData.result_list;
// console.log("myOffersData RETURN DATA->", this.myOffersData);
// this.total_offers = this.myOffersData?.length;
// }
// );
//
// }
openOfferDetail(item){
}
async requestStart(item) {
const alert = await this.alertController.create({
header: "Ready to start",
message: "You will start the task now, offer shall be completed in allocated timeline.",
buttons: [
{
text: "Cancel",
role: "cancel",
handler: () => {
// this.getMyOffersData();
this.offerData = this.bannersDataService.offerData;
},
},
{
text: "Start Now",
handler: () => {
this.sendOfferResponse(item, 100);
// this.getMyOffersData();
this.offerData = this.bannersDataService.offerData;
},
},
],
});
await alert.present();
}
async requestReject(item) {
const alert = await this.alertController.create({
header: "Confirm Reject",
message: "This task will go away, you dont have to do anything.",
buttons: [
{
text: "Cancel",
role: "cancel",
handler: () => {
//this.getMyOffersData();
this.offerData = this.bannersDataService.offerData;
},
},
{
text: "Reject",
handler: () => {
this.sendOfferResponse(item, 333);
//this.getMyOffersData();
this.offerData = this.bannersDataService.offerData;
},
},
],
});
await alert.present();
}
responseData: {
action:number,
member_id: number,
uid: string,
sessionid: string,
offer_result:number,
contract:string,
offer_code:string
};
offerRespData:any;
// offferResponse(respData)
async sendOfferResponse(item, respType){
const loading = await this.loadingCtrl.create({
message: 'Processing',
duration: 3000,
});
this.responseData = {
action:15010,
member_id: this.sessionDataProviderService.member_id,
uid: this.sessionDataProviderService.member_uid,
sessionid: this.sessionDataProviderService.session ,
offer_result:respType,
contract:item.contract,
offer_code: item.contract
};
await loading.present();
this.wrenchService.offferResponse(this.responseData).subscribe(
offerRespData => {
this.offerRespData = offerRespData;
console.log("offerRespData RETURN->", this.offerRespData);
// this.getMyOffersData();
this.offerData = this.bannersDataService.offerData;
}
);
}
}