Open History to see the last commit
1import { useNavigate } from "@tanstack/react-router";
2
3import { showAIAssistant } from "@/store/assistant";
4
5import motorcycles from "@/data/motorcycles";
6
7export default function MotorcycleRecommendation({ id }: { id: string }) {
8 const navigate = useNavigate();
9 const motorcycle = motorcycles.find((motorcycle) => motorcycle.id === +id);
10 if (!motorcycle) {
11 return null;
12 }
13 return (
14 <div className="my-4 rounded-lg overflow-hidden border border-orange-500/20 bg-gray-800/50">
15 <div className="aspect-[4/3] relative overflow-hidden">
16 <img
17 src={motorcycle.image}
18 alt={motorcycle.name}
19 className="w-full h-full object-cover"
20 />
21 </div>
22 <div className="p-4">
23 <h3 className="text-lg font-semibold text-white mb-2">
24 {motorcycle.name}
25 </h3>
26 <p className="text-sm text-gray-300 mb-1 line-clamp-2">
27 {motorcycle.shortDescription}
28 </p>
29 <p className="text-sm text-gray-400 mb-3">
30 {motorcycle.engineSize}cc •{" "}
31 {motorcycle.type.charAt(0).toUpperCase() + motorcycle.type.slice(1)}
32 </p>
33 <div className="flex items-center justify-between">
34 <div className="text-lg font-bold text-emerald-400">
35 ${motorcycle.price.toLocaleString()}
36 </div>
37 <button
38 onClick={() => {
39 navigate({
40 to: "/motorcycles/$motorcycleId",
41 params: { motorcycleId: motorcycle.id.toString() },
42 });
43 showAIAssistant.setState(() => false);
44 }}
45 className="bg-gradient-to-r from-orange-500 to-red-600 text-white px-4 py-1.5 rounded-lg text-sm hover:opacity-90 transition-opacity"
46 >
47 View Details
48 </button>
49 </div>
50 </div>
51 </div>
52 );
53}