262 lines
11 KiB
TypeScript
262 lines
11 KiB
TypeScript
import React from 'react'
|
||
import Image from 'next/image'
|
||
import Button from '@/components/ui/Button'
|
||
import { SearchCardProps } from '@/app/types/index'
|
||
|
||
const SearchCard = ({
|
||
id,
|
||
username,
|
||
userImg,
|
||
start_point,
|
||
country_from,
|
||
country_from_icon,
|
||
country_from_code,
|
||
end_point,
|
||
country_to,
|
||
country_to_icon,
|
||
country_to_code,
|
||
cargo_type,
|
||
user_request,
|
||
user_comment,
|
||
moving_type,
|
||
estimated_date,
|
||
day_out,
|
||
day_in,
|
||
}: SearchCardProps) => {
|
||
const getUserRequestStyles = () => {
|
||
if (user_request === 'Нужен перевозчик') {
|
||
return 'text-[#065bff]'
|
||
}
|
||
return 'text-[#45c226]'
|
||
}
|
||
|
||
const setMovingTypeIcon = () => {
|
||
if (moving_type === 'Авиатранспорт') {
|
||
return '/images/airplane.png'
|
||
}
|
||
return '/images/car.png'
|
||
}
|
||
|
||
return (
|
||
<>
|
||
{/* десктоп */}
|
||
<div className="hidden sm:block">
|
||
<div className="my-4 w-full rounded-xl bg-white p-6 shadow-lg">
|
||
<div className="mb-4 flex items-center justify-between">
|
||
<div className="flex items-center gap-5">
|
||
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-gray-200">
|
||
<Image
|
||
src={userImg}
|
||
alt={username}
|
||
width={52}
|
||
height={52}
|
||
className="rounded-full object-cover"
|
||
/>
|
||
</div>
|
||
<div className="flex items-center gap-3">
|
||
<div className="text-base font-semibold">{username}</div>
|
||
<div className="text-gray-500">|</div>
|
||
<div className={`text-base font-semibold ${getUserRequestStyles()}`}>
|
||
{user_request}
|
||
</div>
|
||
<div className="ml-1">
|
||
Тип посылки: <span className="text-orange ml-1 font-semibold">{cargo_type}</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<Button
|
||
text="Откликнуться"
|
||
className="bg-orange hover:bg-orange/80 cursor-pointer px-10 py-3 text-base font-semibold text-white transition-colors"
|
||
/>
|
||
</div>
|
||
|
||
<div className="rounded-lg bg-[#f8f8f8] p-5">
|
||
<div className="flex items-baseline gap-2">
|
||
<span className="text-gray-600">{user_comment}</span>
|
||
</div>
|
||
</div>
|
||
<div className="flex justify-end pt-2 text-sm text-gray-500">Объявление № {id}</div>
|
||
|
||
<div className="mt-6 flex items-center justify-between">
|
||
<div className="flex flex-col">
|
||
{user_request === 'Нужен перевозчик' ? (
|
||
<span className="text-gray-500">Забрать из:</span>
|
||
) : (
|
||
<span className="text-gray-500">Выезжаю из:</span>
|
||
)}
|
||
<div className="flex flex-col">
|
||
<div className="flex items-center">
|
||
<Image src={country_from_icon} width={26} height={13} alt={country_from_code} />
|
||
<span className="pr-2 pl-1 text-gray-400">{country_from_code}</span>
|
||
<span className="text-base font-semibold">
|
||
{start_point} / {country_from}
|
||
</span>
|
||
</div>
|
||
{user_request === 'Могу перевезти' && (
|
||
<div className="mt-1 text-sm text-gray-500">
|
||
<span className="text-sm font-normal">Отправление:</span>{' '}
|
||
<span className="text-sm font-semibold">{day_out?.toLocaleDateString()}</span>
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
|
||
<div className="text-center">
|
||
<div className="flex items-center justify-center gap-2">
|
||
<span className="text-base font-semibold">{moving_type}</span>
|
||
<Image
|
||
src={setMovingTypeIcon()}
|
||
width={15}
|
||
height={15}
|
||
alt="route vector"
|
||
className="h-[15px] w-[15px] object-contain"
|
||
/>
|
||
</div>
|
||
<div className="mx-auto my-1 flex w-[500px] items-center justify-between">
|
||
<Image
|
||
src="/images/vector.svg"
|
||
width={500}
|
||
height={6}
|
||
alt="route vector"
|
||
className="absolute"
|
||
/>
|
||
<div className="relative z-10 h-5 w-5 rounded-full border-3 border-[#065bff] bg-white" />
|
||
<div className="relative z-10 h-5 w-5 rounded-full border-3 border-[#45c226] bg-white" />
|
||
</div>
|
||
|
||
{user_request === 'Нужен перевозчик' && (
|
||
<div className="text-sm text-gray-500">
|
||
<span className="text-sm font-normal">Дата доставки:</span>{' '}
|
||
<span className="text-sm font-semibold">
|
||
{estimated_date.toLocaleDateString()}
|
||
</span>
|
||
</div>
|
||
)}
|
||
</div>
|
||
|
||
<div className="-mb-[14px] flex flex-col">
|
||
{user_request === 'Нужен перевозчик' ? (
|
||
<div className="text-base text-gray-500">Доставить в:</div>
|
||
) : (
|
||
<div className="text-base text-gray-500">Прибываю в:</div>
|
||
)}
|
||
|
||
<div className="flex flex-col">
|
||
<div className="flex items-center">
|
||
<Image src={country_to_icon} width={26} height={13} alt={country_to_code} />
|
||
<span className="pr-2 pl-1 text-gray-400">{country_to_code}</span>
|
||
<span className="text-base font-semibold">
|
||
{end_point} / {country_to}
|
||
</span>
|
||
</div>
|
||
{user_request === 'Могу перевезти' && (
|
||
<div className="text-sm text-gray-500">
|
||
<span className="text-sm font-normal">Прибытие:</span>{' '}
|
||
<span className="text-sm font-semibold">{day_in?.toLocaleDateString()}</span>
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
{/* мобилка */}
|
||
<div className="block sm:hidden">
|
||
<div className="my-4 w-full rounded-xl bg-white p-4 shadow-lg">
|
||
<div className="flex items-center justify-between">
|
||
<div className={`text-sm font-semibold ${getUserRequestStyles()}`}>{user_request}</div>
|
||
<div className="text-sm font-semibold">
|
||
Тип посылки: <span className="text-orange">{cargo_type}</span>
|
||
</div>
|
||
</div>
|
||
<div className="mt-5 mb-2 flex flex-row items-center justify-between gap-3">
|
||
<div className="flex h-16 w-16 min-w-[64px] shrink-0 items-center justify-center rounded-full bg-gray-200">
|
||
<Image
|
||
src={userImg}
|
||
alt={username}
|
||
width={52}
|
||
height={52}
|
||
className="aspect-square h-[52px] w-[52px] rounded-full object-cover"
|
||
/>
|
||
</div>
|
||
<div className="flex-1 rounded-lg bg-[#f8f8f8] p-4 text-sm font-normal">
|
||
{user_comment}
|
||
</div>
|
||
</div>
|
||
<div className="flex justify-end text-xs text-gray-500">Объявление № {id}</div>
|
||
|
||
{user_request === 'Нужен перевозчик' ? (
|
||
<span className="pl-7 text-sm text-gray-500">Забрать из:</span>
|
||
) : (
|
||
<span className="pl-7 text-sm text-gray-500">Выезжаю из:</span>
|
||
)}
|
||
<div className="mt-4 mb-2 flex flex-row items-stretch gap-4">
|
||
<div className="relative flex h-[150px] flex-col items-center">
|
||
<div className="relative flex h-full w-[10px] items-center justify-center">
|
||
<Image
|
||
src="/images/vectormob.png"
|
||
width={6}
|
||
height={100}
|
||
alt="route vector"
|
||
className="absolute h-[150px] w-auto"
|
||
/>
|
||
<div className="absolute -top-[10px] z-10 h-4 w-4 rounded-full border-3 border-[#065bff] bg-white" />
|
||
<div className="absolute -bottom-[10px] z-10 h-4 w-4 rounded-full border-3 border-[#45c226] bg-white" />
|
||
</div>
|
||
</div>
|
||
<div className="flex flex-1 flex-col justify-between">
|
||
<div className="-mt-[14px] flex items-center">
|
||
<Image src={country_from_icon} width={26} height={13} alt={country_from_code} />
|
||
<span className="pr-2 pl-1 text-sm text-gray-400">{country_from_code}</span>
|
||
<span className="text-base font-semibold">
|
||
{start_point} / {country_from}
|
||
</span>
|
||
</div>
|
||
|
||
<div className="flex flex-col">
|
||
<div className="flex items-center gap-4">
|
||
<span className="text-base">{moving_type}</span>
|
||
<Image
|
||
src={setMovingTypeIcon()}
|
||
width={15}
|
||
height={15}
|
||
alt="route vector"
|
||
className="h-[15px] w-[15px] object-contain"
|
||
/>
|
||
</div>
|
||
<div className="my-2 h-[2px] w-[165px] bg-gray-200" />
|
||
<div className="text-sm">Дата доставки: {estimated_date.toLocaleDateString()}</div>
|
||
</div>
|
||
|
||
<div className="-mb-[14px] flex flex-col">
|
||
{user_request === 'Нужен перевозчик' ? (
|
||
<div className="text-sm text-gray-500">Доставить в:</div>
|
||
) : (
|
||
<div className="text-sm text-gray-500">Прибываю в:</div>
|
||
)}
|
||
|
||
<div className="flex items-center">
|
||
<Image src={country_to_icon} width={26} height={13} alt={country_to_code} />
|
||
<span className="pr-2 pl-1 text-gray-400">{country_to_code}</span>
|
||
<span className="text-base font-semibold">
|
||
{end_point} / {country_to}
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
{user_request === 'Могу перевезти' && (
|
||
<div className="mt-3 ml-7 text-sm text-gray-500">
|
||
<span className="text-sm font-normal">Прибытие:</span>{' '}
|
||
<span className="text-sm font-semibold">{day_in?.toLocaleDateString()}</span>
|
||
</div>
|
||
)}
|
||
</div>
|
||
</div>
|
||
</>
|
||
)
|
||
}
|
||
|
||
export default SearchCard
|