Store the current gpx id in account docs
This commit is contained in:
1 parent
8d32fa253a
commit
51ab7c38e0
3 files changed
+41
-3
No files matched your search
+19
-1
@@ -1,5 +1,6 @@
|
||||
import { getFamily, put } from './lib';
|
||||
import { get, getFamily, put } from './lib';
|
||||
import getUri from '../lib/ids';
|
||||
import { getSettings, putSettings } from './settings';
|
||||
|
||||
export const initialAccount = {
|
||||
id: 'initial',
|
||||
@@ -12,6 +13,12 @@ export const getAccounts = async () => {
|
||||
return accountDocs.rows.map((row: any) => row.doc.doc);
|
||||
};
|
||||
|
||||
export const getAccount = async (params: any) => {
|
||||
const { id } = params;
|
||||
const uri = getUri('account', { account: id });
|
||||
return (await get(uri, true)).doc;
|
||||
};
|
||||
|
||||
export const putAccount = async (params: any) => {
|
||||
const { id, account } = params;
|
||||
const uri = getUri('account', { account: id });
|
||||
@@ -22,3 +29,14 @@ export const getAccountById = (accounts: any, id: string) => {
|
||||
const targetAccounts: any[] = accounts.filter((acc: any) => acc.id === id);
|
||||
return targetAccounts[0];
|
||||
};
|
||||
|
||||
export const getCurrentAccount = async (params: any) => {
|
||||
const settings = await getSettings();
|
||||
return await getAccount({ id: settings.currentAccountId });
|
||||
};
|
||||
|
||||
export const putCurrentAccount = async (params: any) => {
|
||||
const { account } = params;
|
||||
const settings = await getSettings();
|
||||
await putAccount({ id: settings.currentAccountId, account });
|
||||
};
|
||||
Reference in new issue
Block a user