From 752f05864fc3310376aa1d7c40aec2de30f20727 Mon Sep 17 00:00:00 2001 From: ramith-kulal Date: Wed, 29 Nov 2023 14:49:54 +0530 Subject: [PATCH] feat: Change greeting according to time --- src/components/LandingPage.jsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/LandingPage.jsx b/src/components/LandingPage.jsx index fc9d7ec..f548068 100644 --- a/src/components/LandingPage.jsx +++ b/src/components/LandingPage.jsx @@ -85,6 +85,19 @@ function LandingPage() { } } }; + // Function to get the current time and determine the greeting +const getGreeting = () => { + const currentHour = new Date().getHours(); + + if (currentHour >= 5 && currentHour < 12) { + return 'Good Morning'; + } else if (currentHour >= 12 && currentHour < 18) { + return 'Good Afternoon'; + } else { + return 'Good Evening'; + } +}; + // Modal and loader handling functions const closeModal = () => setShowModal(false); @@ -141,7 +154,7 @@ function LandingPage() {
{isAuthenticated && (

- Hello, {user.name}! + {getGreeting()}, {user.name}!

)} {!isAuthenticated ? (