Improve MineGeo interface and functionality
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { getI18n } from "@/lib/i18n";
|
||||
import { Header, Footer } from "@/components/Shell";
|
||||
import { DraftEditor } from "@/components/DraftEditor";
|
||||
import { user } from "@/lib/supabase";
|
||||
@@ -7,6 +8,7 @@ export default async function Draft({
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { t } = await getI18n();
|
||||
const { id } = await params;
|
||||
if (!(await user()))
|
||||
redirect(`/log-in?next=${encodeURIComponent("/dashboard/" + id)}`);
|
||||
@@ -14,8 +16,8 @@ export default async function Draft({
|
||||
<>
|
||||
<Header />
|
||||
<main className="section page-content">
|
||||
<span className="eyebrow">YOUR WORLD · YOUR LOCATIONS</span>
|
||||
<h1>Map workshop</h1>
|
||||
<span className="eyebrow">{t("YOUR WORLD · YOUR LOCATIONS")}</span>
|
||||
<h1>{t("Map workshop")}</h1>
|
||||
<DraftEditor id={id} />
|
||||
</main>
|
||||
<Footer />
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getI18n } from "@/lib/i18n";
|
||||
import { Header, Footer } from "@/components/Shell";
|
||||
import { SignIn } from "@/components/SignIn";
|
||||
import { Dashboard } from "@/components/Dashboard";
|
||||
@@ -6,16 +7,21 @@ import Link from "next/link";
|
||||
import { accountProfile } from "@/lib/profile";
|
||||
export const dynamic = "force-dynamic";
|
||||
export default async function DashboardPage() {
|
||||
const { t, formatDate } = await getI18n();
|
||||
const account = await user();
|
||||
const profile = account ? await accountProfile(account) : null;
|
||||
const historyCutoff = new Date(
|
||||
Date.now() - 30 * 24 * 60 * 60 * 1000,
|
||||
).toISOString();
|
||||
const history = account
|
||||
? required(
|
||||
await admin()
|
||||
.from("game_sessions")
|
||||
.select("id,difficulty,created_at,current_round")
|
||||
.eq("owner_id", account.id)
|
||||
.gte("created_at", historyCutoff)
|
||||
.order("created_at", { ascending: false })
|
||||
.limit(20),
|
||||
.limit(5),
|
||||
)
|
||||
: [];
|
||||
return (
|
||||
@@ -24,24 +30,31 @@ export default async function DashboardPage() {
|
||||
<main className="section page-content">
|
||||
{account ? (
|
||||
<>
|
||||
<span className="eyebrow">THE CARTOGRAPHER’S DESK</span>
|
||||
<h1>My expedition.</h1>
|
||||
<p className="lead">Welcome back, {profile?.display_name}.</p>
|
||||
<span className="eyebrow">{t("THE CARTOGRAPHER’S DESK")}</span>
|
||||
<h1>{t("My expedition.")}</h1>
|
||||
<p className="lead">
|
||||
{t("Welcome back,")} {profile?.display_name}.
|
||||
</p>
|
||||
<Dashboard />
|
||||
{history.length > 0 && (
|
||||
<section className="token-box">
|
||||
<h2>Recent journeys</h2>
|
||||
<h2>{t("Recent journeys")}</h2>
|
||||
<p className="muted">
|
||||
{t("Your five latest journeys from the past 30 days.")}
|
||||
</p>
|
||||
{history.map((s) => (
|
||||
<div className="draft-row" key={s.id}>
|
||||
<span>
|
||||
{new Date(s.created_at).toLocaleDateString("en-GB")} ·{" "}
|
||||
{s.difficulty} · {s.current_round}/5 rounds
|
||||
{formatDate(s.created_at)} ·{" "}
|
||||
{t(s.difficulty[0].toUpperCase() + s.difficulty.slice(1))}{" "}
|
||||
· {s.current_round}
|
||||
{t("/5 rounds")}
|
||||
</span>
|
||||
<Link
|
||||
className="button"
|
||||
href={`/${s.current_round >= 5 ? "results" : "play"}/${s.id}`}
|
||||
>
|
||||
Open →
|
||||
{t("Open →")}
|
||||
</Link>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user