tipsEnabled set
This commit is contained in:
@@ -6,10 +6,6 @@
|
||||
@close="dismissReview"
|
||||
>
|
||||
<div class="space-y-6">
|
||||
<p class="text-center text-sm text-muted">
|
||||
خدمت: {{ activeReview?.serviceTitle ?? '—' }}
|
||||
</p>
|
||||
|
||||
<StarRating v-model="rating" />
|
||||
|
||||
<template v-if="activeReview?.tipsEnabled">
|
||||
@@ -64,12 +60,10 @@
|
||||
@close="closeTipModal"
|
||||
>
|
||||
<form class="space-y-4" @submit.prevent="submitTip">
|
||||
<AppInput
|
||||
<PriceInput
|
||||
id="tipAmount"
|
||||
v-model="tipAmountInput"
|
||||
label="مبلغ (تومان)"
|
||||
inputmode="numeric"
|
||||
ltr
|
||||
placeholder="مثلاً ۵۰٬۰۰۰"
|
||||
required
|
||||
/>
|
||||
@@ -79,10 +73,26 @@
|
||||
</AppButton>
|
||||
</form>
|
||||
</AppModal>
|
||||
|
||||
<AppModal
|
||||
:open="tipSuccessOpen"
|
||||
title="پرداخت موفق"
|
||||
@close="closeTipSuccess"
|
||||
>
|
||||
<div class="space-y-4 text-center">
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
پرداخت شما با موفقیت انجام شد.
|
||||
</p>
|
||||
<AppButton class="w-full" @click="closeTipSuccess">
|
||||
باشه
|
||||
</AppButton>
|
||||
</div>
|
||||
</AppModal>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import {
|
||||
fetchPendingReviews,
|
||||
initiateBookingTip,
|
||||
@@ -92,17 +102,20 @@ import {
|
||||
import { ApiError } from '@/api/client';
|
||||
import StarRating from '@/components/booking/StarRating.vue';
|
||||
import AppButton from '@/components/ui/AppButton.vue';
|
||||
import AppInput from '@/components/ui/AppInput.vue';
|
||||
import AppModal from '@/components/ui/AppModal.vue';
|
||||
import PriceInput from '@/components/ui/PriceInput.vue';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { parsePriceInput } from '@/utils/format';
|
||||
|
||||
const auth = useAuthStore();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
const pending = ref<PendingBookingReview[]>([]);
|
||||
const activeReview = ref<PendingBookingReview | null>(null);
|
||||
const reviewOpen = ref(false);
|
||||
const tipOpen = ref(false);
|
||||
const tipSuccessOpen = ref(false);
|
||||
const rating = ref(0);
|
||||
const error = ref('');
|
||||
const submitting = ref(false);
|
||||
@@ -157,6 +170,29 @@ function closeTipModal() {
|
||||
tipError.value = '';
|
||||
}
|
||||
|
||||
function showTipSuccess() {
|
||||
tipSuccessOpen.value = true;
|
||||
}
|
||||
|
||||
function closeTipSuccess() {
|
||||
tipSuccessOpen.value = false;
|
||||
}
|
||||
|
||||
function handleTipQuery() {
|
||||
const raw = route.query.tip;
|
||||
if (raw !== 'success' && raw !== 'failed') return;
|
||||
|
||||
if (raw === 'success') {
|
||||
showTipSuccess();
|
||||
} else {
|
||||
tipError.value = 'پرداخت ناموفق بود.';
|
||||
}
|
||||
|
||||
const nextQuery = { ...route.query };
|
||||
delete nextQuery.tip;
|
||||
void router.replace({ query: nextQuery });
|
||||
}
|
||||
|
||||
async function submitWithoutTip() {
|
||||
if (!activeReview.value || !rating.value) return;
|
||||
submitting.value = true;
|
||||
@@ -193,7 +229,7 @@ async function submitTip() {
|
||||
pending.value = pending.value.filter((item) => item.bookingId !== bookingId);
|
||||
activeReview.value = pending.value[0] ?? null;
|
||||
if (result.mock) {
|
||||
if (activeReview.value) reviewOpen.value = true;
|
||||
showTipSuccess();
|
||||
return;
|
||||
}
|
||||
window.location.href = result.startUrl;
|
||||
@@ -212,6 +248,14 @@ watch(
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
handleTipQuery();
|
||||
void loadPending();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route.query.tip,
|
||||
() => {
|
||||
handleTipQuery();
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user