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.
28 lines
612 B
TypeScript
28 lines
612 B
TypeScript
import { unreachable } from "../../../common/lib/dev.ts";
|
|
import { Const, ReturnTypes } from "../../../common/utils.ts";
|
|
import { ViewState } from "../App/view.ts";
|
|
import { State } from "./view.ts";
|
|
|
|
export const newSchema = () => ({ kind: "newSchema" as const });
|
|
export type Action = ReturnTypes<[typeof newSchema]>;
|
|
|
|
export const reduce = (
|
|
state: Const<State>,
|
|
action: Action,
|
|
): Const<ViewState> => {
|
|
if (action.kind == "newSchema") {
|
|
return {
|
|
kind: "SchemaEditor",
|
|
state: {
|
|
schema: {
|
|
fields: [],
|
|
name: "New schema",
|
|
},
|
|
errors: {},
|
|
},
|
|
};
|
|
}
|
|
|
|
return unreachable();
|
|
};
|