test: ๐Ÿงช test auto-update

by Sivritkin Dmitriy

1@@ -0,0 +1,27 @@
2+"use client";
3+
4+import { useEffect, useState } from "react";
5+import dayjs from "dayjs";
6+import relativeTime from "dayjs/plugin/relativeTime";
7+
8+dayjs.extend(relativeTime);
9+
10+export const Date = ({ date }: { date: string }) => {
11+  const [currentDate, setCurrentDate] = useState(dayjs(date).fromNow());
12+
13+  useEffect(() => {
14+    const intervalId = setInterval(() => {
15+      setCurrentDate(dayjs(date).fromNow());
16+    }, 1000);
17+
18+    return () => clearInterval(intervalId);
19+  }, []);
20+
21+  console.log("@log", currentDate);
22+
23+  return (
24+    <div>
25+      <h1>{currentDate}</h1>
26+    </div>
27+  );
28+};@@ -6,6 +6,7 @@ import Link from "next/link";
29 import { Avatar, AvatarImage } from "~/shared/ui/avatar";
30 import { convertEmoji } from "~/shared/lib/convert-emoji";
31 import { RefreshButton } from "~/app/refresh-form";
32+import { Date } from "~/app/date";
33 
34 dayjs.extend(relativeTime);
35 
36@@ -40,9 +41,7 @@ export default async function Home() {
37                   </Avatar>
38                   <span className="text-lg">{commit.commit.author?.name}</span>
39                 </div>
40-                <p className="text-lg">
41-                  {dayjs(commit.commit.committer?.date).fromNow()}
42-                </p>
43+                <Date date={commit.commit.committer?.date || ""} />
44               </div>
45             </Card>
46           </Link>