All files / src/components/AppointmentDetail AppointmentDetailHeader.vue

85.36% Statements 35/41
94.11% Branches 32/34
53.84% Functions 7/13
94.59% Lines 35/37

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190    21x           2x                                                                               20x 2x                                                                             21x               21x   21x 20x     21x   20x       21x 20x 2x     18x 3x     15x 1x     14x             21x 19x 3x     16x 2x     14x     21x 19x         14x     5x       21x                   21x 8x     21x 21x 21x 21x                                      
<template>
  <muc-intro
    v-if="appointment"
    :tagline="introTagline"
    :title="formatMultilineTitle(appointment)"
    variant="detail"
    :id="`process-${appointment?.processId}-displayNumber-${appointment?.displayNumber}`"
  >
    <div class="appointment-data">
      <p>
        <strong> {{ t("appointmentNumber") }}: </strong>
        {{ appointment.displayNumber ?? appointment.processId }}
      </p>
      <muc-link
        :label="
          formatAppointmentDateTime(appointment.timestamp) +
          ' ' +
          t('timeStampSuffix')
        "
        prepend-icon="calendar"
        @click.prevent="focusTime"
      />
      <br />
      <muc-link
        v-if="introLocation"
        :id="selectedProvider ? `provider-${selectedProvider.id}` : undefined"
        :label="introLocation"
        :prepend-icon="introLocationIcon"
        :aria-label="introLocationAriaLabel"
        @click.prevent="focusLocation"
      />
      <br />
      <muc-link
        v-if="appointment.icsContent"
        :label="t('downloadAppointment')"
        prepend-icon="calendar-down"
        @click.prevent="downloadIcsAppointment"
      />
      <!--      Used after the content of hint has been checked-->
      <!--      <p-->
      <!--        v-if="-->
      <!--          selectedProvider &&-->
      <!--          selectedProvider.scope &&-->
      <!--          selectedProvider.scope.hint-->
      <!--        "-->
      <!--      >-->
      <!--        {{ selectedProvider.scope.hint }}-->
      <!--      </p>-->
    </div>
    <div class="m-button-group">
      <muc-button
        v-if="!rebookingDisabled"
        icon="arrow-right"
        @click="rescheduleAppointment"
      >
        <template #default>{{ t("rescheduleAppointment") }}</template>
      </muc-button>
      <muc-button
        icon="trash"
        :variant="rebookingDisabled ? 'primary' : 'secondary'"
        @click="cancelAppointment"
      >
        <template #default>
          <span>{{ t("cancelAppointment") }}</span>
        </template>
      </muc-button>
    </div>
  </muc-intro>
</template>
 
<script setup lang="ts">
import type { VariantOverwrite } from "@/api/models/Service";
 
import { MucButton, MucIntro, MucLink } from "@muenchen/muc-patternlab-vue";
import { computed } from "vue";
 
import { AppointmentImpl } from "@/types/AppointmentImpl";
import { OfficeImpl } from "@/types/OfficeImpl";
import {
  VARIANT_ID_PRESENCE,
  VARIANT_ID_TELEPHONE,
  VARIANT_ID_VIDEO,
} from "@/utils/Constants";
import { downloadIcsFile } from "@/utils/downloadIcsFile";
import { formatAppointmentDateTime } from "@/utils/formatAppointmentDateTime";
import { formatMultilineTitle } from "@/utils/formatMultilineTitle";
import { useVariant } from "@/utils/useVariant";
 
const props = defineProps<{
  appointment: AppointmentImpl | undefined;
  selectedProvider: OfficeImpl | undefined;
  variantId: number | null;
  variantOverwrite?: VariantOverwrite;
  t: (key: string) => string;
}>();
 
const getVariant = useVariant(props.t);
 
const rebookingDisabled = computed(
  () => props.appointment?.scope?.rebookingDisabled === true
);
 
const introTagline = computed(
  () =>
    getVariant(props.variantId ?? VARIANT_ID_PRESENCE, props.variantOverwrite)
      ?.name
);
 
const introLocation = computed(() => {
  if (props.variantId === VARIANT_ID_VIDEO) {
    return props.t("appointmentDetailVideoIntroLocation");
  }
 
  if (props.variantId === VARIANT_ID_TELEPHONE) {
    return props.appointment?.telephone ?? "";
  }
 
  if (!props.selectedProvider) {
    return "";
  }
 
  return (
    props.selectedProvider.address.street +
    " " +
    props.selectedProvider.address.house_number
  );
});
 
const introLocationIcon = computed(() => {
  if (props.variantId === VARIANT_ID_TELEPHONE) {
    return "telephone";
  }
 
  if (props.variantId === VARIANT_ID_VIDEO) {
    return "video-camera";
  }
 
  return "map-pin";
});
 
const introLocationAriaLabel = computed(() => {
  if (
    props.variantId !== VARIANT_ID_TELEPHONE &&
    props.variantId !== VARIANT_ID_VIDEO &&
    props.selectedProvider
  ) {
    return props.selectedProvider.name;
  }
 
  return introLocation.value;
});
 
const emit =
  defineEmits<
    (
      e:
        | "cancelAppointment"
        | "focusLocation"
        | "focusTime"
        | "rescheduleAppointment"
    ) => void
  >();
 
const downloadIcsAppointment = () => {
  downloadIcsFile(props.appointment?.icsContent);
};
 
const cancelAppointment = () => emit("cancelAppointment");
const focusLocation = () => emit("focusLocation");
const focusTime = () => emit("focusTime");
const rescheduleAppointment = () => emit("rescheduleAppointment");
</script>
<style scoped>
.appointment-data {
  margin-top: 32px;
  margin-bottom: 16px;
}
 
.appointment-data p,
a {
  padding-bottom: 16px;
}
</style>
<style>
.m-intro-vertical__title {
  margin-bottom: 0 !important;
  white-space: pre-wrap !important;
}
</style>