2026-09-15 12:36:48 +07:00
|
|
|
import { render } from "solid-js/web";
|
2026-09-15 16:35:03 +07:00
|
|
|
import { Router, Route, useLocation, useNavigate, useParams, type RouteSectionProps } from "@solidjs/router";
|
|
|
|
|
import { createSignal, Show } from "solid-js";
|
2026-09-15 12:36:48 +07:00
|
|
|
import { WatchlistDrawer, ChatSidebar } from "./components/WatchlistChat";
|
2026-09-15 16:35:03 +07:00
|
|
|
import { ThemeToggle, useAuth, AuthButton } from "./components/auth";
|
2026-09-15 17:40:39 +07:00
|
|
|
import { Button } from "./components/ui/button";
|
|
|
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./components/ui/card";
|
|
|
|
|
import { TextField, TextFieldInput } from "./components/ui/text-field";
|
2026-09-15 16:35:03 +07:00
|
|
|
import { api } from "./lib/api";
|
2026-09-15 12:36:48 +07:00
|
|
|
import Dashboard from "./pages/Dashboard";
|
|
|
|
|
import Routines from "./pages/Routines";
|
|
|
|
|
import Screener from "./pages/Screener";
|
|
|
|
|
import Alerts from "./pages/Alerts";
|
|
|
|
|
import Report from "./pages/Report";
|
|
|
|
|
import Portfolio from "./pages/Portfolio";
|
2026-09-15 17:40:39 +07:00
|
|
|
import "./styles/globals.css";
|
|
|
|
|
|
|
|
|
|
const NAV = [
|
|
|
|
|
{ href: "/", icon: "📊", label: "Dashboard" },
|
|
|
|
|
{ href: "/routines", icon: "🗓️", label: "Routines" },
|
|
|
|
|
{ href: "/screener", icon: "🔍", label: "Screener" },
|
|
|
|
|
{ href: "/alerts", icon: "🔔", label: "Alerts" },
|
|
|
|
|
{ href: "/portfolio", icon: "💼", label: "Portfolio" },
|
|
|
|
|
];
|
2026-09-15 12:36:48 +07:00
|
|
|
|
|
|
|
|
function Nav() {
|
|
|
|
|
const loc = useLocation();
|
|
|
|
|
return (
|
2026-09-15 17:40:39 +07:00
|
|
|
<nav class="flex w-56 shrink-0 flex-col gap-1 border-r bg-card p-4 max-lg:hidden">
|
|
|
|
|
<div class="mb-4 px-2 text-xl font-bold tracking-tight">
|
|
|
|
|
Flow<span class="text-primary">Sight</span>
|
2026-09-15 16:35:03 +07:00
|
|
|
</div>
|
2026-09-15 17:40:39 +07:00
|
|
|
{NAV.map((n) => (
|
|
|
|
|
<a
|
|
|
|
|
href={n.href}
|
|
|
|
|
class={`flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground ${loc.pathname === n.href ? "bg-accent text-accent-foreground" : "text-muted-foreground"}`}
|
|
|
|
|
>
|
|
|
|
|
<span>{n.icon}</span> {n.label}
|
|
|
|
|
</a>
|
|
|
|
|
))}
|
|
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function MobileNav() {
|
|
|
|
|
const loc = useLocation();
|
|
|
|
|
return (
|
|
|
|
|
<nav class="fixed inset-x-0 bottom-0 z-40 flex border-t bg-card px-2 py-1 lg:hidden">
|
|
|
|
|
{NAV.map((n) => (
|
|
|
|
|
<a
|
|
|
|
|
href={n.href}
|
|
|
|
|
class={`flex flex-1 flex-col items-center rounded-md py-1.5 text-[11px] font-medium ${loc.pathname === n.href ? "text-primary" : "text-muted-foreground"}`}
|
|
|
|
|
>
|
|
|
|
|
<span class="text-base">{n.icon}</span> {n.label}
|
|
|
|
|
</a>
|
|
|
|
|
))}
|
2026-09-15 12:36:48 +07:00
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-15 16:35:03 +07:00
|
|
|
function TickerSearch() {
|
|
|
|
|
const nav = useNavigate();
|
|
|
|
|
const [q, setQ] = createSignal("");
|
|
|
|
|
const go = () => {
|
|
|
|
|
const t = q().toUpperCase().trim();
|
|
|
|
|
if (t) nav(`/report/${t}`);
|
|
|
|
|
};
|
|
|
|
|
return (
|
2026-09-15 17:40:39 +07:00
|
|
|
<form class="flex max-w-sm flex-1 items-center gap-2" onSubmit={(e) => { e.preventDefault(); go(); }}>
|
|
|
|
|
<TextField class="flex-1">
|
|
|
|
|
<TextFieldInput placeholder="Ticker → report (e.g. BBCA)" value={q()}
|
|
|
|
|
onInput={(e) => setQ(e.currentTarget.value)} />
|
|
|
|
|
</TextField>
|
|
|
|
|
<Button type="submit" variant="secondary">Open</Button>
|
2026-09-15 16:35:03 +07:00
|
|
|
</form>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function LoginPage() {
|
|
|
|
|
const params = useParams<{ error?: string }>();
|
|
|
|
|
const err = () => new URLSearchParams(window.location.search).get("error");
|
|
|
|
|
void params;
|
|
|
|
|
return (
|
2026-09-15 17:40:39 +07:00
|
|
|
<div class="mx-auto max-w-md py-[8vh]">
|
|
|
|
|
<Card>
|
|
|
|
|
<CardHeader class="text-center">
|
|
|
|
|
<CardTitle class="text-2xl">Welcome to FlowSight</CardTitle>
|
|
|
|
|
<CardDescription>Sign in with Google to get your own watchlist, routines, alerts and reports.</CardDescription>
|
|
|
|
|
</CardHeader>
|
|
|
|
|
<CardContent class="text-center">
|
|
|
|
|
<Show when={err()}><p class="mb-3 text-sm text-destructive">Login failed: {err()}</p></Show>
|
|
|
|
|
<a href="/api/auth/start"><Button size="lg">Sign in with Google</Button></a>
|
|
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
2026-09-15 16:35:03 +07:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Shell(props: RouteSectionProps) {
|
|
|
|
|
const { me, refetch } = useAuth();
|
|
|
|
|
const logout = async () => { await api.logout(); refetch(); };
|
|
|
|
|
return (
|
2026-09-15 17:40:39 +07:00
|
|
|
<div class="flex min-h-screen bg-background text-foreground">
|
2026-09-15 16:35:03 +07:00
|
|
|
<Nav />
|
2026-09-15 17:40:39 +07:00
|
|
|
<div class="flex min-w-0 flex-1 flex-col">
|
|
|
|
|
<header class="sticky top-0 z-30 flex items-center gap-3 border-b bg-background/95 px-4 py-2.5 backdrop-blur">
|
2026-09-15 16:35:03 +07:00
|
|
|
<TickerSearch />
|
2026-09-15 17:40:39 +07:00
|
|
|
<span class="flex-1" />
|
2026-09-15 16:35:03 +07:00
|
|
|
<ThemeToggle />
|
|
|
|
|
<AuthButton me={me()} onLogout={logout} />
|
|
|
|
|
</header>
|
2026-09-15 17:40:39 +07:00
|
|
|
<main class="mx-auto w-full max-w-6xl flex-1 space-y-6 p-4 pb-20 lg:p-6">{props.children}</main>
|
2026-09-15 16:35:03 +07:00
|
|
|
</div>
|
2026-09-15 17:40:39 +07:00
|
|
|
<aside class="hidden w-80 shrink-0 flex-col gap-4 border-l bg-card p-4 xl:flex">
|
2026-09-15 16:35:03 +07:00
|
|
|
<WatchlistDrawer />
|
|
|
|
|
<ChatSidebar />
|
|
|
|
|
</aside>
|
2026-09-15 17:40:39 +07:00
|
|
|
<MobileNav />
|
2026-09-15 16:35:03 +07:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-15 12:36:48 +07:00
|
|
|
render(
|
|
|
|
|
() => (
|
2026-09-15 16:35:03 +07:00
|
|
|
<Router root={Shell}>
|
2026-09-15 12:36:48 +07:00
|
|
|
<Route path="/" component={Dashboard} />
|
|
|
|
|
<Route path="/routines" component={Routines} />
|
|
|
|
|
<Route path="/screener" component={Screener} />
|
|
|
|
|
<Route path="/alerts" component={Alerts} />
|
|
|
|
|
<Route path="/report/:ticker" component={Report} />
|
|
|
|
|
<Route path="/portfolio" component={Portfolio} />
|
2026-09-15 16:35:03 +07:00
|
|
|
<Route path="/login" component={LoginPage} />
|
2026-09-15 12:36:48 +07:00
|
|
|
</Router>
|
|
|
|
|
),
|
|
|
|
|
document.getElementById("root")!,
|
|
|
|
|
);
|