diff --git a/src/components/invitation/index.ts b/src/components/invitation/index.ts deleted file mode 100644 index eaae8d2..0000000 --- a/src/components/invitation/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./Invitation"; diff --git a/src/components/invitations/index.ts b/src/components/invitations/index.ts deleted file mode 100644 index cb3587b..0000000 --- a/src/components/invitations/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from "./Invitations"; diff --git a/src/components/invitation/Invitation.tsx b/src/components/user/User.tsx similarity index 92% rename from src/components/invitation/Invitation.tsx rename to src/components/user/User.tsx index b0c84f9..4aa7de9 100644 --- a/src/components/invitation/Invitation.tsx +++ b/src/components/user/User.tsx @@ -16,7 +16,7 @@ interface Props { values?: any; } -const Invitation: Component = (props) => { +const User: Component = (props) => { const navigate = useNavigate(); const [openDialog, setOpenDialog] = createSignal(false); @@ -28,20 +28,20 @@ const Invitation: Component = (props) => { const [saving, save] = createServerAction$(async (args: any) => { const { props, values } = args; console.log({ - caller: 'Invitation / save', + caller: 'User / save', props, values, args, id: props.values?._id, }); const db = new PouchDb('.db'); - const id = props.values?._id ?? `invitation/${uuid()}`; + const id = props.values?._id ?? `user/${uuid()}`; await put({ db, doc: { _id: id, date: new Date().toISOString(), - type: 'invitation', + type: 'user', ...values, }, }); @@ -50,7 +50,7 @@ const Invitation: Component = (props) => { const [dbChecking, dbCheck] = createServerAction$(async (args: any) => { console.log({ - caller: 'Invitation / dbCheck', + caller: 'User / dbCheck', args, }); let baseDbInfoAuth; @@ -87,28 +87,28 @@ const Invitation: Component = (props) => { const submitHandler = async (values: any, context: any) => { console.log({ - caller: 'Invitation / submitHandler', + caller: 'User / submitHandler', props, values, context, }); const id = await save({ values, props }); if (!props.values) { - navigate(`/invitations/${encodeURIComponent(id)}`); + navigate(`/user/${encodeURIComponent(id)}`); } }; const cancelHandler = () => { - navigate(`/invitations/`); + navigate(`/user/`); }; const deleteHandler = async () => { console.log({ - caller: 'Invitation / deleteHandler', + caller: 'User / deleteHandler', props, }); await save({ props, values: { _deleted: true } }); - navigate(`/invitations/`); + navigate(`/user/`); }; const { form, data } = createForm({ @@ -122,7 +122,7 @@ const Invitation: Component = (props) => { auth: { username: data('username'), password: data('password') }, }); console.log({ - caller: 'Invitation / dbCheckHandler', + caller: 'User / dbCheckHandler', props, data: data(), result, @@ -144,7 +144,7 @@ const Invitation: Component = (props) => { const createUserHandler = async () => { console.log({ - caller: 'Invitation / createUserHandler', + caller: 'User / createUserHandler', props, data: data(), }); @@ -155,7 +155,7 @@ const Invitation: Component = (props) => { usernamePassword: UsernamePassword ) => { console.log({ - caller: 'Invitation / usernamePasswordHandler', + caller: 'User / usernamePasswordHandler', props, usernamePassword, }); @@ -163,7 +163,7 @@ const Invitation: Component = (props) => { }; console.log({ - caller: 'Invitation ', + caller: 'User ', props, }); @@ -279,4 +279,4 @@ const Invitation: Component = (props) => { ); }; -export default Invitation; +export default User; diff --git a/src/components/user/index.ts b/src/components/user/index.ts new file mode 100644 index 0000000..1dcc83d --- /dev/null +++ b/src/components/user/index.ts @@ -0,0 +1 @@ +export { default } from "./User"; diff --git a/src/components/invitation/style.css b/src/components/user/style.css similarity index 100% rename from src/components/invitation/style.css rename to src/components/user/style.css diff --git a/src/components/invitations/Invitations.tsx b/src/components/users/Users.tsx similarity index 57% rename from src/components/invitations/Invitations.tsx rename to src/components/users/Users.tsx index c7042ab..ee22e79 100644 --- a/src/components/invitations/Invitations.tsx +++ b/src/components/users/Users.tsx @@ -7,49 +7,49 @@ import { useNavigate } from 'solid-start'; interface Props {} -const Invitations: Component = (props) => { +const Users: Component = (props) => { const navigate = useNavigate(); - const [invitations, getInvitations] = createServerAction$( + const [users, getUsers] = createServerAction$( async (values: any) => { const db = new PouchDb('.db'); const results = await db.allDocs({ include_docs: true, - startkey: 'invitation/', - endkey: 'invitation/\ufff0', + startkey: 'user/', + endkey: 'user/\ufff0', }); - console.log({ caller: 'Invitations / serverAction', results }); + console.log({ caller: 'Users / serverAction', results }); return results.rows; } ); - getInvitations(); + getUsers(); createEffect(() => { console.log({ - caller: 'Invitations', - invitations: invitations.result, + caller: 'Users', + users: users.result, }); }); const newHandler = () => { - navigate('/invitations/new'); + navigate('/user/new'); }; return ( <> New
    - - {(invitation: any) => { + + {(user: any) => { console.log({ - caller: 'Invitations / loop', - invitations: invitation, + caller: 'Users / loop', + users: user, }); return (
  • - - {invitation.doc.mail} + + {user.doc.mail}
  • ); @@ -60,4 +60,4 @@ const Invitations: Component = (props) => { ); }; -export default Invitations; +export default Users; diff --git a/src/components/users/index.ts b/src/components/users/index.ts new file mode 100644 index 0000000..d25de51 --- /dev/null +++ b/src/components/users/index.ts @@ -0,0 +1 @@ +export { default } from "./Users"; diff --git a/src/routes/invitations/index.tsx b/src/routes/invitations/index.tsx deleted file mode 100644 index c427b96..0000000 --- a/src/routes/invitations/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import Invitations from "~/components/invitations"; - -export default () => { - return ( -
    -

    Invitations

    - -
    - ); -}; diff --git a/src/routes/invitations/new.tsx b/src/routes/invitations/new.tsx deleted file mode 100644 index d598c07..0000000 --- a/src/routes/invitations/new.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import Invitation from "~/components/invitation"; - -export default () => { - return ( -
    -

    New invitation

    - -
    - ); -}; diff --git a/src/routes/invitations/[id].tsx b/src/routes/user/[id].tsx similarity index 52% rename from src/routes/invitations/[id].tsx rename to src/routes/user/[id].tsx index 5d3b02f..3576d8a 100644 --- a/src/routes/invitations/[id].tsx +++ b/src/routes/user/[id].tsx @@ -1,35 +1,35 @@ import { useParams } from 'solid-start'; import { createServerAction$ } from 'solid-start/server'; import PouchDb from 'pouchdb'; -import Invitation from '~/components/invitation'; +import User from '~/components/user'; import { createEffect, Show } from 'solid-js'; export default () => { const params = useParams(); - const [invitation, getInvitation] = createServerAction$( + const [user, getUser] = createServerAction$( async (id: string) => { const db = new PouchDb('.db'); const result = await db.get(id); - console.log({ caller: 'Invitations / serverAction', result }); + console.log({ caller: 'Users / serverAction', result }); return result; } ); - getInvitation(decodeURIComponent(params.id)); + getUser(decodeURIComponent(params.id)); createEffect(() => { console.log({ - caller: 'Invitations/[id]', + caller: 'Users/[id]', params, - invitation: invitation.result, + user: user.result, }); }); return (
    -

    Invitation

    - Loading...}> - +

    User

    + Loading...}> +
    ); diff --git a/src/routes/user/index.tsx b/src/routes/user/index.tsx new file mode 100644 index 0000000..bbb6160 --- /dev/null +++ b/src/routes/user/index.tsx @@ -0,0 +1,10 @@ +import Users from "~/components/users"; + +export default () => { + return ( +
    +

    Users

    + +
    + ); +}; diff --git a/src/routes/user/new.tsx b/src/routes/user/new.tsx new file mode 100644 index 0000000..59524b9 --- /dev/null +++ b/src/routes/user/new.tsx @@ -0,0 +1,10 @@ +import User from "~/components/user"; + +export default () => { + return ( +
    +

    New user

    + +
    + ); +};