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

Commit

Permalink
feat(consultation): show status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lemredd committed Nov 14, 2022
1 parent 4ce84e6 commit 5bab62f
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions components/consultation/chat_window/rescheduler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
</template>

<template #default>
<ReceivedErrors v-if="ReceivedErrors.length" :received-errors="receivedErrors"/>
<ReceivedSuccessMessages
v-if="successMessages.length"
:received-success-messages="successMessages"/>
<Scheduler
v-model:chosen-day="chosenDay"
v-model:chosen-time="chosenTime"
Expand Down Expand Up @@ -37,12 +41,16 @@ import type { DeserializedEmployeeScheduleListDocument } from "$/types/documents
import { DEFAULT_LIST_LIMIT } from "$/constants/numerical"
import Fetcher from "$@/fetchers/consultation"
import fillSuccessMessages from "$@/helpers/fill_success_messages"
import EmployeeScheduleFetcher from "$@/fetchers/employee_schedule"
import loadRemainingResource from "$@/helpers/load_remaining_resource"
import extractAllErrorDetails from "$@/helpers/extract_all_error_details"
import convertMinutesToTimeObject from "%/helpers/convert_minutes_to_time_object"
import Overlay from "@/helpers/overlay.vue"
import Scheduler from "@/consultation/helpers/scheduler.vue"
import loadRemainingResource from "$@/helpers/load_remaining_resource"
import ReceivedErrors from "@/helpers/message_handlers/received_errors.vue"
import ReceivedSuccessMessages from "@/helpers/message_handlers/received_success_messages.vue"
const pageContext = inject("pageContext") as PageContext<"deserialized", "consultation">
const { pageProps } = pageContext
Expand All @@ -64,6 +72,19 @@ const { consultation } = pageProps
const employeeScheduleFetcher = new EmployeeScheduleFetcher()
const chosenDay = ref("")
const chosenTime = ref("")
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)
}
return chosenDate.toJSON()
})
const consultantSchedules = ref<DeserializedEmployeeScheduleListDocument>({
"data": [],
"meta": {
Expand All @@ -89,20 +110,9 @@ 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)
}
return chosenDate.toJSON()
})
const fetcher = new Fetcher()
const receivedErrors = ref<string[]>([])
const successMessages = ref<string[]>([])
function rescheduleConsultation() {
fetcher.update(consultation.data.id, {
"actionTaken": null,
Expand Down Expand Up @@ -131,6 +141,14 @@ function rescheduleConsultation() {
}
}
})
.then(() => fillSuccessMessages(
receivedErrors,
successMessages,
"Your consultation has been successfully rescheduled."
))
.catch(responseWithErrors => extractAllErrorDetails(
responseWithErrors, receivedErrors, successMessages
))
}
onMounted(() => {
Expand Down

0 comments on commit 5bab62f

Please sign in to comment.