Server side form saving.x

This commit is contained in:
vdv committed 2023-02-21 13:38:43 +01:00
1 parent 069ba3e281
commit 46135c3a6e
4 files changed
+3300 -83

No files matched your search

+14 -1
View File
@@ -1,12 +1,24 @@
import { createForm } from "@felte/solid";
import { Component } from "solid-js";
import { Component, createUniqueId } from "solid-js";
import { TextField, Button } from "@kobalte/core";
import "./style.css";
import { createServerAction$ } from "solid-start/server";
import PouchDb from "pouchdb";
interface Props {}
const Invitation: Component<Props> = (props) => {
const [saving, save] = createServerAction$(async (values: any) => {
const db = new PouchDb(".db");
const uuid = createUniqueId();
await db.put({
_id: `invitation/${uuid}`,
type: "invitation",
doc: values,
});
});
const submitHandler = (values: any, context: any) => {
console.log({
caller: "Invitation / submitHandler",
@@ -14,6 +26,7 @@ const Invitation: Component<Props> = (props) => {
values,
context,
});
save(values);
};
const { form } = createForm({ onSubmit: submitHandler });