import { View, Text } from "react-native"; import { useTheme } from "./theme"; import { Avatar } from "./ui/avatar"; import { Rating } from "./ui/rating"; function formatTimeAgo(timestamp: number): string { const now = Date.now(); const diff = now - timestamp; const seconds = Math.floor(diff / 1000); const minutes = Math.floor(seconds / 60); const hours = Math.floor(minutes / 60); const days = Math.floor(hours / 24); const months = Math.floor(days / 30); const years = Math.floor(days / 365); if (years > 0) return `пред ${years} ${years === 1 ? "година" : "години"}`; if (months > 0) return `пред ${months} ${months === 1 ? "месец" : "месеци"}`; if (days > 0) return `пред ${days} ${days === 1 ? "ден" : "денови"}`; if (hours > 0) return `пред ${hours} ${hours === 1 ? "час" : "часа"}`; if (minutes > 0) return `пред ${minutes} ${minutes === 1 ? "минута" : "минути"}`; return "пред малку"; } interface ReviewCardProps { review: { _id: string; rating: number; comment?: string; createdAt: number; }; customerName: string; customerAvatarId?: string; } export function ReviewCard({ review, customerName, customerAvatarId }: ReviewCardProps) { const theme = useTheme(); return ( {customerName} {formatTimeAgo(review.createdAt)} {review.comment ? ( {review.comment} ) : null} ); }