|
@@ -13,15 +13,15 @@
|
|
|
size="80px"
|
|
size="80px"
|
|
|
:style="avatarStyle"
|
|
:style="avatarStyle"
|
|
|
>
|
|
>
|
|
|
- {{ schedule.provider_name?.slice(0, 2).toUpperCase() ?? "??" }}
|
|
|
|
|
|
|
+ {{ displayProviderName.slice(0, 2).toUpperCase() || "??" }}
|
|
|
</q-avatar>
|
|
</q-avatar>
|
|
|
|
|
|
|
|
<div class="font16 fontbold provider-name">
|
|
<div class="font16 fontbold provider-name">
|
|
|
- {{ getFirstName(schedule.provider_name) || "—" }}
|
|
|
|
|
|
|
+ {{ getFirstName(displayProviderName) || "—" }}
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="font14 fontmedium text-text">
|
|
<div class="font14 fontmedium text-text">
|
|
|
- {{ schedule.address?.district || "" }}
|
|
|
|
|
|
|
+ {{ displayDistrict }}
|
|
|
</div>
|
|
</div>
|
|
|
</q-card-section>
|
|
</q-card-section>
|
|
|
|
|
|
|
@@ -40,7 +40,7 @@
|
|
|
</span>
|
|
</span>
|
|
|
|
|
|
|
|
<span class="detail-value">
|
|
<span class="detail-value">
|
|
|
- {{ formattedDate }}
|
|
|
|
|
|
|
+ {{ displayDate }}
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -50,9 +50,9 @@
|
|
|
</span>
|
|
</span>
|
|
|
|
|
|
|
|
<span class="detail-valued text-text">
|
|
<span class="detail-valued text-text">
|
|
|
- {{ schedule.start_time?.slice(0, 5) }}
|
|
|
|
|
|
|
+ {{ displayStartTime }}
|
|
|
{{ $t("dashboard_client.next_schedules.to") }}
|
|
{{ $t("dashboard_client.next_schedules.to") }}
|
|
|
- {{ schedule.end_time?.slice(0, 5) }}
|
|
|
|
|
|
|
+ {{ displayEndTime }}
|
|
|
</span>
|
|
</span>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
@@ -153,7 +153,8 @@ import SchedulePaymentDialog from "./SchedulePaymentDialog.vue";
|
|
|
import SchedulePaymentPixDialog from "./SchedulePaymentPixDialog.vue";
|
|
import SchedulePaymentPixDialog from "./SchedulePaymentPixDialog.vue";
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
const props = defineProps({
|
|
|
- schedule: { type: Object, required: true },
|
|
|
|
|
|
|
+ schedule: { type: Object, default: null },
|
|
|
|
|
+ servicePackage: { type: Object, default: null },
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
defineEmits([...useDialogPluginComponent.emits]);
|
|
@@ -166,38 +167,66 @@ const paymentStore = usePaymentStore();
|
|
|
|
|
|
|
|
const { platformFees, loadPlatformFees } = usePaymentPlatformFees();
|
|
const { platformFees, loadPlatformFees } = usePaymentPlatformFees();
|
|
|
|
|
|
|
|
|
|
+const isServicePackage = computed(() => !!props.servicePackage);
|
|
|
|
|
+const item = computed(() => props.servicePackage ?? props.schedule);
|
|
|
|
|
+
|
|
|
|
|
+const displayProviderName = computed(() => {
|
|
|
|
|
+ if (isServicePackage.value) {
|
|
|
|
|
+ return item.value.provider?.user?.name ?? item.value.provider_name ?? '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return item.value.provider_name ?? '';
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const displayDistrict = computed(() => {
|
|
|
|
|
+ if (isServicePackage.value) {
|
|
|
|
|
+ return item.value.schedules?.[0]?.address?.district ?? item.value.address?.district ?? '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return item.value.address?.district ?? '';
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const displayDate = computed(() => {
|
|
|
|
|
+ const src = isServicePackage.value ? item.value.schedules?.[0] : item.value;
|
|
|
|
|
+ if (!src) return '';
|
|
|
|
|
+ if (src.formatted_date) return src.formatted_date;
|
|
|
|
|
+ const raw = String(src.date || '');
|
|
|
|
|
+ const m = raw.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
|
|
|
+ if (!m) return raw;
|
|
|
|
|
+ const d = new Date(+m[1], +m[2] - 1, +m[3]);
|
|
|
|
|
+ return d.toLocaleDateString('pt-BR', {
|
|
|
|
|
+ day: '2-digit',
|
|
|
|
|
+ month: 'long',
|
|
|
|
|
+ year: 'numeric',
|
|
|
|
|
+ });
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const displayStartTime = computed(() => {
|
|
|
|
|
+ if (isServicePackage.value) {
|
|
|
|
|
+ return item.value.schedules?.[0]?.start_time?.slice(0, 5) ?? '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return item.value.start_time?.slice(0, 5) ?? '';
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
|
|
+const displayEndTime = computed(() => {
|
|
|
|
|
+ if (isServicePackage.value) {
|
|
|
|
|
+ return item.value.schedules?.[0]?.end_time?.slice(0, 5) ?? '';
|
|
|
|
|
+ }
|
|
|
|
|
+ return item.value.end_time?.slice(0, 5) ?? '';
|
|
|
|
|
+});
|
|
|
|
|
+
|
|
|
const avatarStyle = computed(
|
|
const avatarStyle = computed(
|
|
|
- () => avatarColors[props.schedule.id % avatarColors.length],
|
|
|
|
|
|
|
+ () => avatarColors[item.value.id % avatarColors.length],
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-const baseAmount = computed(() => Number(props.schedule.total_amount) || 0);
|
|
|
|
|
|
|
+const baseAmount = computed(() => Number(item.value.total_amount) || 0);
|
|
|
|
|
|
|
|
const creditCardTotal = computed(() =>
|
|
const creditCardTotal = computed(() =>
|
|
|
parseFloat((baseAmount.value + platformFee("credit_card")).toFixed(2)),
|
|
parseFloat((baseAmount.value + platformFee("credit_card")).toFixed(2)),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
const hasServicePackageDiscount = computed(() =>
|
|
const hasServicePackageDiscount = computed(() =>
|
|
|
- scheduleUsesServicePackageDiscount(props.schedule),
|
|
|
|
|
|
|
+ scheduleUsesServicePackageDiscount(item.value),
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
-const formattedDate = computed(() => {
|
|
|
|
|
- if (props.schedule.formatted_date) return props.schedule.formatted_date;
|
|
|
|
|
-
|
|
|
|
|
- const raw = String(props.schedule.date || "");
|
|
|
|
|
-
|
|
|
|
|
- const m = raw.match(/^(\d{4})-(\d{2})-(\d{2})/);
|
|
|
|
|
-
|
|
|
|
|
- if (!m) return raw;
|
|
|
|
|
-
|
|
|
|
|
- const d = new Date(+m[1], +m[2] - 1, +m[3]);
|
|
|
|
|
-
|
|
|
|
|
- return d.toLocaleDateString("pt-BR", {
|
|
|
|
|
- day: "2-digit",
|
|
|
|
|
- month: "long",
|
|
|
|
|
- year: "numeric",
|
|
|
|
|
- });
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
const pixDiscount = computed(() =>
|
|
const pixDiscount = computed(() =>
|
|
|
Math.max(0, parseFloat((creditCardTotal.value - pixTotal.value).toFixed(2))),
|
|
Math.max(0, parseFloat((creditCardTotal.value - pixTotal.value).toFixed(2))),
|
|
|
);
|
|
);
|
|
@@ -207,7 +236,7 @@ const pixTotal = computed(() =>
|
|
|
|
|
|
|
|
const platformFee = (paymentType) => {
|
|
const platformFee = (paymentType) => {
|
|
|
const feeRate = getSchedulePlatformFeeRate(
|
|
const feeRate = getSchedulePlatformFeeRate(
|
|
|
- props.schedule,
|
|
|
|
|
|
|
+ item.value,
|
|
|
paymentType,
|
|
paymentType,
|
|
|
platformFees.value,
|
|
platformFees.value,
|
|
|
);
|
|
);
|
|
@@ -216,16 +245,20 @@ const platformFee = (paymentType) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const onGoToPayment = () => {
|
|
const onGoToPayment = () => {
|
|
|
- const hasValidPixPayment = !!paymentStore.getValidPixPayment(
|
|
|
|
|
- props.schedule.id,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ const validPixPayment = isServicePackage.value
|
|
|
|
|
+ ? paymentStore.getValidPixPaymentForServicePackage(item.value.id)
|
|
|
|
|
+ : paymentStore.getValidPixPayment(item.value.id);
|
|
|
|
|
+
|
|
|
|
|
+ const hasValidPixPayment = !!validPixPayment;
|
|
|
|
|
|
|
|
$q.dialog({
|
|
$q.dialog({
|
|
|
component: hasValidPixPayment
|
|
component: hasValidPixPayment
|
|
|
? SchedulePaymentPixDialog
|
|
? SchedulePaymentPixDialog
|
|
|
: SchedulePaymentDialog,
|
|
: SchedulePaymentDialog,
|
|
|
componentProps: {
|
|
componentProps: {
|
|
|
- schedule: props.schedule,
|
|
|
|
|
|
|
+ ...(isServicePackage.value
|
|
|
|
|
+ ? { servicePackage: item.value }
|
|
|
|
|
+ : { schedule: item.value }),
|
|
|
...(hasValidPixPayment ? { total: pixTotal.value } : {}),
|
|
...(hasValidPixPayment ? { total: pixTotal.value } : {}),
|
|
|
},
|
|
},
|
|
|
}).onOk(() => {
|
|
}).onOk(() => {
|