Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
fix(consultation): correct the state to use
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Nov 28, 2022
1 parent 9380ba0 commit 7d7a3cd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
8 changes: 5 additions & 3 deletions components/consultation/chat_window/consultation_header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<string>({
get(): string {
return props.modelValue
Expand Down
14 changes: 9 additions & 5 deletions components/consultation/chat_window/extra_controls.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>(Component, {
"global": {
"stubs": {
"Dropdown": false,
Expand All @@ -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
}
})

Expand All @@ -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<any>(Component, {
"global": {
"stubs": {
"Dropdown": false,
Expand All @@ -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")
Expand Down
24 changes: 14 additions & 10 deletions components/consultation/chat_window/extra_controls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,19 @@
View consultation form
</a>
<a
v-if="mustShowFinishButton"
v-if="mayShowFinishButton"
class="additional-control show-action-taken-overlay-btn"
@click="showActionTakenOverlay">
Finish consultation
</a>
<a
v-if="mustShowCancelButton"
v-if="mayShowCancelButton"
class="additional-control show-action-taken-overlay-btn"
@click="showActionTakenOverlay">
Cancel consultation
</a>
<a
v-if="!isCurrentUserConsultant
&& !isConsultationFinishedOrCancelled
&& !isOngoing"
v-if="mayShowRescheduleButton"
class="additional-control show-rescheduling-overlay-btn"
@click="showReschedulerOverlay">
Reschedule consultation
Expand Down Expand Up @@ -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
}>()
Expand Down Expand Up @@ -98,10 +97,15 @@ function toggleHeaderControlDropdownShown() {
emit("toggleHeaderControlDropdownShown")
}
const mustShowFinishButton
= props.isCurrentUserConsultant && !props.isConsultationFinishedOrCancelled
const mustShowCancelButton
= !props.isCurrentUserConsultant && !props.isConsultationFinishedOrCancelled
const mayShowFinishButton = computed<boolean>(
() => props.isCurrentUserConsultant && props.isOngoing
)
const mayShowCancelButton = computed<boolean>(
() => !props.isCurrentUserConsultant && (props.willSoonStart || props.willStart)
)
const mayShowRescheduleButton = computed<boolean>(
() => !props.isCurrentUserConsultant && props.willSoonStart
)
function showActionTakenOverlay() {
toggleHeaderControlDropdownShown()
emit("showActionTakenOverlay")
Expand Down

0 comments on commit 7d7a3cd

Please sign in to comment.