feat: consulta pública de pedidos por código

This commit is contained in:
2026-08-09 23:48:55 -05:00
parent 7a7939e309
commit 1af4d2052d
24 changed files with 2639 additions and 33 deletions

View File

@@ -0,0 +1,79 @@
<template>
<div>
<v-list density="compact">
<v-list-item>
<template #prepend>
<v-icon>mdi-tag</v-icon>
</template>
<v-list-item-title>Código del pedido</v-list-item-title>
<v-list-item-subtitle>
<code class="order-code">{{ code }}</code>
</v-list-item-subtitle>
<template #append>
<v-btn
data-test="copy-code"
icon="mdi-content-copy"
size="small"
title="Copiar código"
variant="text"
@click="copyText(code)"
/>
</template>
</v-list-item>
<v-list-item>
<template #prepend>
<v-icon>mdi-link-variant</v-icon>
</template>
<v-list-item-title>Link de consulta</v-list-item-title>
<v-list-item-subtitle>
<code class="order-link">{{ publicLink }}</code>
</v-list-item-subtitle>
<template #append>
<v-btn
data-test="copy-link"
icon="mdi-content-copy"
size="small"
title="Copiar link"
variant="text"
@click="copyText(publicLink)"
/>
</template>
</v-list-item>
</v-list>
<v-snackbar v-model="snackbar" color="success" location="top" :timeout="2000">
Copiado
</v-snackbar>
</div>
</template>
<script setup>
import { computed, ref } from 'vue'
const props = defineProps({
code: {
type: String,
required: true,
},
})
const snackbar = ref(false)
const publicLink = computed(() => {
return `${window.location.origin}/pedido/${props.code}`
})
async function copyText (text) {
if (navigator.clipboard?.writeText) {
await navigator.clipboard.writeText(text)
}
snackbar.value = true
}
</script>
<style scoped>
.order-code,
.order-link {
word-break: break-all;
}
</style>

View File

@@ -0,0 +1,18 @@
<template>
<v-list-item v-if="customer">
<template #prepend>
<v-icon>mdi-account</v-icon>
</template>
<v-list-item-title>Cliente</v-list-item-title>
<v-list-item-subtitle>{{ customer.name }}</v-list-item-subtitle>
</v-list-item>
</template>
<script setup>
defineProps({
customer: {
type: Object,
default: null,
},
})
</script>

View File

@@ -0,0 +1,39 @@
<template>
<v-table density="compact">
<thead>
<tr>
<th class="text-left">Producto</th>
<th class="text-right">Precio</th>
<th class="text-right">Cantidad</th>
<th class="text-right">Subtotal</th>
</tr>
</thead>
<tbody>
<tr v-for="(line, index) in lines" :key="index">
<td>{{ line.product?.name }}</td>
<td class="text-right">
<CurrencyText :value="Number(line.unit_price)" />
</td>
<td class="text-right">{{ line.quantity }}</td>
<td class="text-right">
<CurrencyText :value="subtotal(line)" />
</td>
</tr>
</tbody>
</v-table>
</template>
<script setup>
import CurrencyText from '@/components/CurrencyText.vue'
defineProps({
lines: {
type: Array,
default: () => [],
},
})
function subtotal (line) {
return Number(line.unit_price || 0) * Number(line.quantity || 0)
}
</script>

View File

@@ -0,0 +1,18 @@
<template>
<v-list-item v-if="paymentMethod">
<template #prepend>
<v-icon>mdi-credit-card</v-icon>
</template>
<v-list-item-title>Pagado en</v-list-item-title>
<v-list-item-subtitle>{{ paymentMethod }}</v-list-item-subtitle>
</v-list-item>
</template>
<script setup>
defineProps({
paymentMethod: {
type: String,
default: '',
},
})
</script>

View File

@@ -0,0 +1,19 @@
<template>
<div class="d-flex justify-space-between align-center">
<span class="font-weight-bold">Total</span>
<span class="font-weight-bold">
<CurrencyText :value="total" />
</span>
</div>
</template>
<script setup>
import CurrencyText from '@/components/CurrencyText.vue'
defineProps({
total: {
type: Number,
required: true,
},
})
</script>