|
|
@@ -11,8 +11,12 @@
|
|
|
<q-separator class="q-mt-sm" />
|
|
|
|
|
|
<q-card-section class="q-pt-sm q-pb-md">
|
|
|
+ <div v-if="availableServiceTypes.length === 0" class="text-center text-grey-6 text-body2 q-py-md">
|
|
|
+ {{ $t('scheduling_page.no_slots_available') }}
|
|
|
+ </div>
|
|
|
+
|
|
|
<div
|
|
|
- v-for="type in serviceTypes"
|
|
|
+ v-for="type in availableServiceTypes"
|
|
|
:key="type.key"
|
|
|
class="row items-center no-wrap q-py-sm"
|
|
|
>
|
|
|
@@ -61,6 +65,7 @@ import ServiceTypeInfoDialog from './ServiceTypeInfoDialog.vue';
|
|
|
const props = defineProps({
|
|
|
provider: { type: Object, required: true },
|
|
|
selectedDate: { type: String, required: true },
|
|
|
+ partialBlocks: { type: Array, required: false, default: () => [] },
|
|
|
});
|
|
|
|
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
|
@@ -69,40 +74,56 @@ const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginC
|
|
|
const $q = useQuasar();
|
|
|
const { t } = useI18n();
|
|
|
|
|
|
-const serviceTypes = computed(() => [
|
|
|
- {
|
|
|
- key: 'integral',
|
|
|
- hoursCount: 8,
|
|
|
- label: t('scheduling_page.service_types.integral.label'),
|
|
|
- hours: t('scheduling_page.service_types.integral.hours'),
|
|
|
- description: t('scheduling_page.service_types.integral.description'),
|
|
|
- price: props.provider?.daily_price_8h ?? null,
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'padrao',
|
|
|
- hoursCount: 6,
|
|
|
- label: t('scheduling_page.service_types.padrao.label'),
|
|
|
- hours: t('scheduling_page.service_types.padrao.hours'),
|
|
|
- description: t('scheduling_page.service_types.padrao.description'),
|
|
|
- price: props.provider?.daily_price_6h ?? null,
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'meio_periodo',
|
|
|
- hoursCount: 4,
|
|
|
- label: t('scheduling_page.service_types.meio_periodo.label'),
|
|
|
- hours: t('scheduling_page.service_types.meio_periodo.hours'),
|
|
|
- description: t('scheduling_page.service_types.meio_periodo.description'),
|
|
|
- price: props.provider?.daily_price_4h ?? null,
|
|
|
- },
|
|
|
- {
|
|
|
- key: 'diaria_rapida',
|
|
|
- hoursCount: 2,
|
|
|
- label: t('scheduling_page.service_types.diaria_rapida.label'),
|
|
|
- hours: t('scheduling_page.service_types.diaria_rapida.hours'),
|
|
|
- description: t('scheduling_page.service_types.diaria_rapida.description'),
|
|
|
- price: props.provider?.daily_price_2h ?? null,
|
|
|
- },
|
|
|
-]);
|
|
|
+const slotConflicts = (slotStart, slotEnd, blocks) =>
|
|
|
+ blocks.some(b => {
|
|
|
+ const blockStart = parseInt(b.init_hour);
|
|
|
+ const blockEnd = parseInt(b.end_hour);
|
|
|
+ return slotEnd >= blockStart && slotStart <= blockEnd;
|
|
|
+ });
|
|
|
+
|
|
|
+const hasValidSlots = (hoursCount) => {
|
|
|
+ for (let s = 7; s + hoursCount <= 20; s++) {
|
|
|
+ if (!slotConflicts(s, s + hoursCount, props.partialBlocks)) return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+};
|
|
|
+
|
|
|
+const availableServiceTypes = computed(() =>
|
|
|
+ [
|
|
|
+ {
|
|
|
+ key: 'integral',
|
|
|
+ hoursCount: 8,
|
|
|
+ label: t('scheduling_page.service_types.integral.label'),
|
|
|
+ hours: t('scheduling_page.service_types.integral.hours'),
|
|
|
+ description: t('scheduling_page.service_types.integral.description'),
|
|
|
+ price: props.provider?.daily_price_8h ?? null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'padrao',
|
|
|
+ hoursCount: 6,
|
|
|
+ label: t('scheduling_page.service_types.padrao.label'),
|
|
|
+ hours: t('scheduling_page.service_types.padrao.hours'),
|
|
|
+ description: t('scheduling_page.service_types.padrao.description'),
|
|
|
+ price: props.provider?.daily_price_6h ?? null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'meio_periodo',
|
|
|
+ hoursCount: 4,
|
|
|
+ label: t('scheduling_page.service_types.meio_periodo.label'),
|
|
|
+ hours: t('scheduling_page.service_types.meio_periodo.hours'),
|
|
|
+ description: t('scheduling_page.service_types.meio_periodo.description'),
|
|
|
+ price: props.provider?.daily_price_4h ?? null,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'diaria_rapida',
|
|
|
+ hoursCount: 2,
|
|
|
+ label: t('scheduling_page.service_types.diaria_rapida.label'),
|
|
|
+ hours: t('scheduling_page.service_types.diaria_rapida.hours'),
|
|
|
+ description: t('scheduling_page.service_types.diaria_rapida.description'),
|
|
|
+ price: props.provider?.daily_price_2h ?? null,
|
|
|
+ },
|
|
|
+ ].filter(type => hasValidSlots(type.hoursCount))
|
|
|
+);
|
|
|
|
|
|
const formatPrice = (value) =>
|
|
|
Number(value).toLocaleString('pt-BR', { style: 'currency', currency: 'BRL' });
|