full switch to jotai, finishes schema version query fixes

This commit is contained in:
2024-09-05 05:22:29 -06:00
parent b529445851
commit 84cbea8ce1
12 changed files with 148 additions and 91 deletions

View File

@@ -1,15 +1,14 @@
// import { useRecoilValue } from "recoil";
import { SchemaEditAtom } from "../../recoil/atoms/schema";
import { TEMPLATE_TYPES } from "../../constants/TemplateTypes";
import { FC, PropsWithChildren } from "react";
import { useAtom } from "jotai";
import { InputBinder } from "@/types";
interface IProps {
bind: InputBinder;
}
export const FieldTypeInput: FC<PropsWithChildren<IProps>> = ({ bind }) => {
// const schema = useRecoilValue(SchemaEditAtom);
const [schema] = useAtom(SchemaEditAtom);
return (

View File

@@ -14,10 +14,10 @@ import { FieldTypes } from "./fieldtypes";
import { findSchema, saveSchemaDb } from "@/actions/Schemas/index";
import { useToast } from "../toast";
import { useAtom } from "jotai";
import { Schema } from "@/types";
import { Schema, TypeType } from "@/types";
export const SchemaBuilder: FC = () => {
const [schema, setSchema] = useAtom(SchemaEditAtom);
const [schema, setSchema] = useAtom<Schema>(SchemaEditAtom);
// const resetSchema = useResetRecoilState(SchemaEditAtom);
const { createToast } = useToast();
const { update: updateSchema, bindProperty: bindSchemaProperty } =
@@ -30,7 +30,7 @@ export const SchemaBuilder: FC = () => {
useEffect(() => {
if (schemaId !== "create" && schemaId !== schema.id)
findSchema(schemaId).then((sc) => {
findSchema(schemaId, 0).then((sc) => {
if (!sc) return;
setSchema(sc);
});
@@ -70,7 +70,7 @@ export const SchemaBuilder: FC = () => {
const saveSchema = useCallback(async () => {
createToast({ msg: "Saving Schema", fading: true });
await saveSchemaDb(schema);
await saveSchemaDb(schema, schema.version);
}, [createToast, schema]);
const selectTypeForEdit = useCallback((typeKey: string) => {