order-card: show date

This commit is contained in:
vchikalkin 2025-06-26 15:06:21 +03:00
parent aa347fb032
commit 7f6539d10a
2 changed files with 7 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import { ReadonlyTimeRange } from './time-range/readonly';
import { getBadge } from '@/components/shared/status';
import type * as GQL from '@repo/graphql/types';
import { Avatar, AvatarFallback, AvatarImage } from '@repo/ui/components/ui/avatar';
import { formatDate } from '@repo/utils/datetime-format';
import Link from 'next/link';
type OrderComponentProps = GQL.OrderFieldsFragment & {
@ -14,6 +15,7 @@ type OrderCustomer = GQL.CustomerFieldsFragment;
export function OrderCard({ avatarSource, documentId, ...order }: Readonly<OrderComponentProps>) {
const services = order?.services.map((service) => service?.name).join(', ');
const date = order?.slot?.date;
const customer = avatarSource === 'master' ? order?.slot?.master : order?.client;
@ -25,7 +27,9 @@ export function OrderCard({ avatarSource, documentId, ...order }: Readonly<Order
{customer && <CustomerAvatar customer={customer} />}
<div className="flex flex-col">
<ReadonlyTimeRange timeEnd={order?.time_end} timeStart={order?.time_start} />
<span className="truncate text-xs text-muted-foreground">{services}</span>
<span className="truncate text-xs text-muted-foreground">
{formatDate(date).user('DD.MM.YYYY')} {services}
</span>
</div>
{/* <span className="text-xs text-foreground">{clientName}</span> */}
</div>

View File

@ -20,10 +20,10 @@ export function formatDate(date: Date | string) {
return {
db: () => dayjs(date).format('YYYY-MM-DD'),
user: () => {
user: (template?: string) => {
const lang = document.documentElement.lang || 'ru';
dayjs.locale(lang);
return dayjs(date).format('D MMMM YYYY');
return dayjs(date).format(template || 'D MMMM YYYY');
},
};
}