Still progressing...
This commit is contained in:
parent
5dbf080190
commit
1d6c3a858d
|
@ -16,6 +16,7 @@ import dispatch from '../../workers/dispatcher-main';
|
||||||
import allGpxes from '../all-gpxes';
|
import allGpxes from '../all-gpxes';
|
||||||
import gpx from '../gpx';
|
import gpx from '../gpx';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
|
import { getAccountById } from '../../db/account';
|
||||||
|
|
||||||
const Account: Component<{}> = (props) => {
|
const Account: Component<{}> = (props) => {
|
||||||
const [t] = useI18n();
|
const [t] = useI18n();
|
||||||
|
@ -34,6 +35,9 @@ const Account: Component<{}> = (props) => {
|
||||||
action: 'getAccounts',
|
action: 'getAccounts',
|
||||||
});
|
});
|
||||||
setAccounts([{ id: '--new--', name: t('newAccount') }, ...newAccounts]);
|
setAccounts([{ id: '--new--', name: t('newAccount') }, ...newAccounts]);
|
||||||
|
setAccount(
|
||||||
|
cloneDeep(getAccountById(accounts(), settings().currentAccountId))
|
||||||
|
);
|
||||||
|
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'Account / handleClickOpen',
|
caller: 'Account / handleClickOpen',
|
||||||
|
@ -54,15 +58,12 @@ const Account: Component<{}> = (props) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeAccountHandler = (event: any) => {
|
const changeAccountHandler = (event: any) => {
|
||||||
const selectedAccountName = event.target.value;
|
const selectedAccountId = event.target.value;
|
||||||
const targetAccount =
|
setAccount(cloneDeep(getAccountById(accounts(), selectedAccountId)));
|
||||||
accounts().filter((acc: any) => acc.name === selectedAccountName)[0] ||
|
|
||||||
{};
|
|
||||||
setAccount(cloneDeep(targetAccount));
|
|
||||||
console.log({
|
console.log({
|
||||||
caller: 'Account / changeAccountHandler',
|
caller: 'Account / changeAccountHandler',
|
||||||
event,
|
event,
|
||||||
selectedAccountName,
|
selectedAccountName: selectedAccountId,
|
||||||
account: account(),
|
account: account(),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -115,7 +116,10 @@ const Account: Component<{}> = (props) => {
|
||||||
>
|
>
|
||||||
<For each={accounts()}>
|
<For each={accounts()}>
|
||||||
{(account: any) => (
|
{(account: any) => (
|
||||||
<option value={account.id} selected={account.id === ''}>
|
<option
|
||||||
|
value={account.id}
|
||||||
|
selected={account.id === settings().currentAccountId}
|
||||||
|
>
|
||||||
{account.name}
|
{account.name}
|
||||||
</option>
|
</option>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue