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

+3
View File
@@ -22,3 +22,6 @@ gitignore
# System Files
.DS_Store
Thumbs.db
# Database
.db/
+3279 -81
View File
File diff suppressed because it is too large. Load diff
+4 -1
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"
}
}
+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 });