|
|
@@ -0,0 +1,163 @@
|
|
|
+<template>
|
|
|
+ <q-dialog ref="dialogRef" @hide="onDialogHide">
|
|
|
+ <q-card class="q-dialog-plugin column" style="width: 700px; max-width: 95vw; max-height: 90vh;">
|
|
|
+ <DefaultDialogHeader :title="() => $t('provider.approval.dialog_title')" @close="onDialogCancel" />
|
|
|
+
|
|
|
+ <div class="col scroll q-pa-md">
|
|
|
+ <div class="row items-center q-mb-md">
|
|
|
+ <q-badge
|
|
|
+ :color="statusColor"
|
|
|
+ :label="$t(`provider.approval_status.${provider.approval_status}`)"
|
|
|
+ class="text-body2 q-pa-sm"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="text-subtitle1 text-weight-bold q-mb-sm">{{ $t('provider.approval.section_personal') }}</div>
|
|
|
+ <q-list bordered separator class="rounded-borders q-mb-md">
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('common.terms.name') }}</q-item-label>
|
|
|
+ <q-item-label>{{ provider.user?.name || '—' }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('common.terms.email') }}</q-item-label>
|
|
|
+ <q-item-label>{{ provider.user?.email || '—' }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.document') }}</q-item-label>
|
|
|
+ <q-item-label>{{ provider.document || '—' }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.rg') }}</q-item-label>
|
|
|
+ <q-item-label>{{ provider.rg || '—' }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.birth_date') }}</q-item-label>
|
|
|
+ <q-item-label>{{ provider.birth_date || '—' }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ </q-list>
|
|
|
+
|
|
|
+ <div class="text-subtitle1 text-weight-bold q-mb-sm">{{ $t('provider.approval.section_pricing') }}</div>
|
|
|
+ <q-list bordered separator class="rounded-borders q-mb-md">
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.daily_price_8h') }}</q-item-label>
|
|
|
+ <q-item-label>{{ formatCurrency(provider.daily_price_8h) }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.daily_price_6h') }}</q-item-label>
|
|
|
+ <q-item-label>{{ formatCurrency(provider.daily_price_6h) }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.daily_price_4h') }}</q-item-label>
|
|
|
+ <q-item-label>{{ formatCurrency(provider.daily_price_4h) }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ <q-item>
|
|
|
+ <q-item-section>
|
|
|
+ <q-item-label caption>{{ $t('provider.fields.daily_price_2h') }}</q-item-label>
|
|
|
+ <q-item-label>{{ formatCurrency(provider.daily_price_2h) }}</q-item-label>
|
|
|
+ </q-item-section>
|
|
|
+ </q-item>
|
|
|
+ </q-list>
|
|
|
+
|
|
|
+ <div class="text-caption text-grey-6">
|
|
|
+ {{ $t('common.terms.created_at') + ': ' + (provider.created_at || '—') }}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <q-card-actions align="right" class="q-pa-md">
|
|
|
+ <q-btn
|
|
|
+ flat
|
|
|
+ :label="$t('common.actions.cancel')"
|
|
|
+ color="grey-7"
|
|
|
+ @click="onDialogCancel"
|
|
|
+ />
|
|
|
+ <q-btn
|
|
|
+ v-if="provider.approval_status !== 'rejected'"
|
|
|
+ unelevated
|
|
|
+ :label="$t('provider.approval.btn_reject')"
|
|
|
+ color="negative"
|
|
|
+ :loading="loadingReject"
|
|
|
+ @click="onReject"
|
|
|
+ />
|
|
|
+ <q-btn
|
|
|
+ v-if="provider.approval_status !== 'accepted'"
|
|
|
+ unelevated
|
|
|
+ :label="$t('provider.approval.btn_approve')"
|
|
|
+ color="positive"
|
|
|
+ :loading="loadingApprove"
|
|
|
+ @click="onApprove"
|
|
|
+ />
|
|
|
+ </q-card-actions>
|
|
|
+ </q-card>
|
|
|
+ </q-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup>
|
|
|
+import { computed, ref } from "vue";
|
|
|
+import { useDialogPluginComponent, useQuasar } from "quasar";
|
|
|
+import { useI18n } from "vue-i18n";
|
|
|
+import { approveProvider, rejectProvider } from "src/api/provider";
|
|
|
+import DefaultDialogHeader from "src/components/defaults/DefaultDialogHeader.vue";
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ provider: { type: Object, required: true },
|
|
|
+});
|
|
|
+
|
|
|
+defineEmits([...useDialogPluginComponent.emits]);
|
|
|
+const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent();
|
|
|
+
|
|
|
+const $q = useQuasar();
|
|
|
+const { t } = useI18n();
|
|
|
+
|
|
|
+const loadingApprove = ref(false);
|
|
|
+const loadingReject = ref(false);
|
|
|
+
|
|
|
+const statusColor = computed(() => {
|
|
|
+ const map = { pending: "warning", accepted: "positive", rejected: "negative" };
|
|
|
+ return map[props.provider.approval_status] ?? "grey";
|
|
|
+});
|
|
|
+
|
|
|
+const formatCurrency = (value) => {
|
|
|
+ if (!value) return "—";
|
|
|
+ return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value);
|
|
|
+};
|
|
|
+
|
|
|
+const onApprove = async () => {
|
|
|
+ loadingApprove.value = true;
|
|
|
+ try {
|
|
|
+ await approveProvider(props.provider.id);
|
|
|
+ onDialogOK({ action: "approved" });
|
|
|
+ } catch {
|
|
|
+ $q.notify({ type: "negative", message: t("http.errors.failed"), position: "top" });
|
|
|
+ } finally {
|
|
|
+ loadingApprove.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const onReject = async () => {
|
|
|
+ loadingReject.value = true;
|
|
|
+ try {
|
|
|
+ await rejectProvider(props.provider.id);
|
|
|
+ onDialogOK({ action: "rejected" });
|
|
|
+ } catch {
|
|
|
+ $q.notify({ type: "negative", message: t("http.errors.failed"), position: "top" });
|
|
|
+ } finally {
|
|
|
+ loadingReject.value = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|