fix(dashboard): the greeting tells the visitor's time, not the server's #5529
1 changed file+13−8
Modifiedsrc/routes/dashboard.tsx+13−8View fileUnifiedSplit
@@ -566,16 +566,21 @@ dashboard.get("/dashboard", requireAuth, async (c) => {
566566 <div class="dash-hero-inner">
567567 <div class="dash-hero-text">
568568 <div class="dash-hero-eyebrow">
569 {(() => {
570 const hour = new Date().getHours();
571 if (hour < 5) return "Late night,";
572 if (hour < 12) return "Good morning,";
573 if (hour < 17) return "Good afternoon,";
574 if (hour < 21) return "Good evening,";
575 return "Late night,";
576 })()}{" "}
569 {/* Server renders a timezone-neutral fallback; the inline
570 script below swaps in the time-of-day greeting computed in
571 the VISITOR'S clock. The old server-side new Date() ran in
572 the box's UTC — the owner's 9am in New Zealand was greeted
573 with "Good evening", i.e. warmth that was wrong for nearly
574 every user on earth except those near Greenwich. */}
575 <span id="dash-greet">Welcome back,</span>{" "}
577576 <span class="dash-hero-username">{user.username}</span>
578577 </div>
578 <script
579 dangerouslySetInnerHTML={{
580 __html:
581 '(function(){var h=new Date().getHours();var g=h<5?"Late night,":h<12?"Good morning,":h<17?"Good afternoon,":h<21?"Good evening,":"Late night,";var e=document.getElementById("dash-greet");if(e)e.textContent=g;})();',
582 }}
583 />
579584 <h1 class="dash-hero-title">
580585 Your{" "}
581586 <span class="gradient-text">command center</span>.
582587
c comment · e edit title · m merge · a approve · r request changes · ? shortcuts