"use client"; import SectionHeader from "@/Shared/UI/SectionHeader/SectionHeader"; import "./RatingSection.scss"; import SearchBar from "@/Features/SearchBar/SearchBar"; import arrow_down_icon from "./icons/arrow-down-icon.svg"; import arrow_up_icon from "./icons/arrow-up-icon.svg"; import like_icon from "./icons/like-icon.svg"; import message_icon from "./icons/message-icon.svg"; import Image from "next/image"; import { useRating } from "./rating.store"; import { useEffect } from "react"; import Link from "next/link"; const RatingSection = () => { const { data: reports, getRatings } = useRating(); useEffect(() => { getRatings(); }, []); const sliceDate = (date: string) => { return `${date.slice(8, 10)}.${date.slice(5, 7)}.${date.slice( 0, 4 )}`; }; const sliceLocation = (location: string) => { if (location.length > 15) return `${location.slice(0, 15)}...`; return location; }; const sliceDescription = (description: string) => { if (description.length > 49) { return `${description.slice(0, 50)}...`; } return description; }; return (
Рейтинг
{reports.results.map((report) => ( ))}
Дата Arrow Down Arrow Up
Адрес Статус Описание
Комментарии Arrow Down Arrow Up
Рейтинг Arrow Down Arrow Up
{sliceDate(report.created_at)} {sliceLocation(report.location[0].address)} Разбитая дорога

{sliceDescription(report.description)}

Message Icon {report.count_reviews}
Like Icon {report.total_likes}
); }; export default RatingSection;