Saving the new account
This commit is contained in:
parent
87b6e1710d
commit
a32faaa837
|
@ -7,6 +7,8 @@ import {
|
|||
Typography,
|
||||
} from '@suid/material';
|
||||
import { Component, createEffect, createSignal, Show } from 'solid-js';
|
||||
import { parseUserId } from '../../lib/user-id';
|
||||
import dispatch from '../../workers/dispatcher-main';
|
||||
import Dialog from '../dialog';
|
||||
|
||||
interface props {}
|
||||
|
@ -18,6 +20,18 @@ const fetchInvitation = () => {
|
|||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
setInvitation({ ...invitation(), data });
|
||||
return invitation();
|
||||
})
|
||||
.then(() => {
|
||||
dispatch({
|
||||
action: 'getAccount',
|
||||
params: { id: invitation().data.id },
|
||||
}).then((account) => {
|
||||
console.log({ caller: 'Invitation / fetchInvitation', account });
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error({ caller: 'Invitation / fetchInvitation', error });
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -63,6 +77,18 @@ const Invitation: Component<props> = (props) => {
|
|||
failure: codeData.response !== 'OK',
|
||||
success: codeData.response === 'OK',
|
||||
});
|
||||
const user = invitation().codeData.user;
|
||||
const id = user._id;
|
||||
const account = {
|
||||
id,
|
||||
localDb: id,
|
||||
name: id,
|
||||
remoteDbServer: user.database,
|
||||
remoteDbUser: user.username,
|
||||
remoteDbPassword: user.password,
|
||||
mail: user.mail,
|
||||
};
|
||||
dispatch({ action: 'putAccount', params: { id, account } });
|
||||
} catch (error) {
|
||||
setInvitation({
|
||||
...invitation(),
|
||||
|
|
|
@ -15,6 +15,7 @@ export const getAccounts = async () => {
|
|||
|
||||
export const getAccount = async (params: any) => {
|
||||
const { id } = params;
|
||||
console.log({ caller: 'getAccount', params });
|
||||
const uri = getUri('account', { account: id });
|
||||
return (await get(uri, true)).doc;
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ import { initDb } from '../db';
|
|||
import {
|
||||
getAccounts,
|
||||
getCurrentAccount,
|
||||
getAccount,
|
||||
putAccount,
|
||||
putCurrentAccount,
|
||||
} from '../db/account';
|
||||
|
@ -69,6 +70,7 @@ onmessage = async function (e) {
|
|||
putSettings,
|
||||
|
||||
getAccounts,
|
||||
getAccount,
|
||||
putAccount,
|
||||
getCurrentAccount,
|
||||
putCurrentAccount,
|
||||
|
|
Loading…
Reference in New Issue