Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ujjwall-R#40 from ramith-kulal/feature/greetings
Browse files Browse the repository at this point in the history
feat: Change greeting according to time
singodiyashubham87 authored Nov 29, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
2 parents 8153168 + 752f058 commit b17683a
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
@@ -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() {
<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 ? (

0 comments on commit b17683a

Please sign in to comment.