Server side form saving.x

This commit is contained in:
Eric van der Vlist 2023-02-21 13:38:43 +01:00
parent 069ba3e281
commit 46135c3a6e
4 changed files with 3300 additions and 83 deletions

3
.gitignore vendored
View File

@ -22,3 +22,6 @@ gitignore
# System Files
.DS_Store
Thumbs.db
# Database
.db/

3360
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,9 @@
"dependencies": {
"@felte/reporter-solid": "^1.2.5",
"@felte/solid": "^1.2.7",
"@kobalte/core": "^0.6.1"
"@kobalte/core": "^0.6.1",
"@types/pouchdb": "^6.4.0",
"pouchdb": "^8.0.1",
"pouchdb-server": "^4.2.0"
}
}

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 });