diff --git a/components/consultation/chat_window/consultation_header.vue b/components/consultation/chat_window/consultation_header.vue index 2f1e3d3d6..df7a41804 100644 --- a/components/consultation/chat_window/consultation_header.vue +++ b/components/consultation/chat_window/consultation_header.vue @@ -35,7 +35,8 @@ :consultation-id="consultation.id" :is-header-control-dropdown-shown="isHeaderControlDropdownShown" :is-current-user-consultant="isCurrentUserConsultant" - :is-consultation-finished-or-cancelled="isConsultationFinishedOrCancelled" + :will-soon-start="willSoonStart" + :will-start="willStart" :is-ongoing="isOngoing" @show-action-taken-overlay="showActionTakenOverlay" @toggle-header-control-dropdown-shown="toggleHeaderControlDropdownShown" @@ -258,12 +259,13 @@ const actionTakenHeader = isCurrentUserConsultant.value const actionTakenDescription = isCurrentUserConsultant.value ? "action taken to solve the consulter(s) concern." : "reason for cancellation." + const { + willSoonStart, + willStart, isCanceled, - isDone, isOngoing } = makeConsultationStates(props) -const isConsultationFinishedOrCancelled = isDone.value || isCanceled.value const actionTaken = computed({ get(): string { return props.modelValue diff --git a/components/consultation/chat_window/extra_controls.spec.ts b/components/consultation/chat_window/extra_controls.spec.ts index df9b1a512..e3e4a92b4 100644 --- a/components/consultation/chat_window/extra_controls.spec.ts +++ b/components/consultation/chat_window/extra_controls.spec.ts @@ -4,7 +4,7 @@ import Component from "./extra_controls.vue" describe("Component: chat_window/extra_controls", () => { it("should emit toggling of action taken", async() => { - const wrapper = shallowMount(Component, { + const wrapper = shallowMount(Component, { "global": { "stubs": { "Dropdown": false, @@ -13,10 +13,11 @@ describe("Component: chat_window/extra_controls", () => { }, "props": { "consultationId": "1", - "isConsultationFinishedOrCancelled": false, "isCurrentUserConsultant": true, "isHeaderControlDropdownShown": true, - "isOngoing": false + "isOngoing": false, + "willSoonStart": false, + "willStart": false } }) @@ -30,7 +31,7 @@ describe("Component: chat_window/extra_controls", () => { it("should lead to printable consultation form", () => { const id = "1" - const wrapper = shallowMount(Component, { + const wrapper = shallowMount(Component, { "global": { "stubs": { "Dropdown": false, @@ -42,7 +43,10 @@ describe("Component: chat_window/extra_controls", () => { "isConsultationFinishedOrCancelled": false, "isCurrentUserConsultant": true, "isHeaderControlDropdownShown": true, - "isOngoing": false + "isOngoing": false, + "willSoonStart": false, + "willStart": false + } }) const printableFormLink = wrapper.find(".view-printable-form-link") diff --git a/components/consultation/chat_window/extra_controls.vue b/components/consultation/chat_window/extra_controls.vue index fa21a1526..ecbe7aeeb 100644 --- a/components/consultation/chat_window/extra_controls.vue +++ b/components/consultation/chat_window/extra_controls.vue @@ -11,21 +11,19 @@ View consultation form Finish consultation Cancel consultation Reschedule consultation @@ -69,8 +67,9 @@ import Dropdown from "@/helpers/minor_dropdown.vue" const props = defineProps<{ consultationId: string, isCurrentUserConsultant: boolean, - isConsultationFinishedOrCancelled: boolean, isHeaderControlDropdownShown: boolean, + willSoonStart: boolean + willStart: boolean isOngoing: boolean }>() @@ -98,10 +97,15 @@ function toggleHeaderControlDropdownShown() { emit("toggleHeaderControlDropdownShown") } -const mustShowFinishButton -= props.isCurrentUserConsultant && !props.isConsultationFinishedOrCancelled -const mustShowCancelButton -= !props.isCurrentUserConsultant && !props.isConsultationFinishedOrCancelled +const mayShowFinishButton = computed( + () => props.isCurrentUserConsultant && props.isOngoing +) +const mayShowCancelButton = computed( + () => !props.isCurrentUserConsultant && (props.willSoonStart || props.willStart) +) +const mayShowRescheduleButton = computed( + () => !props.isCurrentUserConsultant && props.willSoonStart +) function showActionTakenOverlay() { toggleHeaderControlDropdownShown() emit("showActionTakenOverlay")