aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-13 18:52:40 +0700
committerFactiven <[email protected]>2023-04-13 18:52:40 +0700
commit6b07c063c85888aa06d2fb7e4e16f54ba78598fa (patch)
tree77016a5d6b7c20aa9b6a51fa4f199549aa1482f9
parentUpdate index.js (diff)
downloadmoopa-6b07c063c85888aa06d2fb7e4e16f54ba78598fa.tar.xz
moopa-6b07c063c85888aa06d2fb7e4e16f54ba78598fa.zip
Update index.js
-rw-r--r--pages/index.js8
1 files changed, 7 insertions, 1 deletions
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 }) {
)}
</div>
</div>
+
<div className="h-auto w-screen bg-[#141519] text-[#dbdcdd] ">
<Navigasi />
{/* PC / TABLET */}
@@ -392,7 +398,7 @@ export default function Home({ detail, populars }) {
<Content
ids="recentlyWatched"
section="Recently Watched"
- data={user.recentWatch.reverse()}
+ data={array}
/>
</motion.div>
)}