From 6b07c063c85888aa06d2fb7e4e16f54ba78598fa Mon Sep 17 00:00:00 2001 From: Factiven Date: Thu, 13 Apr 2023 18:52:40 +0700 Subject: Update index.js --- pages/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pages/index.js b/pages/index.js index 98a0ca1..60f6381 100644 --- a/pages/index.js +++ b/pages/index.js @@ -91,6 +91,7 @@ export default function Home({ detail, populars }) { const [isVisible, setIsVisible] = useState(false); const [recently, setRecently] = useState(null); const [user, setUser] = useState(null); + const [array, setArray] = useState([]); const popular = populars?.data; const data = detail.data[0]; @@ -104,11 +105,15 @@ export default function Home({ detail, populars }) { setIsVisible(false); }; + // const reversed = user?.recentWatch.reverse(); + // console.log(array); + useEffect(() => { async function userData() { if (!session) return; const res = await fetch(`/api/get-user?userName=${session?.user.name}`); const data = await res.json(); + setArray(data?.recentWatch.reverse()); setUser(data); } function fetchData() { @@ -323,6 +328,7 @@ export default function Home({ detail, populars }) { )} +
{/* PC / TABLET */} @@ -392,7 +398,7 @@ export default function Home({ detail, populars }) { )} -- cgit v1.2.3