diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html index 55eaa6a..96bbdc5 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.html @@ -85,9 +85,16 @@ {{check(days) | date:'longDate'}}
-
+
+ - + + + + + + +
diff --git a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts index d067865..a84414e 100644 --- a/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts +++ b/ng-seed/src/app/appoinment/appoinments/dialog-box/dialog-box.component.ts @@ -112,6 +112,8 @@ export class DialogBoxComponent implements OnInit { isSubmitting: boolean = false; selectedRadioValue: any; paymentMode: boolean = false; + slotIndex_group:any=[]; + slotslength:any=[]; constructor(private notifierService: NotifierService,private router: Router,private formBuilder: FormBuilder, public _cus:CustomersService, public dialogRef: MatDialogRef,public _api:ConsultantService, public _con:ConsultantService, @Inject(MAT_DIALOG_DATA) public data: UsersData,public _app:AppointmentsService,public end_user:EndUserService) { @@ -296,6 +298,12 @@ export class DialogBoxComponent implements OnInit { console.log(res) let data = res['data']; this.slots = data + let len =[] + this.slots.forEach(element => { + + len.push( element.length) + }) + console.log(len) // this.slots.forEach(element => { // console.log(element) // if(element == this.findSlotIndex[0]){ @@ -376,7 +384,7 @@ export class DialogBoxComponent implements OnInit { }) } - checkSlotDur(param:any,i:any){ + checkSlotDur(param:any,i:any,slots){ //console.log(param,i) // this.slot_array =[]; // debugger; @@ -385,7 +393,7 @@ export class DialogBoxComponent implements OnInit { // this.slotTime = param // console.log(this.date,param) - let thirtyMinutes = this.duration * 60 * 1000; // convert 30 minutes to milliseconds + let thirtyMinutes = this.duration * 60000; // convert 30 minutes to milliseconds let date1 = new Date(param); let date2 = new Date(date1.getTime() + thirtyMinutes); // console.log(date1); @@ -395,14 +403,14 @@ export class DialogBoxComponent implements OnInit { const rangeDate = new Date(date2); - const resultArray = this.slots.filter(slot => { + const resultArray = slots.filter(slot => { const date = new Date(slot); return date >= rangeDate; }); const firstSlt = new Date(date1); const lastSlt = new Date( resultArray[0]); - const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); + const filteredTimes = slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); // console.log(resultArray,filteredTimes); @@ -595,16 +603,25 @@ console.log(params) console.log(res) let data = res['data']; this.slots = data + let len =[]; + this.slots.forEach(element => { + + len.push( element.length) + }) + console.log(len) + + this.slotslength = len.reduce((a, b) => a + b, 0) } }) } - toggleActive(event:any,param:any,i:any){ + toggleActive(event:any,param:any,i:any,slots,j){ console.log(event,param,i) this.slot_array =[]; + this.slotIndex_group=j // debugger; // // event.preventDefault(); - this.slotIndex = i + this.slotIndex = param // this.slotTime = param let resultDate = new DatePipe('en-US').transform(param, 'shortTime') this.form.controls['appoinmentTime'].setValue(resultDate) @@ -621,14 +638,14 @@ console.log(params) const rangeDate = new Date(date2); - const resultArray = this.slots.filter(slot => { + const resultArray =slots.filter(slot => { const date = new Date(slot); return date >= rangeDate; }); const firstSlt = new Date(date1); const lastSlt = new Date( resultArray[0]); - const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); + const filteredTimes = slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); console.log(resultArray,filteredTimes); // if(filteredTimes.length > 1){ diff --git a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html index f0eb116..30c0d14 100644 --- a/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html +++ b/ng-seed/src/app/end-user/booking-summary/booking-summary.component.html @@ -79,7 +79,7 @@ Booked On
- : {{bookingSummary.createdAt2 | date:'dd/MM/yyyy'}} + : {{bookingSummary.createdAt2 }}
@@ -111,7 +111,16 @@ Fees
- : {{busCurrency}} {{serviceMapDetails.duration.length>0 ? serviceMapDetails.duration[0].fees : serviceMapDetails.service[0].fees}} + : {{busCurrency}} {{(serviceMapDetails.duration.length>0 ? serviceMapDetails.duration[0].fees : serviceMapDetails.service[0].fees) | currency: currency}} +
+
+ +
+
+ Payment Status +
+
+ : {{(bookingSummary.paymentStatus== 0 ? 'Not Paid' : 'Paid') }}
- + diff --git a/ng-seed/src/app/end-user/customer-info/customer-info.component.ts b/ng-seed/src/app/end-user/customer-info/customer-info.component.ts index f3314a7..35f6f79 100644 --- a/ng-seed/src/app/end-user/customer-info/customer-info.component.ts +++ b/ng-seed/src/app/end-user/customer-info/customer-info.component.ts @@ -115,7 +115,7 @@ export class CustomerInfoComponent implements OnInit { order_id: generateRandomString(), description: 'testing', mode: 'TEST', - return_url: this.apiUrl+'paymentResponse', + return_url: 'http://localhost:8080/api/paymentResponse', currency: 'INR', country: 'IND', udf1: ''+busId+'', @@ -351,7 +351,7 @@ export class CustomerInfoComponent implements OnInit { } - onclickfun(){ + onclickfun2(){ console.log("worked") @@ -452,6 +452,161 @@ this.paymentform = payment; } } - + + +onclickfun(){ + let URL = this.router.url; + let busId = localStorage.getItem('busId') + + let addFormData = { + busId: busId, + cusName: this.form.value.name, + email: this.form.value.email, + address_1: this.form.value.address_line_1, + phoneNo: this.form.value.phone, + pincode: this.form.value.zip_code, + state: this.form.value.state, + city: this.form.value.city, + }; +console.log(addFormData) + + +function generateRandomString() { + const prefix = "ORD-"; + const randomNum = (Math.random() + 1).toString(36).substring(7); + return prefix + randomNum; + } + +this._cus.addCusDetails(addFormData).subscribe(async (res1) => { +if (res1.status == 200) { + console.log(res1) + this.createAppointment(res1['data'].id) + + +} + +}) +} + + +createAppointment(cusID){ + let slot_array = JSON.parse(localStorage.getItem("slotData")) + + let busId = localStorage.getItem('busId') + let service = localStorage.getItem("servicedetails") + let serviceDetails = JSON.parse(service) + console.log(serviceDetails) + + let URL = this.router.url; + console.log(URL,slot_array) + let URL_AS_LIST = URL.split('/'); + console.log(URL_AS_LIST); + // let cusID; + // if(URL_AS_LIST[2] == 'business'){ + // cusID=URL_AS_LIST[9] + // }else{ + // cusID=URL_AS_LIST[8] + // } + // if(serviceDetails.hasOwnProperty('userId')){ + serviceDetails.userId = localStorage.getItem('user_id') + let paramPay = {"cusId":cusID} + + + + // } +let paramsmap= { + "serviceId": ""+serviceDetails.serviceId+"", + "userId": serviceDetails.userId, + "busId": serviceDetails.busId +} + console.log(paramsmap) + this._cus.CreatecusServicesMapDetails(paramsmap).subscribe(res => { + if (res.status == 200) { + console.log(res) + let serviceMap = res['data'][0].id + let time = new Date().toLocaleTimeString() + let params= { + "busId": serviceDetails.busId, + "cusId": cusID, + "appoinmentDate": slot_array[0].date, + "appoinmentTime": time, + "serviceMap": serviceMap, + "paymentStatus": 0, + "paymentMode":"online", + "createdBy":"customer", + "appoinmentSlots": JSON.stringify(slot_array[0].slots) + //"servicemap" :this.bookedAppointment_servicemap + } + + this._cus.CreateAppoinmentsCus(params).subscribe(res => { + if (res.status == 200) { + console.log(res) + res = res.data; + // this.end_user.summmarylist.next(res.data) + console.log('booked2', res); + let app = {app:res,data:params} + + let bookingId = res[0].bookingId + let appointmentId = res[0].id + + let payment = { + api_key: '4cb964d4-9ef4-4a25-8f85-a2a13f43cbba', + hash: '', + amount: ""+this.bookedDetails.amount+"", + order_id: ''+bookingId+'', + description: 'testing', + mode: 'TEST', + return_url: 'http://localhost:8080/api/paymentResponse', + currency: 'INR', + country: 'IND', + udf1: ''+busId+'', + udf2: ''+window.location.origin+'/#'+URL+'/', + udf3: ''+cusID+'', + udf4: ''+appointmentId+'', + udf5: '' +} + +this.form.patchValue(payment) + +this._cus.paymentRequest(this.form.value ).subscribe(res => { + + console.log(this.form.value , res) + + + //this._cus.addCusDetails(addFormData).subscribe(res1 => { + //if (res1.status == 200) { + // console.log(res1) + + // let URL = this.router.url; + // console.log(URL) + this.form.controls['hash'].setValue(res.data) + this.testFormEl.nativeElement.submit() + +}) + + + // this.bookingSummary.appoinmentSlots =JSON.parse(this.bookingSummary.appoinmentSlots) + + // this.end_user.getcusServicesMapDetails() + // let param ={id:serviceMap} + // this._cus.getcusServicesMapDetails(param).subscribe(res => { + // if (res.status == 200) { + // console.log(res) + + + // } + // }) + }else{ + return {} + } + }) +} + }) + +} +ngOnDestroy(){ + localStorage.clear(); +} + } diff --git a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.html b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.html index ee7ce45..bfad978 100644 --- a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.html +++ b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.html @@ -87,8 +87,13 @@ - - + + + + + + + diff --git a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts index ed02686..668ade4 100644 --- a/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts +++ b/ng-seed/src/app/end-user/slot-booking/slot-booking-details.component.ts @@ -58,6 +58,8 @@ export class SlotBookingDetailsComponent implements OnInit { serviceMapdetails:any =[] advanced_slot_days: any; logo: any; + slots_select:any=[]; + slotIndex_group:any=[]; private apiUrl = environment.apiEndpoint; constructor(private _location: Location,private router:Router,private datepipe:DatePipe,public end_user:EndUserService) { @@ -246,13 +248,16 @@ if(this.getHours.length != 0){ this.activeButton = event; } - toggleActive(event:any,param:any,i:any){ + toggleActive(event:any,param:any,i:any,slots,j){ console.log(event,param,i) this.slot_array =[]; // debugger; // event.preventDefault(); - this.slotIndex = i + this.slotIndex = param + this.slotIndex_group = j this.slotTime = param + + this.slots_select = slots console.log(this.date,param,this.servicesName.duration) let thirtyMinutes = this.servicesName.duration *60000; // convert 30 minutes to milliseconds @@ -266,17 +271,17 @@ if(this.getHours.length != 0){ const rangeDate = new Date(date2); - const resultArray = this.slots.filter(slot => { + const resultArray = slots.filter(slot => { const date = new Date(slot); return date >= rangeDate; }); const firstSlt = new Date(date1); const lastSlt = new Date( resultArray[0]); - const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); + const filteredTimes = slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); - console.log(resultArray,filteredTimes); - // let result = filteredTimes.pop(); + console.log("hi",filteredTimes); + let result = filteredTimes.pop(); //console.log(result); this.slots.forEach(element => { if(element { + const resultArray = slots.filter(slot => { const date = new Date(slot); return date >= rangeDate; }); const firstSlt = new Date(date1); const lastSlt = new Date( resultArray[0]); - const filteredTimes = this.slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); + const filteredTimes = slots.filter(time => new Date(time) >= firstSlt && new Date(time) <= lastSlt); // console.log(resultArray,filteredTimes);