Invitations are users actually...
This commit is contained in:
parent
4b36f167d5
commit
198653ce82
|
@ -1 +0,0 @@
|
|||
export { default } from "./Invitation";
|
|
@ -1 +0,0 @@
|
|||
export { default } from "./Invitations";
|
|
@ -16,7 +16,7 @@ interface Props {
|
|||
values?: any;
|
||||
}
|
||||
|
||||
const Invitation: Component<Props> = (props) => {
|
||||
const User: Component<Props> = (props) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [openDialog, setOpenDialog] = createSignal(false);
|
||||
|
@ -28,20 +28,20 @@ const Invitation: Component<Props> = (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> = (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> = (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> = (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> = (props) => {
|
|||
|
||||
const createUserHandler = async () => {
|
||||
console.log({
|
||||
caller: 'Invitation / createUserHandler',
|
||||
caller: 'User / createUserHandler',
|
||||
props,
|
||||
data: data(),
|
||||
});
|
||||
|
@ -155,7 +155,7 @@ const Invitation: Component<Props> = (props) => {
|
|||
usernamePassword: UsernamePassword
|
||||
) => {
|
||||
console.log({
|
||||
caller: 'Invitation / usernamePasswordHandler',
|
||||
caller: 'User / usernamePasswordHandler',
|
||||
props,
|
||||
usernamePassword,
|
||||
});
|
||||
|
@ -163,7 +163,7 @@ const Invitation: Component<Props> = (props) => {
|
|||
};
|
||||
|
||||
console.log({
|
||||
caller: 'Invitation ',
|
||||
caller: 'User ',
|
||||
props,
|
||||
});
|
||||
|
||||
|
@ -279,4 +279,4 @@ const Invitation: Component<Props> = (props) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default Invitation;
|
||||
export default User;
|
|
@ -0,0 +1 @@
|
|||
export { default } from "./User";
|
|
@ -7,49 +7,49 @@ import { useNavigate } from 'solid-start';
|
|||
|
||||
interface Props {}
|
||||
|
||||
const Invitations: Component<Props> = (props) => {
|
||||
const Users: Component<Props> = (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 (
|
||||
<>
|
||||
<Button.Root onclick={newHandler}>New</Button.Root>
|
||||
<ul>
|
||||
<For each={invitations.result}>
|
||||
{(invitation: any) => {
|
||||
<For each={users.result}>
|
||||
{(user: any) => {
|
||||
console.log({
|
||||
caller: 'Invitations / loop',
|
||||
invitations: invitation,
|
||||
caller: 'Users / loop',
|
||||
users: user,
|
||||
});
|
||||
return (
|
||||
<li>
|
||||
<A href={encodeURIComponent(invitation.id)}>
|
||||
{invitation.doc.mail}
|
||||
<A href={encodeURIComponent(user.id)}>
|
||||
{user.doc.mail}
|
||||
</A>
|
||||
</li>
|
||||
);
|
||||
|
@ -60,4 +60,4 @@ const Invitations: Component<Props> = (props) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default Invitations;
|
||||
export default Users;
|
|
@ -0,0 +1 @@
|
|||
export { default } from "./Users";
|
|
@ -1,10 +0,0 @@
|
|||
import Invitations from "~/components/invitations";
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<main>
|
||||
<h1>Invitations</h1>
|
||||
<Invitations />
|
||||
</main>
|
||||
);
|
||||
};
|
|
@ -1,10 +0,0 @@
|
|||
import Invitation from "~/components/invitation";
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<main>
|
||||
<h1>New invitation</h1>
|
||||
<Invitation />
|
||||
</main>
|
||||
);
|
||||
};
|
|
@ -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 (
|
||||
<main>
|
||||
<h1>Invitation</h1>
|
||||
<Show when={!invitation.pending} fallback={<>Loading...</>}>
|
||||
<Invitation values={invitation.result} />
|
||||
<h1>User</h1>
|
||||
<Show when={!user.pending} fallback={<>Loading...</>}>
|
||||
<User values={user.result} />
|
||||
</Show>
|
||||
</main>
|
||||
);
|
|
@ -0,0 +1,10 @@
|
|||
import Users from "~/components/users";
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<main>
|
||||
<h1>Users</h1>
|
||||
<Users />
|
||||
</main>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
import User from "~/components/user";
|
||||
|
||||
export default () => {
|
||||
return (
|
||||
<main>
|
||||
<h1>New user</h1>
|
||||
<User />
|
||||
</main>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue