Skip to content

Commit

Permalink
fix order detail
Browse files Browse the repository at this point in the history
  • Loading branch information
1that committed Dec 21, 2024
1 parent 2dafcaa commit b8694dc
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions frontend/src/ui/uikit/items/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,33 @@
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'
import Order from '../../../api/models/order'
import { getOrderById } from '../../../api/request';
import { getOrderById } from '../../../api/request'
const route = useRoute();
const orderId = route.params.id as string;
const order = ref<Order>();
const route = useRoute()
const orderId = route.params.order_id as string
const order = ref<Order | null>(null)
onMounted(() => {
getOrderById(orderId)
.then((response) => {
order.value = response
console.log(order.value)
const date = new Date(order.value.date_time)
order.value.date_time = date
})
})
function formatDate(dateTime: string): string {
const date = new Date(dateTime);
const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1;
const minutes = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes();
return `${date.getDate()}.${month}.${date.getFullYear()} ${date.getHours()}:${minutes}`;
const date = new Date(dateTime)
const month = date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1
const minutes = date.getMinutes() < 10 ? `0${date.getMinutes()}` : date.getMinutes()
return `${date.getDate()}.${month}.${date.getFullYear()} ${date.getHours()}:${minutes}`
}
</script>

<template>
<div class="order-detail">
<div v-if="order" class="order-detail">
<h1>Детали заказа</h1>
<p>Заказ по адресу: {{ order!.address.city }}, {{ order!.address.street }}, дом {{ order!.address.building }}, подъезд {{ order!.address.entrance }}, этаж {{ order!.address.floor }}, квартира {{ order!.address.door_number }}</p>
<p>На дату: {{ formatDate(order!.date_time.toISOString()) }}</p>
Expand Down

0 comments on commit b8694dc

Please sign in to comment.