import { createResource, createSignal, For, Show } from "solid-js"; import { api } from "../lib/api"; import { Citations } from "../components/Citations"; export default function Routines() { const [data, { refetch }] = createResource(() => api.routines()); const [runs, { refetch: refetchRuns }] = createResource(() => api.runs().then((r) => r.runs.slice(0, 20))); const [type_, setType] = createSignal("morning-briefing"); const [schedule, setSchedule] = createSignal(""); const [channels, setChannels] = createSignal(""); const [briefing] = createResource(() => api.briefing().catch(() => null)); async function subscribe() { await api.createRoutine({ type: type_(), schedule_cron: schedule().trim() || undefined, channels: channels().split(",").map((c) => c.trim()).filter(Boolean), }); refetch(); } async function toggle(id: number, enabled: boolean) { await api.updateRoutine(id, { enabled: !enabled }); refetch(); } return (
No routines yet.
{(briefing() as { payload: string })?.payload?.slice(0, 800)}