Skip to content

Commit

Permalink
feat: Change greeting according to time
Browse files Browse the repository at this point in the history
  • Loading branch information
ramith-kulal committed Nov 29, 2023
1 parent 8153168 commit 752f058
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/LandingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -141,7 +154,7 @@ function LandingPage() {
<div className="auth text-center">
{isAuthenticated && (
<h1 className="greeting text-secondary text-[1rem] vvsm:text-[1.5rem] vsm:text-[1.7rem] md:text-[2.5rem] sm:text-[2rem] mb-[1rem]">
Hello, {user.name}!
{getGreeting()}, {user.name}!
</h1>
)}
{!isAuthenticated ? (
Expand Down

0 comments on commit 752f058

Please sign in to comment.