You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
825 B
TypeScript
37 lines
825 B
TypeScript
import { h } from "preact";
|
|
import { Dispatch } from "../../utils.ts";
|
|
import { Action } from "./state.ts";
|
|
import { assert } from "../../../common/deps/yaypi.ts";
|
|
import { Loader, useAsync } from "../../useAsync.ts";
|
|
import { Client } from "../../client.ts";
|
|
|
|
export const Schemas = (p: unknown) => {
|
|
return h("div", {}, "schemas loaded");
|
|
};
|
|
|
|
export const Home = (p: { dispatch: Dispatch<Action>; client: Client }) => {
|
|
const button = h(
|
|
"button",
|
|
{
|
|
onClick: () => p.dispatch({ kind: "editNewSchema" }),
|
|
},
|
|
"New schema",
|
|
);
|
|
|
|
const schemas = h(Loader, {
|
|
fn: async () => assert(await p.client.v1.listSchemas(null)),
|
|
args: [],
|
|
renderLoaded: Schemas,
|
|
});
|
|
|
|
const b = h(
|
|
"button",
|
|
{
|
|
onClick: () => p.dispatch({ kind: "hello" }),
|
|
},
|
|
"Say hello",
|
|
);
|
|
|
|
return h("div", {}, schemas, button, b);
|
|
};
|