add highlight logic to search card

This commit is contained in:
2025-05-29 13:07:49 +03:00
parent 2e820fb041
commit 91c6693190
4 changed files with 15 additions and 6 deletions

View File

@@ -21,7 +21,7 @@ class SearchRouteSerializer(RouteSerializer):
formatted_arrival = serializers.DateTimeField(source='arrival_DT')
country_from_icon = serializers.SerializerMethodField()
country_to_icon = serializers.SerializerMethodField()
is_highlighted = serializers.BooleanField()
class Meta:
model = Route
fields = (
@@ -30,7 +30,7 @@ class SearchRouteSerializer(RouteSerializer):
'to_city_name', 'to_city_russian_name', 'to_country_name',
'formatted_cargo_type', 'formatted_transport', 'type_transport',
'userImg', 'comment', 'formatted_departure', 'formatted_arrival',
'country_from_icon', 'country_to_icon'
'country_from_icon', 'country_to_icon', 'is_highlighted'
)
def get_username(self, obj):

View File

@@ -119,7 +119,7 @@ export default function UserRoutes() {
const getBorderColor = (route: Route) => {
if (route.is_highlighted) {
return 'border-yellow-500'
return 'border-yellow-500 border-2'
}
return 'border'
}
@@ -142,7 +142,7 @@ export default function UserRoutes() {
{routes.map(route => (
<div
key={route.id}
className={`space-y-4 rounded-2xl border bg-white p-6 transition-shadow hover:shadow-md ${getBorderColor(route)}`}
className={`space-y-4 rounded-2xl bg-white p-6 transition-shadow hover:shadow-md ${getBorderColor(route)}`}
>
<div className="flex items-center justify-between">
<div className="text-sm text-gray-500">ID маршрута: #{route.id}</div>

View File

@@ -45,6 +45,7 @@ const SearchCard = ({
formatted_arrival,
country_from_icon,
country_to_icon,
is_highlighted,
}: SearchCardProps) => {
const [isLeadPopupOpen, setIsLeadPopupOpen] = useState(false)
const { isAuthenticated } = useUserStore()
@@ -74,11 +75,18 @@ const SearchCard = ({
const userRequest = owner_type === 'customer' ? 'Нужен перевозчик' : 'Могу перевезти'
const getBorderColor = () => {
if (is_highlighted) {
return 'border-yellow-500 border-3'
}
return null
}
return (
<>
{/* десктоп */}
<div className="hidden sm:block">
<div className="my-4 w-full rounded-xl bg-white p-6 shadow-lg">
<div className={`my-4 w-full rounded-xl bg-white p-6 shadow-lg ${getBorderColor()}`}>
<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">
@@ -220,7 +228,7 @@ const SearchCard = ({
{/* мобилка */}
<div className="block sm:hidden">
<div className="my-4 w-full rounded-xl bg-white p-4 shadow-lg">
<div className={`my-4 w-full rounded-xl bg-white p-4 shadow-lg ${getBorderColor()}`}>
<div className="flex items-center justify-between">
<div className={`text-sm font-semibold ${getUserRequestStyles()}`}>{userRequest}</div>
<div className="text-sm font-semibold">

View File

@@ -47,6 +47,7 @@ export interface SearchCardProps {
formatted_arrival: string
country_from_icon: string
country_to_icon: string
is_highlighted?: boolean
}
export interface AccordionProps {