import { createForm } from '@felte/solid'; import { Component, createEffect, Match, Show, Switch } from 'solid-js'; import { TextField, Button } from '@kobalte/core'; import './style.css'; import { createServerAction$ } from 'solid-start/server'; import PouchDb from 'pouchdb'; import { v4 as uuid } from 'uuid'; import { put } from '~/lib/db'; import { useNavigate } from 'solid-start'; interface Props { values?: any; } const Invitation: Component = (props) => { const navigate = useNavigate(); const [saving, save] = createServerAction$(async (args: any) => { const { props, values } = args; console.log({ caller: 'Invitation / save', props, values, args, }); const db = new PouchDb('.db'); const id = props.values?.id ?? `invitation/${uuid()}`; await put({ db, doc: { _id: id, date: new Date().toISOString(), type: 'invitation', ...values, }, }); return id; }); const submitHandler = async (values: any, context: any) => { console.log({ caller: 'Invitation / submitHandler', props, values, context, }); const id = await save({ values, props }); if (!props.values) { navigate(`/invitations/${encodeURIComponent(id)}`); } }; let { form } = createForm({ onSubmit: submitHandler, initialValues: props?.values, }); console.log({ caller: 'Invitation ', props, }); return (
Mail address Please provide a valid URL Database Please provide a valid URL Password Please provide a valid password Create}> Save
); }; export default Invitation;