diff --git a/src/components/invitation/Invitation.tsx b/src/components/invitation/Invitation.tsx index 9ba428b..b0c84f9 100644 --- a/src/components/invitation/Invitation.tsx +++ b/src/components/invitation/Invitation.tsx @@ -10,6 +10,7 @@ import { put } from '~/lib/db'; import { useNavigate } from 'solid-start'; import { toHex } from '~/lib/to-hex'; import { cloneDeep } from 'lodash'; +import Password, { UsernamePassword } from '../password/Password'; interface Props { values?: any; @@ -19,6 +20,8 @@ const Invitation: Component = (props) => { const navigate = useNavigate(); const [openDialog, setOpenDialog] = createSignal(false); + const [openUsernamePasswordDialog, setOpenUserNamePasswordDialog] = + createSignal(false); const [status, setStatus] = createSignal(); @@ -145,6 +148,18 @@ const Invitation: Component = (props) => { props, data: data(), }); + setOpenUserNamePasswordDialog(true); + }; + + const usernamePasswordHandler = async ( + usernamePassword: UsernamePassword + ) => { + console.log({ + caller: 'Invitation / usernamePasswordHandler', + props, + usernamePassword, + }); + setOpenUserNamePasswordDialog(false); }; console.log({ @@ -254,6 +269,12 @@ const Invitation: Component = (props) => { + ); }; diff --git a/src/components/password/Password.tsx b/src/components/password/Password.tsx new file mode 100644 index 0000000..d3a26f5 --- /dev/null +++ b/src/components/password/Password.tsx @@ -0,0 +1,110 @@ +import { createForm } from '@felte/solid'; +import { Button, Dialog, TextField } from '@kobalte/core'; +import { cloneDeep } from 'lodash'; +import { Component, createEffect, createSignal } from 'solid-js'; + +export interface UsernamePassword { + username: string; + password: string; +} + +interface Props { + url: string; + usernamePassword: (params: UsernamePassword) => void; + open: () => boolean; + setOpen: (open: boolean) => void; +} + +const [passwords, setPasswords] = createSignal( + new Map() +); + +const Password: Component = (props) => { + const { url, usernamePassword, open, setOpen } = props; + + const submitHandler = async (values: any, context: any) => { + console.log({ + caller: 'Password / submitHandler', + props, + values, + context, + }); + const unPw = { username: values.username, password: values.password }; + const newPasswords = cloneDeep(passwords()); + newPasswords.set(url, unPw); + setPasswords(newPasswords); + + usernamePassword(unPw); + }; + + let { form, data } = createForm({ + onSubmit: submitHandler, + initialValues: passwords().get(url), + }); + + createEffect(() => { + const unPw = passwords().get(url); + console.log({ + caller: 'Password / createEffect', + props, + passwords: passwords(), + unPw, + }); + const newForm = createForm({ + onSubmit: submitHandler, + initialValues: passwords().get(url), + }); + form = newForm.form; + data = newForm.data; + }); + + return ( + + + +
+ +
+ + Admin user name and password + + + X + +
+ +
Please enter the admin and password for {url}
+
+ + User name + + + + Password + + + Please provide a valid password + + + Save and create +
+
+
+
+
+
+ ); +}; + +export default Password; diff --git a/src/components/password/index.ts b/src/components/password/index.ts new file mode 100644 index 0000000..e15b6dd --- /dev/null +++ b/src/components/password/index.ts @@ -0,0 +1 @@ +export { default, UsernamePassword } from './Password';