CSR-1149 | Fix AM/PM Bug and Formatting
This commit is contained in:
parent
27133a6f56
commit
6358fbbe96
2 changed files with 34 additions and 17 deletions
|
|
@ -272,16 +272,28 @@ export default {
|
||||||
if (!timeSlotData.id) {
|
if (!timeSlotData.id) {
|
||||||
funnelFooterButtonText = "Continue";
|
funnelFooterButtonText = "Continue";
|
||||||
} else {
|
} else {
|
||||||
funnelFooterButtonText = "Select " + this.convertSelectedDateToShortMonthAndDay(this.selectedDate);
|
funnelFooterButtonText =
|
||||||
|
"Select " + this.convertSelectedDateToShortMonthAndDay(this.selectedDate);
|
||||||
|
|
||||||
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
||||||
funnelFooterButtonText += " at " + this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime);
|
|
||||||
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE && !timeSlotData.isPremiumAppointment) {
|
|
||||||
funnelFooterButtonText +=
|
funnelFooterButtonText +=
|
||||||
" at " +
|
" at " +
|
||||||
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime, true) +
|
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime);
|
||||||
" - " +
|
} else if (
|
||||||
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.endTime, true);
|
this.appointmentType === AppointmentTypeStrings.MOBILE &&
|
||||||
|
!timeSlotData.isPremiumAppointment
|
||||||
|
) {
|
||||||
|
funnelFooterButtonText +=
|
||||||
|
" at " +
|
||||||
|
this.getDisplayTextForMilitaryTime(
|
||||||
|
this.appointmentDateAndTime.startTime,
|
||||||
|
true
|
||||||
|
) +
|
||||||
|
" - " +
|
||||||
|
this.getDisplayTextForMilitaryTime(
|
||||||
|
this.appointmentDateAndTime.endTime,
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -290,16 +302,15 @@ export default {
|
||||||
convertSelectedDateToShortMonthAndDay(selectedDate) {
|
convertSelectedDateToShortMonthAndDay(selectedDate) {
|
||||||
// This conversion ensures we don't get get GMT induced date changes
|
// This conversion ensures we don't get get GMT induced date changes
|
||||||
const dateObject = new Date(`${selectedDate.dateString}T00:00:00`);
|
const dateObject = new Date(`${selectedDate.dateString}T00:00:00`);
|
||||||
return dateObject.toLocaleDateString("en-us", {month:"short", day:"numeric"});
|
return dateObject.toLocaleDateString("en-us", { month: "short", day: "numeric" });
|
||||||
},
|
},
|
||||||
// Expected input: "HH:MM:SS"
|
// Expected input: "HH:MM:SS"
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
const minutes = militaryTimeInput.split(":")[1];
|
||||||
let meridianNotation = "AM";
|
let meridianNotation = hours > 11 ? "PM" : "AM";
|
||||||
if (militaryTimeInput.split(":")[0] > 12) {
|
if (hours > 12) {
|
||||||
hours -= 12;
|
hours -= 12;
|
||||||
meridianNotation = "PM";
|
|
||||||
}
|
}
|
||||||
if (shouldTrimMinutesIfEmpty && minutes === "00") {
|
if (shouldTrimMinutesIfEmpty && minutes === "00") {
|
||||||
return `${hours} ${meridianNotation}`;
|
return `${hours} ${meridianNotation}`;
|
||||||
|
|
@ -338,7 +349,7 @@ export default {
|
||||||
},
|
},
|
||||||
selectedTimeSlotData() {
|
selectedTimeSlotData() {
|
||||||
this.updateFooterButtonText(this.selectedTimeSlotData);
|
this.updateFooterButtonText(this.selectedTimeSlotData);
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
funnelHeader,
|
funnelHeader,
|
||||||
|
|
|
||||||
|
|
@ -253,10 +253,9 @@ export default {
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput) {
|
getDisplayTextForMilitaryTime(militaryTimeInput) {
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
const minutes = militaryTimeInput.split(":")[1];
|
||||||
let meridianNotation = "AM";
|
let meridianNotation = hours > 11 ? "PM" : "AM";
|
||||||
if (militaryTimeInput.split(":")[0] > 12) {
|
if (hours > 12) {
|
||||||
hours -= 12;
|
hours -= 12;
|
||||||
meridianNotation = "PM";
|
|
||||||
}
|
}
|
||||||
return `${hours}:${minutes} ${meridianNotation}`;
|
return `${hours}:${minutes} ${meridianNotation}`;
|
||||||
},
|
},
|
||||||
|
|
@ -273,7 +272,14 @@ export default {
|
||||||
},
|
},
|
||||||
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) {
|
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) {
|
||||||
const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length;
|
const numberOfOptions = newdateAndTimeSlotDataValue?.timeSlots.length;
|
||||||
if (numberOfOptions === 1 && !(this.appointmentType === AppointmentTypeStrings.MOBILE && this.premiumAppointmentFee && newdateAndTimeSlotDataValue.timeSlots[0].offerPremium)) {
|
if (
|
||||||
|
numberOfOptions === 1 &&
|
||||||
|
!(
|
||||||
|
this.appointmentType === AppointmentTypeStrings.MOBILE &&
|
||||||
|
this.premiumAppointmentFee &&
|
||||||
|
newdateAndTimeSlotDataValue.timeSlots[0].offerPremium
|
||||||
|
)
|
||||||
|
) {
|
||||||
this.selectedTimeSlotId = newdateAndTimeSlotDataValue.timeSlots[0].id;
|
this.selectedTimeSlotId = newdateAndTimeSlotDataValue.timeSlots[0].id;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue