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

Commit

Permalink
feat(consultation): allow rescheduling
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Nov 14, 2022
1 parent 061164f commit 504217e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
29 changes: 26 additions & 3 deletions components/consultation/chat_window/rescheduler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<template #footer>
<button
class="finish-btn btn btn-primary"
class="reschedule-btn btn btn-primary"
@click="rescheduleConsultation">
submit
</button>
Expand All @@ -29,7 +29,7 @@
</style>

<script setup lang="ts">
import { inject, onMounted, ref } from "vue"
import { computed, inject, onMounted, ref } from "vue"
import type { PageContext } from "$/types/renderer"
import type { DeserializedUserDocument } from "$/types/documents/user"
Expand All @@ -39,6 +39,7 @@ import { DEFAULT_LIST_LIMIT } from "$/constants/numerical"
import Fetcher from "$@/fetchers/consultation"
import EmployeeScheduleFetcher from "$@/fetchers/employee_schedule"
import convertMinutesToTimeObject from "%/helpers/convert_minutes_to_time_object"
import Overlay from "@/helpers/overlay.vue"
import Scheduler from "@/consultation/helpers/scheduler.vue"
Expand Down Expand Up @@ -89,8 +90,30 @@ function fetchConsultantSchedules() {
})
}
const scheduledStartAt = computed(() => {
const chosenDate = new Date(chosenDay.value)
if (chosenTime.value) {
const timeObject = convertMinutesToTimeObject(Number(chosenTime.value))
chosenDate.setHours(timeObject.hours)
chosenDate.setMinutes(timeObject.minutes)
chosenDate.setSeconds(0)
chosenDate.setMilliseconds(0)
}
console.log("from component", chosenDate.toJSON())
return chosenDate.toJSON()
})
const fetcher = new Fetcher()
function rescheduleConsultation() {
emit("rescheduleConsultation")
fetcher.update(consultation.data.id, {
"actionTaken": null,
"deletedAt": null,
"finishedAt": null,
"reason": consultation.data.reason,
"scheduledStartAt": scheduledStartAt.value,
"startedAt": null
})
}
onMounted(() => {
Expand Down
4 changes: 3 additions & 1 deletion components/consultation/helpers/scheduler.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import convertTimeToMinutes from "$/time/convert_time_to_minutes"
import { shallowMount } from "@vue/test-utils"

import convertTimeToMinutes from "$/time/convert_time_to_minutes"

import Component from "./scheduler.vue"

describe.skip("Component: consultation/helpers/scheduler", () => {
Expand Down Expand Up @@ -53,6 +54,7 @@ describe.skip("Component: consultation/helpers/scheduler", () => {
await selectableDayField.setValue(chosenDay)
await wrapper.setProps({ chosenDay })
console.log(wrapper.html(), "\n\n\n")
console.log(chosenDay, "\n\n\n")
const selectableTime = wrapper.find(".selectable-time")
expect(selectableTime.exists()).toBeTruthy()
// const timeOptions = selectableTime.findAll("option")
Expand Down

0 comments on commit 504217e

Please sign in to comment.