Server side form saving.x
This commit is contained in:
parent
069ba3e281
commit
46135c3a6e
|
@ -22,3 +22,6 @@ gitignore
|
||||||
# System Files
|
# System Files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# Database
|
||||||
|
.db/
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,6 +30,9 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@felte/reporter-solid": "^1.2.5",
|
"@felte/reporter-solid": "^1.2.5",
|
||||||
"@felte/solid": "^1.2.7",
|
"@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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
import { createForm } from "@felte/solid";
|
import { createForm } from "@felte/solid";
|
||||||
import { Component } from "solid-js";
|
import { Component, createUniqueId } from "solid-js";
|
||||||
import { TextField, Button } from "@kobalte/core";
|
import { TextField, Button } from "@kobalte/core";
|
||||||
|
|
||||||
import "./style.css";
|
import "./style.css";
|
||||||
|
import { createServerAction$ } from "solid-start/server";
|
||||||
|
import PouchDb from "pouchdb";
|
||||||
|
|
||||||
interface Props {}
|
interface Props {}
|
||||||
|
|
||||||
const Invitation: Component<Props> = (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) => {
|
const submitHandler = (values: any, context: any) => {
|
||||||
console.log({
|
console.log({
|
||||||
caller: "Invitation / submitHandler",
|
caller: "Invitation / submitHandler",
|
||||||
|
@ -14,6 +26,7 @@ const Invitation: Component<Props> = (props) => {
|
||||||
values,
|
values,
|
||||||
context,
|
context,
|
||||||
});
|
});
|
||||||
|
save(values);
|
||||||
};
|
};
|
||||||
|
|
||||||
const { form } = createForm({ onSubmit: submitHandler });
|
const { form } = createForm({ onSubmit: submitHandler });
|
||||||
|
|
Loading…
Reference in New Issue