CSR-1903 - Display service duration on confirmation
This commit is contained in:
parent
811d3fae06
commit
1159ab6c09
7 changed files with 92 additions and 18 deletions
15
src/helpers/duration-length-helper.js
Normal file
15
src/helpers/duration-length-helper.js
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
export function getDisplayTextForDurationLength(durationMinimum, durationMaximum) {
|
||||||
|
const isLongAppointment = durationMaximum >= 120;
|
||||||
|
const isDurationRange = durationMinimum !== durationMaximum;
|
||||||
|
|
||||||
|
const adjustedMinimum = isLongAppointment ? durationMinimum / 60 : durationMinimum;
|
||||||
|
const adjustedMaximum = isLongAppointment ? durationMaximum / 60 : durationMaximum;
|
||||||
|
|
||||||
|
const durationText = isDurationRange
|
||||||
|
? `${adjustedMinimum} - ${adjustedMaximum}`
|
||||||
|
: adjustedMinimum;
|
||||||
|
|
||||||
|
const unitText = isLongAppointment ? "hours" : "minutes";
|
||||||
|
|
||||||
|
return `${durationText} ${unitText}`;
|
||||||
|
}
|
||||||
24
src/helpers/duration-length-helper.spec.js
Normal file
24
src/helpers/duration-length-helper.spec.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
|
||||||
|
|
||||||
|
describe("damage-length-helper.js", () => {
|
||||||
|
it("Should return the expected duration for the appointment in hours", () => {
|
||||||
|
// Arrange / Act
|
||||||
|
const durationMinimum = 60;
|
||||||
|
const durationMaximum = 120;
|
||||||
|
|
||||||
|
const duration = getDisplayTextForDurationLength(durationMinimum, durationMaximum);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(duration).toEqual("1 - 2 hours");
|
||||||
|
});
|
||||||
|
it("Should return the expected duration for the appointment in minutes", () => {
|
||||||
|
// Arrange / Act
|
||||||
|
const durationMinimum = 30;
|
||||||
|
const durationMaximum = 45;
|
||||||
|
|
||||||
|
const duration = getDisplayTextForDurationLength(durationMinimum, durationMaximum);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(duration).toEqual("30 - 45 minutes");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -25,6 +25,8 @@ beforeEach(() => {
|
||||||
startTime: "09:00",
|
startTime: "09:00",
|
||||||
endTime: "10:00",
|
endTime: "10:00",
|
||||||
routeCode: "000",
|
routeCode: "000",
|
||||||
|
jobMaxMinutes: "120",
|
||||||
|
jobMinMinutes: "60",
|
||||||
},
|
},
|
||||||
lineItems: {
|
lineItems: {
|
||||||
glassParts: [
|
glassParts: [
|
||||||
|
|
@ -360,6 +362,41 @@ describe("computed properties...", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(testValue).toEqual("test1,<br/> test, AZ 12345");
|
expect(testValue).toEqual("test1,<br/> test, AZ 12345");
|
||||||
});
|
});
|
||||||
|
test("Appointment Duration should return text in expected format.", () => {
|
||||||
|
//Arrange
|
||||||
|
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.AppointmentDuration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual("Duration: 1 - 2 hours");
|
||||||
|
});
|
||||||
|
test("Appointment Duration should return with correct duration values in expected format for hours.", () => {
|
||||||
|
//Arrange
|
||||||
|
store.getters.submittedOrder.schedule.jobMaxMinutes = 120;
|
||||||
|
store.getters.submittedOrder.schedule.jobMinMinutes = 60;
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.AppointmentDuration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual("Duration: 1 - 2 hours");
|
||||||
|
});
|
||||||
|
test("Appointment Duration should return with correct duration values in expected format for minutes.", () => {
|
||||||
|
//Arrange
|
||||||
|
store.getters.submittedOrder.schedule.jobMaxMinutes = 45;
|
||||||
|
store.getters.submittedOrder.schedule.jobMinMinutes = 30;
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const testValue = wrapper.vm.AppointmentDuration;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(testValue).toEqual("Duration: 30 - 45 minutes");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ customMountOptions }) {
|
function setupMocks({ customMountOptions }) {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,12 @@
|
||||||
:scheduleEndTime="ScheduleEndTime" />
|
:scheduleEndTime="ScheduleEndTime" />
|
||||||
|
|
||||||
<div class="appoinmenttext" v-html="AppointmentWordingText"></div>
|
<div class="appoinmenttext" v-html="AppointmentWordingText"></div>
|
||||||
|
|
||||||
|
<textBlock
|
||||||
|
:customText="AppointmentDuration"
|
||||||
|
justifyText="center"
|
||||||
|
typeStyle="medium"
|
||||||
|
class="duration-text-block" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
@ -82,6 +88,7 @@ import vehicleBanner from "@/fmg-components/vehicle-banner/vehicle-banner";
|
||||||
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
||||||
import addToCalendar from "@/layouts/confirmation/add-to-calendar/add-to-calendar";
|
import addToCalendar from "@/layouts/confirmation/add-to-calendar/add-to-calendar";
|
||||||
import cart from "@/fmg-components/cart/cart";
|
import cart from "@/fmg-components/cart/cart";
|
||||||
|
import textBlock from "@/digital-components/text-block/text-block";
|
||||||
|
|
||||||
//Supporting files
|
//Supporting files
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
@ -97,6 +104,7 @@ import { deepClone } from "@/helpers/object-helper";
|
||||||
import { Form } from "vee-validate";
|
import { Form } from "vee-validate";
|
||||||
import { get12HourTimeFormat, get12HourTimeMobileFormat } from "@/helpers/date-helper";
|
import { get12HourTimeFormat, get12HourTimeMobileFormat } from "@/helpers/date-helper";
|
||||||
import { coverageStatus } from "@/constants/insurance";
|
import { coverageStatus } from "@/constants/insurance";
|
||||||
|
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "confirmation",
|
name: "confirmation",
|
||||||
|
|
@ -315,6 +323,11 @@ export default {
|
||||||
isPia() {
|
isPia() {
|
||||||
return store.getters.submittedOrder?.payment.isPia;
|
return store.getters.submittedOrder?.payment.isPia;
|
||||||
},
|
},
|
||||||
|
AppointmentDuration() {
|
||||||
|
const durationMaximum = store.getters.submittedOrder?.schedule?.jobMaxMinutes;
|
||||||
|
const durationMinimum = store.getters.submittedOrder?.schedule?.jobMinMinutes;
|
||||||
|
return "Duration: " + getDisplayTextForDurationLength(durationMinimum, durationMaximum);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
|
|
@ -365,6 +378,7 @@ export default {
|
||||||
vehicleBanner,
|
vehicleBanner,
|
||||||
addToCalendar,
|
addToCalendar,
|
||||||
cart,
|
cart,
|
||||||
|
textBlock,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -60,19 +60,3 @@ export function militaryToTwelveHourTime(timeString) {
|
||||||
|
|
||||||
return `${hours}:${minutes} ${meridianNotation}`;
|
return `${hours}:${minutes} ${meridianNotation}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDisplayTextForDurationLength(durationMinimum, durationMaximum) {
|
|
||||||
const isLongAppointment = durationMaximum >= 120;
|
|
||||||
const isDurationRange = durationMinimum !== durationMaximum;
|
|
||||||
|
|
||||||
const adjustedMinimum = isLongAppointment ? durationMinimum / 60 : durationMinimum;
|
|
||||||
const adjustedMaximum = isLongAppointment ? durationMaximum / 60 : durationMaximum;
|
|
||||||
|
|
||||||
const durationText = isDurationRange
|
|
||||||
? `${adjustedMinimum} - ${adjustedMaximum}`
|
|
||||||
: adjustedMinimum;
|
|
||||||
|
|
||||||
const unitText = isLongAppointment ? "hours" : "minutes";
|
|
||||||
|
|
||||||
return `${durationText} ${unitText}`;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ import { deepClone } from "@/helpers/object-helper";
|
||||||
import {
|
import {
|
||||||
convertDateStringToDate,
|
convertDateStringToDate,
|
||||||
militaryToTwelveHourTime,
|
militaryToTwelveHourTime,
|
||||||
getDisplayTextForDurationLength,
|
|
||||||
} from "@/layouts/schedule/helpers/schedule-helper";
|
} from "@/layouts/schedule/helpers/schedule-helper";
|
||||||
|
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
|
||||||
|
|
||||||
// Validation - TODO: Move this somewhere more global?
|
// Validation - TODO: Move this somewhere more global?
|
||||||
import { defineRule, useField } from "vee-validate";
|
import { defineRule, useField } from "vee-validate";
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,8 @@ import { partTypeStrings } from "@/constants/part-type-strings";
|
||||||
import {
|
import {
|
||||||
convertDateStringToDate,
|
convertDateStringToDate,
|
||||||
militaryToTwelveHourTime,
|
militaryToTwelveHourTime,
|
||||||
getDisplayTextForDurationLength,
|
|
||||||
} from "@/layouts/schedule/helpers/schedule-helper";
|
} from "@/layouts/schedule/helpers/schedule-helper";
|
||||||
|
import { getDisplayTextForDurationLength } from "@/helpers/duration-length-helper";
|
||||||
import { paymentMethods } from "@/constants/payment-method-constants";
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
import {
|
import {
|
||||||
getPromoCodeWithoutBundleIdentifier,
|
getPromoCodeWithoutBundleIdentifier,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue