diff --git a/app/pages/client-orders/index.vue b/app/pages/client-orders/index.vue
index 52a29c1..16e4994 100644
--- a/app/pages/client-orders/index.vue
+++ b/app/pages/client-orders/index.vue
@@ -10,6 +10,8 @@ import {
type ManagerUsersQuery,
} from '~/composables/graphql/generated';
import { messengerConnectionAvatarSrc } from '~/composables/useMessengerConnectionPresentation';
+import { formatOrderCode } from '~/composables/useOrderCodePresentation';
+import { formatPrice } from '~/composables/useOrderDetailPresentation';
definePageMeta({
middleware: ['manager-only'],
@@ -52,6 +54,7 @@ function customerCardMeta(customerId: string) {
return {
name: customerId,
avatarSrc: '',
+ fallbackAvatarSrc: '/favicon.ico',
initials: customerId.slice(0, 2).toUpperCase(),
};
}
@@ -59,6 +62,7 @@ function customerCardMeta(customerId: string) {
return {
name: customer.fullName,
avatarSrc: messengerConnectionAvatarSrc(customer.telegramConnection),
+ fallbackAvatarSrc: '/favicon.ico',
initials: customer.fullName
.split(/\s+/)
.filter(Boolean)
@@ -95,6 +99,7 @@ const searchedOrders = computed
(() => {
return orders.filter((order) => {
const text = [
order.code,
+ formatOrderCode(order.code),
order.customerId,
customerCardMeta(order.customerId).name,
order.deliveryAddress || '',
@@ -109,6 +114,15 @@ const searchedOrders = computed(() => {
const filteredOrders = computed(() => searchedOrders.value.filter((order) => matchesFilter(order)));
+function escapeHtml(value: string) {
+ return String(value)
+ .replaceAll('&', '&')
+ .replaceAll('<', '<')
+ .replaceAll('>', '>')
+ .replaceAll('"', '"')
+ .replaceAll("'", ''');
+}
+
const statusTabs = computed>(() => [
{
id: 'ALL',
@@ -152,12 +166,50 @@ const calendarOptions = computed(() => ({
buttonText: {
today: 'Сегодня',
},
- events: filteredOrders.value.map((order: ManagerOrderItem) => ({
- id: order.id,
- title: `${order.code} • ${order.customerId}`,
- start: new Date(order.createdAt).toISOString(),
- allDay: true,
- })),
+ events: filteredOrders.value.map((order: ManagerOrderItem) => {
+ const customer = customerCardMeta(order.customerId);
+
+ return {
+ id: order.id,
+ title: formatOrderCode(order.code),
+ start: new Date(order.createdAt).toISOString(),
+ allDay: true,
+ extendedProps: {
+ customerName: customer.name,
+ avatarSrc: customer.avatarSrc,
+ fallbackAvatarSrc: customer.fallbackAvatarSrc,
+ initials: customer.initials,
+ orderCode: formatOrderCode(order.code),
+ totalPriceLabel: formatPrice(order.totalPrice) ?? 'Цена уточняется',
+ },
+ };
+ }),
+ eventContent: ({ event }: { event: { extendedProps: Record } }) => {
+ const customerName = escapeHtml(event.extendedProps.customerName || '');
+ const avatarSrc = event.extendedProps.avatarSrc || event.extendedProps.fallbackAvatarSrc;
+ const orderCode = escapeHtml(event.extendedProps.orderCode || '');
+ const totalPriceLabel = escapeHtml(event.extendedProps.totalPriceLabel || '');
+ const initials = escapeHtml(event.extendedProps.initials || '');
+
+ return {
+ html: `
+
+ `,
+ };
+ },
eventClick: ({ event }: { event: { id: string } }) => {
void router.push(`/client-orders/${event.id}`);
},
@@ -238,3 +290,82 @@ const calendarOptions = computed(() => ({