aboutsummaryrefslogtreecommitdiff
path: root/pages/index.js
diff options
context:
space:
mode:
authorFactiven <[email protected]>2023-04-18 15:51:22 +0700
committerFactiven <[email protected]>2023-04-18 15:51:22 +0700
commit88270076a27201364e80eebcc63ae3abe37628c4 (patch)
tree98b5fada39486cc3bf1a4ca49e35d3f26b7f3c73 /pages/index.js
parent8th fixes (diff)
downloadmoopa-88270076a27201364e80eebcc63ae3abe37628c4.tar.xz
moopa-88270076a27201364e80eebcc63ae3abe37628c4.zip
10th fixes
Diffstat (limited to 'pages/index.js')
-rw-r--r--pages/index.js35
1 files changed, 16 insertions, 19 deletions
diff --git a/pages/index.js b/pages/index.js
index b97b3a2..5dc013b 100644
--- a/pages/index.js
+++ b/pages/index.js
@@ -104,12 +104,11 @@ export default function Home({ detail, populars, sessions }) {
const [isVisible, setIsVisible] = useState(false);
const [plan, setPlan] = useState(null);
+ const [greeting, setGreeting] = useState("");
// const [array, setArray] = useState(null);
const popular = populars?.data;
const data = detail.data[0];
- const greeting = getGreeting();
-
const handleShowClick = () => {
setIsVisible(true);
};
@@ -119,6 +118,21 @@ export default function Home({ detail, populars, sessions }) {
};
useEffect(() => {
+ const time = new Date().getHours();
+ let greeting = "";
+
+ if (time >= 5 && time < 12) {
+ greeting = "Good morning";
+ } else if (time >= 12 && time < 18) {
+ greeting = "Good afternoon";
+ } else if (time >= 18 && time < 22) {
+ greeting = "Good evening";
+ } else if (time >= 22 || time < 5) {
+ greeting = "Good night";
+ }
+
+ setGreeting(greeting);
+
async function userData() {
if (!sessions) return;
const getMedia =
@@ -516,20 +530,3 @@ export async function getServerSideProps(context) {
},
};
}
-
-function getGreeting() {
- const time = new Date().getHours();
- let greeting = "";
-
- if (time >= 5 && time < 12) {
- greeting = "Good morning";
- } else if (time >= 12 && time < 18) {
- greeting = "Good afternoon";
- } else if (time >= 18 && time < 22) {
- greeting = "Good evening";
- } else if (time >= 22 || time < 5) {
- greeting = "Good night";
- }
-
- return greeting;
-}