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) {
|
||||
funnelFooterButtonText = "Continue";
|
||||
} else {
|
||||
funnelFooterButtonText = "Select " + this.convertSelectedDateToShortMonthAndDay(this.selectedDate);
|
||||
|
||||
funnelFooterButtonText =
|
||||
"Select " + this.convertSelectedDateToShortMonthAndDay(this.selectedDate);
|
||||
|
||||
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
||||
funnelFooterButtonText += " at " + this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime);
|
||||
} else if (this.appointmentType === AppointmentTypeStrings.MOBILE && !timeSlotData.isPremiumAppointment) {
|
||||
funnelFooterButtonText +=
|
||||
" at " +
|
||||
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime, true) +
|
||||
" - " +
|
||||
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.endTime, true);
|
||||
" at " +
|
||||
this.getDisplayTextForMilitaryTime(this.appointmentDateAndTime.startTime);
|
||||
} else if (
|
||||
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) {
|
||||
// This conversion ensures we don't get get GMT induced date changes
|
||||
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"
|
||||
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||
const minutes = militaryTimeInput.split(":")[1];
|
||||
let meridianNotation = "AM";
|
||||
if (militaryTimeInput.split(":")[0] > 12) {
|
||||
let meridianNotation = hours > 11 ? "PM" : "AM";
|
||||
if (hours > 12) {
|
||||
hours -= 12;
|
||||
meridianNotation = "PM";
|
||||
}
|
||||
if (shouldTrimMinutesIfEmpty && minutes === "00") {
|
||||
return `${hours} ${meridianNotation}`;
|
||||
|
|
@ -338,7 +349,7 @@ export default {
|
|||
},
|
||||
selectedTimeSlotData() {
|
||||
this.updateFooterButtonText(this.selectedTimeSlotData);
|
||||
}
|
||||
},
|
||||
},
|
||||
components: {
|
||||
funnelHeader,
|
||||
|
|
|
|||
|
|
@ -253,10 +253,9 @@ export default {
|
|||
getDisplayTextForMilitaryTime(militaryTimeInput) {
|
||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
||||
const minutes = militaryTimeInput.split(":")[1];
|
||||
let meridianNotation = "AM";
|
||||
if (militaryTimeInput.split(":")[0] > 12) {
|
||||
let meridianNotation = hours > 11 ? "PM" : "AM";
|
||||
if (hours > 12) {
|
||||
hours -= 12;
|
||||
meridianNotation = "PM";
|
||||
}
|
||||
return `${hours}:${minutes} ${meridianNotation}`;
|
||||
},
|
||||
|
|
@ -273,7 +272,14 @@ export default {
|
|||
},
|
||||
autoSelectTimeSlotIfOnlyOneIsAvailable(newdateAndTimeSlotDataValue) {
|
||||
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;
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue