import { render } from "solid-js/web"; import { Router, Route, useLocation, useNavigate, type RouteSectionProps } from "@solidjs/router"; import { createResource, createSignal, createEffect, Show } from "solid-js"; import { WatchlistDrawer, ChatSidebar } from "./components/WatchlistChat"; import { ThemeToggle, useAuth, AuthButton, ButuhLogin } from "./components/auth"; import { Button } from "./components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "./components/ui/card"; import { TextField, TextFieldInput } from "./components/ui/text-field"; import { api, AUTH_EXPIRED_EVENT } from "./lib/api"; 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"; import "./styles/globals.css"; const NAV_ALL = [ { href: "/", icon: "π", label: "Dashboard" }, { href: "/routines", icon: "ποΈ", label: "Routines" }, { href: "/screener", icon: "π", label: "Screener" }, { href: "/alerts", icon: "π", label: "Alerts" }, { href: "/portfolio", icon: "πΌ", label: "Portfolio" }, ]; function Nav(props: { loggedIn: boolean }) { const loc = useLocation(); // Belum login: hanya Dashboard yg terlihat (fitur lain di-hide). const items = () => props.loggedIn ? NAV_ALL : NAV_ALL.slice(0, 1); return ( ); } function MobileNav(props: { loggedIn: boolean }) { const loc = useLocation(); const items = () => props.loggedIn ? NAV_ALL : NAV_ALL.slice(0, 1); return ( ); } function TickerSearch(props: { loggedIn: boolean }) { const nav = useNavigate(); const [q, setQ] = createSignal(""); const go = () => { const t = q().toUpperCase().trim(); // Report butuh login: arahkan yg belum login ke /login. if (t) nav(props.loggedIn ? `/report/${t}` : "/login"); }; return (
); } function LoginPage() { const err = () => new URLSearchParams(window.location.search).get("error"); const [mode, setMode] = createSignal<"masuk" | "daftar">("masuk"); const [username, setUsername] = createSignal(""); const [password, setPassword] = createSignal(""); const [busy, setBusy] = createSignal(false); const [formErr, setFormErr] = createSignal(""); const [version] = createResource(() => api.version().catch(() => null)); async function submit(e: Event) { e.preventDefault(); setFormErr(""); setBusy(true); try { if (mode() === "daftar") await api.signup(username().trim(), password()); else await api.login(username().trim(), password()); window.location.href = "/"; } catch (e2) { setFormErr(String(e2)); } finally { setBusy(false); } } return (Login gagal: {err()}