Skip to content

Commit 7d2bdcb

Browse files
committed
update
1 parent 8af9283 commit 7d2bdcb

4 files changed

Lines changed: 51 additions & 30 deletions

File tree

app/layout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ export default function RootLayout({
4141
</Link>
4242
.{"\n "}
4343
</p>
44+
<p className="text-center text-gray-500 mb-8">
45+
Text to book +47 6494 0131
46+
</p>
4447
<main className="pt-6">{children}</main>
4548
</body>
4649
</html>

components/ai-review-summary.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export async function AIReviewSummary({ product }: { product: Product }) {
2828
<span className="text-sm ml-4 text-gray-500 dark:text-gray-400">
2929
{numberWithOneDecimal(averageRating)} out of 5
3030
</span>
31+
<a
32+
href="https://maps.app.goo.gl/f4irVqGC9KGHzRDP9"
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
className="ml-6 underline text-xs text-blue-600"
36+
>
37+
Google page
38+
</a>
3139
</div>
3240
</CardHeader>
3341
<CardContent className="p-0 grid gap-4">

components/reviews.tsx

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { AvatarImage, AvatarFallback, Avatar } from "@/components/ui/avatar";
22
import { Product, Review as ReviewType } from "@/lib/types";
3-
import ms from "ms";
43
import { FiveStarRating } from "./five-star-rating";
54
import { AIReviewSummary } from "./ai-review-summary";
65

76
export async function Reviews({ product }: { product: Product }) {
7+
// Sort reviews by date descending (newest first)
8+
const sortedReviews = [...product.reviews].sort(
9+
(a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()
10+
);
811
return (
912
<div className="mx-auto px-4 md:px-6 max-w-2xl grid gap-12">
1013
<AIReviewSummary product={product} />
11-
{product.reviews.map((review) => (
14+
{sortedReviews.map((review) => (
1215
<div key={review.review}>
1316
<Review key={review.review} review={review} />
1417
</div>
@@ -52,10 +55,24 @@ export function Review({ review }: { review: ReviewType }) {
5255
* You probably want to wrap the parent element of this component with `suppressHydrationWarning`
5356
*/
5457
const timeAgo = (date: Date, suffix = true) => {
55-
if (Date.now() - date.getTime() < 1000) {
56-
return "Just now";
57-
}
58-
return `${ms(Date.now() - date.getTime(), { long: true })}${
59-
suffix ? " ago" : ""
60-
}`;
58+
const now = new Date();
59+
const seconds = Math.floor((now.getTime() - date.getTime()) / 1000);
60+
61+
if (seconds < 60) return "Just now";
62+
const minutes = Math.floor(seconds / 60);
63+
if (minutes < 60)
64+
return `${minutes} minute${
65+
minutes !== 1 ? "s" : ""
66+
}${suffix ? " ago" : ""}`;
67+
const hours = Math.floor(minutes / 60);
68+
if (hours < 24)
69+
return `${hours} hour${hours !== 1 ? "s" : ""}${suffix ? " ago" : ""}`;
70+
const days = Math.floor(hours / 24);
71+
if (days < 30)
72+
return `${days} day${days !== 1 ? "s" : ""}${suffix ? " ago" : ""}`;
73+
const months = Math.floor(days / 30);
74+
if (months < 12)
75+
return `${months} month${months !== 1 ? "s" : ""}${suffix ? " ago" : ""}`;
76+
const years = Math.floor(months / 12);
77+
return `${years} year${years !== 1 ? "s" : ""}${suffix ? " ago" : ""}`;
6178
};

lib/sample-data.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,31 @@ export const sampleProductsReviews: Record<string, Product> = {
1515
reviews: [
1616
{
1717
review:
18-
"Absolutely love the Hagersten Street Cut! Installation was a breeze, thanks to the clear instructions and videos. It navigates my complex yard with ease, even the steep parts. Plus, it's so quiet, I barely notice it's working. Truly a game-changer for lawn care.",
19-
authorName: "Jake P.",
20-
date: "2024-02-15",
18+
"Fantastic barber! Got a sharp haircut and beard trim. The staff are friendly and really listen to what you want. The shop is clean and has a great vibe. Highly recommend if you're in Hagersten.",
19+
authorName: "Erik S.",
20+
date: "2024-05-15",
2121
stars: 5,
2222
},
2323
{
2424
review:
25-
"The Hagersten Street Cut has been a solid addition to my garden tools. It handles the lawn autonomously, freeing up my weekends. The app control is intuitive, though I wish the Bluetooth range was better. Overall, a reliable lawn mower that does its job well.",
26-
authorName: "Marianne L.",
27-
date: "2024-01-28",
28-
stars: 4,
29-
},
30-
{
31-
review:
32-
"I had high hopes for the Hagersten Street Cut, but it's been a mixed bag. The setup was more complicated than expected, and it occasionally misses spots on the lawn. It's quiet and the safety features are reassuring, but I expected more precision for the price.",
33-
authorName: "Alexa R.",
34-
date: "2023-12-20",
35-
stars: 3,
25+
"Very professional service and attention to detail. I appreciated the advice on styling and products. Will definitely come back next month.",
26+
authorName: "Anna L.",
27+
date: "2024-04-28",
28+
stars: 5,
3629
},
3730
{
3831
review:
39-
"The Hagersten Street Cut is decent. It mows the lawn autonomously, which is convenient. However, the setup took some effort, and the app could be more stable. It's nice to have, but I'm not sure it's worth the investment for smaller yards.",
40-
authorName: "Gary W.",
41-
date: "2024-02-05",
42-
stars: 3,
32+
"Walked in without an appointment and was seen quickly. The barber was skilled and friendly. Prices are reasonable for Stockholm. Great local spot!",
33+
authorName: "Jonas M.",
34+
date: "2025-04-10",
35+
stars: 4,
4336
},
4437
{
4538
review:
46-
"Overall, the Hagersten Street Cut is a good buy. It handles most of my lawn well, including the slope. The silent operation is a huge plus. Just wish the battery life was longer, as it doesn't always finish in one go. Still, it's much better than manual mowing.",
47-
authorName: "Bethany E.",
48-
date: "2024-01-19",
49-
stars: 4,
39+
"My son and I both got haircuts here. The barber was patient and did a great job with my son's hair. Convenient location in Hagersten.",
40+
authorName: "Maria P.",
41+
date: "2025-03-20",
42+
stars: 5,
5043
},
5144
],
5245
},

0 commit comments

Comments
 (0)