diff --git a/frontend/app/(urls)/search/components/SearchCard.tsx b/frontend/app/(urls)/search/components/SearchCard.tsx index 526da6c..dc3e547 100644 --- a/frontend/app/(urls)/search/components/SearchCard.tsx +++ b/frontend/app/(urls)/search/components/SearchCard.tsx @@ -4,6 +4,25 @@ import Button from '@/components/ui/Button' import { SearchCardProps } from '@/app/types' import noPhoto from '../../../../public/images/noPhoto.png' +const formatDateTime = (dateTimeString: string): string => { + const date = new Date(dateTimeString) + const formatter = new Intl.DateTimeFormat('ru-RU', { + day: 'numeric', + month: 'long', + year: 'numeric', + }) + + const timeFormatter = new Intl.DateTimeFormat('ru-RU', { + hour: '2-digit', + minute: '2-digit', + }) + + const dateStr = formatter.format(date).replace(' г.', '') + const timeStr = timeFormatter.format(date) + + return `${dateStr}, ${timeStr}` +} + const SearchCard = ({ id, username, @@ -104,7 +123,9 @@ const SearchCard = ({ {userRequest === 'Могу перевезти' && (
Отправление:{' '} - {formatted_departure} + + {formatDateTime(formatted_departure)} +
)} @@ -136,7 +157,7 @@ const SearchCard = ({ {userRequest === 'Нужен перевозчик' && (
Дата доставки:{' '} - {formatted_arrival} + {formatDateTime(formatted_arrival)}
)} @@ -166,7 +187,9 @@ const SearchCard = ({ {userRequest === 'Могу перевезти' && (
Прибытие:{' '} - {formatted_arrival} + + {formatDateTime(formatted_arrival)} +
)} @@ -275,7 +298,7 @@ const SearchCard = ({ {userRequest === 'Могу перевезти' && (
Прибытие:{' '} - {formatted_arrival} + {formatDateTime(formatted_arrival)}
)}