add highlight logic to search card
This commit is contained in:
@@ -21,7 +21,7 @@ class SearchRouteSerializer(RouteSerializer):
|
|||||||
formatted_arrival = serializers.DateTimeField(source='arrival_DT')
|
formatted_arrival = serializers.DateTimeField(source='arrival_DT')
|
||||||
country_from_icon = serializers.SerializerMethodField()
|
country_from_icon = serializers.SerializerMethodField()
|
||||||
country_to_icon = serializers.SerializerMethodField()
|
country_to_icon = serializers.SerializerMethodField()
|
||||||
|
is_highlighted = serializers.BooleanField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Route
|
model = Route
|
||||||
fields = (
|
fields = (
|
||||||
@@ -30,7 +30,7 @@ class SearchRouteSerializer(RouteSerializer):
|
|||||||
'to_city_name', 'to_city_russian_name', 'to_country_name',
|
'to_city_name', 'to_city_russian_name', 'to_country_name',
|
||||||
'formatted_cargo_type', 'formatted_transport', 'type_transport',
|
'formatted_cargo_type', 'formatted_transport', 'type_transport',
|
||||||
'userImg', 'comment', 'formatted_departure', 'formatted_arrival',
|
'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):
|
def get_username(self, obj):
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ export default function UserRoutes() {
|
|||||||
|
|
||||||
const getBorderColor = (route: Route) => {
|
const getBorderColor = (route: Route) => {
|
||||||
if (route.is_highlighted) {
|
if (route.is_highlighted) {
|
||||||
return 'border-yellow-500'
|
return 'border-yellow-500 border-2'
|
||||||
}
|
}
|
||||||
return 'border'
|
return 'border'
|
||||||
}
|
}
|
||||||
@@ -142,7 +142,7 @@ export default function UserRoutes() {
|
|||||||
{routes.map(route => (
|
{routes.map(route => (
|
||||||
<div
|
<div
|
||||||
key={route.id}
|
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="flex items-center justify-between">
|
||||||
<div className="text-sm text-gray-500">ID маршрута: #{route.id}</div>
|
<div className="text-sm text-gray-500">ID маршрута: #{route.id}</div>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const SearchCard = ({
|
|||||||
formatted_arrival,
|
formatted_arrival,
|
||||||
country_from_icon,
|
country_from_icon,
|
||||||
country_to_icon,
|
country_to_icon,
|
||||||
|
is_highlighted,
|
||||||
}: SearchCardProps) => {
|
}: SearchCardProps) => {
|
||||||
const [isLeadPopupOpen, setIsLeadPopupOpen] = useState(false)
|
const [isLeadPopupOpen, setIsLeadPopupOpen] = useState(false)
|
||||||
const { isAuthenticated } = useUserStore()
|
const { isAuthenticated } = useUserStore()
|
||||||
@@ -74,11 +75,18 @@ const SearchCard = ({
|
|||||||
|
|
||||||
const userRequest = owner_type === 'customer' ? 'Нужен перевозчик' : 'Могу перевезти'
|
const userRequest = owner_type === 'customer' ? 'Нужен перевозчик' : 'Могу перевезти'
|
||||||
|
|
||||||
|
const getBorderColor = () => {
|
||||||
|
if (is_highlighted) {
|
||||||
|
return 'border-yellow-500 border-3'
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* десктоп */}
|
{/* десктоп */}
|
||||||
<div className="hidden sm:block">
|
<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="mb-4 flex items-center justify-between">
|
||||||
<div className="flex items-center gap-5">
|
<div className="flex items-center gap-5">
|
||||||
<div className="flex h-16 w-16 items-center justify-center rounded-full bg-gray-200">
|
<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="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="flex items-center justify-between">
|
||||||
<div className={`text-sm font-semibold ${getUserRequestStyles()}`}>{userRequest}</div>
|
<div className={`text-sm font-semibold ${getUserRequestStyles()}`}>{userRequest}</div>
|
||||||
<div className="text-sm font-semibold">
|
<div className="text-sm font-semibold">
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export interface SearchCardProps {
|
|||||||
formatted_arrival: string
|
formatted_arrival: string
|
||||||
country_from_icon: string
|
country_from_icon: string
|
||||||
country_to_icon: string
|
country_to_icon: string
|
||||||
|
is_highlighted?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AccordionProps {
|
export interface AccordionProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user