Add greetings to the Dashboard for logged in users
This commit is contained in:
32
app/[locale]/(backend)/lib/dailyVerseData.ts
Normal file
32
app/[locale]/(backend)/lib/dailyVerseData.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// Local data storage for development without DB
|
||||
// Each object represents a verse for a specific day
|
||||
export interface localizedContent {
|
||||
en: string;
|
||||
de: string;
|
||||
ru: string;
|
||||
}
|
||||
|
||||
export interface BibleVerse {
|
||||
reference: string;
|
||||
content: localizedContent;
|
||||
}
|
||||
|
||||
export const bibleVerses: BibleVerse[] = [
|
||||
{
|
||||
reference: "Epheser 2:19",
|
||||
content: {
|
||||
en: "So then you are no longer strangers and aliens...",
|
||||
de: "So seid ihr nun nicht mehr Gäste und Fremdlinge...",
|
||||
ru: "Итак вы уже не чужие и не пришельцы..."
|
||||
}
|
||||
},
|
||||
{
|
||||
reference: "Psalm 23:1",
|
||||
content: {
|
||||
en: "The Lord is my shepherd...",
|
||||
de: "Der Herr ist mein Hirte...",
|
||||
ru: "Господь — Пастырь мой..."
|
||||
}
|
||||
},
|
||||
// Add as many as you want here
|
||||
];
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Community-Dashboard",
|
||||
"welcome": "Willkommen im Admin-Bereich. Verwalten Sie Ihre Community-Ressourcen sicher."
|
||||
"welcome": "Willkommen im Admin-Bereich. Verwalten Sie Ihre Community-Ressourcen sicher.",
|
||||
"greeting": "Lieber {user}, deine örtliche Gemeinde {church} begrüßt dich!",
|
||||
"verse_intro": "Lass dich durch den folgenden Vers ermutigen:"
|
||||
},
|
||||
"users": {
|
||||
"title": "Benutzer",
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Community Dashboard",
|
||||
"welcome": "Welcome to the admin area. Manage your community resources safely."
|
||||
"welcome": "Welcome to the admin area. Manage your community resources safely.",
|
||||
"greeting": "Dear {user}, your local community {church} welcomes you!",
|
||||
"verse_intro": "Let the following verse encourage you:"
|
||||
},
|
||||
"users": {
|
||||
"title": "Users",
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
},
|
||||
"dashboard": {
|
||||
"title": "Community Dashboard",
|
||||
"welcome": "Добро пожаловать в административный раздел. Безопасно управляйте ресурсами вашего сообщества."
|
||||
"welcome": "Добро пожаловать в административный раздел. Безопасно управляйте ресурсами вашего сообщества.",
|
||||
"greeting": "Дорогой {user}, твоя местная община {church} приветствует тебя!",
|
||||
"verse_intro": "Пусть этот стих подбодрит тебя:"
|
||||
},
|
||||
"users": {
|
||||
"title": "Пользователи",
|
||||
|
||||
Reference in New Issue
Block a user