Add greetings to the Dashboard for logged in users
This commit is contained in:
@@ -22,11 +22,26 @@ import {
|
||||
Users,
|
||||
} from "lucide-react";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { useParams } from "next/navigation";
|
||||
import Link from "next/link";
|
||||
import React from "react";
|
||||
import { bibleVerses, localizedContent } from "./lib/dailyVerseData";
|
||||
|
||||
const Dashboard: React.FC = () => {
|
||||
// 1. Get a unique number for the current day
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0); // Normalize to midnight
|
||||
const dayTimestamp = today.getTime();
|
||||
|
||||
// 2. Use the timestamp to get a consistent index
|
||||
// The modulo (%) operator ensures the index is always within array bounds
|
||||
const verseIndex = dayTimestamp % bibleVerses.length;
|
||||
const todayVerse = bibleVerses[verseIndex];
|
||||
const params = useParams();
|
||||
const lng = params.locale as keyof localizedContent || "en"; // Default to English if no locale is provided
|
||||
|
||||
const t = useTranslations("dashboard");
|
||||
|
||||
const categories: ModuleCategory[] = [
|
||||
{
|
||||
title: "People & Community",
|
||||
@@ -174,7 +189,12 @@ const Dashboard: React.FC = () => {
|
||||
<h1 className="text-foreground text-3xl font-bold tracking-tight">
|
||||
{t("title")}
|
||||
</h1>
|
||||
<p className="text-muted-foreground mt-1">{t("welcome")}</p>
|
||||
<p className="text-muted-foreground mt-1">{t("greeting", { user: "David", church: "Rastatt" })}</p>
|
||||
<p className="text-muted-foreground mt-1">{t("verse_intro")}</p>
|
||||
<p className="text-muted-foreground mt-1">
|
||||
„{todayVerse.content[lng]}"
|
||||
</p>
|
||||
<span className="text-sm text-muted-foreground">({todayVerse.reference})</span>
|
||||
</div>
|
||||
<div className="flex space-x-3">
|
||||
<Badge variant="secondary" className="px-2.5 py-0.5 text-sm">
|
||||
@@ -230,7 +250,7 @@ const Dashboard: React.FC = () => {
|
||||
title={item.title}
|
||||
description={item.description}
|
||||
icon={item.icon}
|
||||
//onClick={() => console.log(`Navigating to ${item.path}`)}
|
||||
//onClick={() => console.log(`Navigating to ${item.path}`)}
|
||||
/>
|
||||
</Link>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user