feat(notes): connect dashboard saved views
This commit is contained in:
parent
ea2a746c21
commit
99484a5636
@ -78,6 +78,18 @@ export default function DashboardPage() {
|
||||
|
||||
const recentNotes = notes.slice(0, 3);
|
||||
|
||||
function getSavedViewHref(view: (typeof savedViews)[number]) {
|
||||
if (view.id === "workspace-all") {
|
||||
return "/workspaces";
|
||||
}
|
||||
|
||||
if (view.id === "draft-notes") {
|
||||
return `/search?q=${encodeURIComponent("draft")}`;
|
||||
}
|
||||
|
||||
return "/reviews";
|
||||
}
|
||||
|
||||
return (
|
||||
<AppShell
|
||||
title="Dashboard"
|
||||
@ -104,7 +116,12 @@ export default function DashboardPage() {
|
||||
<div style={{ fontSize: "var(--ml-fs-xl)", fontWeight: 700 }}>Saved views</div>
|
||||
<div style={{ display: "grid", gap: "var(--ml-space-3)" }}>
|
||||
{savedViews.map((view) => (
|
||||
<article key={view.id} className="surface-muted" style={{ padding: "var(--ml-space-4)", display: "grid", gap: "var(--ml-space-2)" }}>
|
||||
<Link
|
||||
key={view.id}
|
||||
href={getSavedViewHref(view)}
|
||||
className="surface-muted"
|
||||
style={{ padding: "var(--ml-space-4)", display: "grid", gap: "var(--ml-space-2)" }}
|
||||
>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", gap: "var(--ml-space-3)", flexWrap: "wrap" }}>
|
||||
<strong>{view.name}</strong>
|
||||
<span className="badge">{view.scope}</span>
|
||||
@ -114,7 +131,7 @@ export default function DashboardPage() {
|
||||
<span style={{ color: "var(--ml-text-secondary)" }}>{view.query}</span>
|
||||
<span style={{ color: "var(--ml-text-secondary)" }}>{view.resultCount} results</span>
|
||||
</div>
|
||||
</article>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@ -1,16 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import Link from "next/link";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { AppShell } from "@/components/AppShell";
|
||||
import { searchNoteSummaries } from "@/lib/notes-client";
|
||||
import type { NoteSummary } from "@/lib/types";
|
||||
|
||||
export default function SearchPage() {
|
||||
const searchParams = useSearchParams();
|
||||
const [notes, setNotes] = useState<NoteSummary[]>([]);
|
||||
const [query, setQuery] = useState("");
|
||||
const [query, setQuery] = useState(() => searchParams?.get("q") ?? "");
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setQuery(searchParams?.get("q") ?? "");
|
||||
}, [searchParams]);
|
||||
|
||||
useEffect(() => {
|
||||
const timeout = window.setTimeout(() => {
|
||||
void (async () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user