Skip to content

A local-first personal finance app

feat: creating test budget on the config page

Matiss Janis Aboltins4d1a51421028
diff --git a/packages/desktop-client/src/components/manager/ConfigServer.js b/packages/desktop-client/src/components/manager/ConfigServer.js
index 86ece34bf4..408927c2b3 100644
--- a/packages/desktop-client/src/components/manager/ConfigServer.js
+++ b/packages/desktop-client/src/components/manager/ConfigServer.js
@@ -2,6 +2,7 @@ import React, { useState, useEffect } from 'react';
import { useDispatch } from 'react-redux';
import { useHistory } from 'react-router-dom';
+import { createBudget } from 'loot-core/src/client/actions/budgets';
import { signOut, loggedIn } from 'loot-core/src/client/actions/user';
import { send } from 'loot-core/src/platform/client/fetch';
import {
@@ -11,6 +12,10 @@ import {
ButtonWithLoading
} from 'loot-design/src/components/common';
import { colors } from 'loot-design/src/style';
+import {
+ isDevelopmentEnvironment,
+ isPreviewEnvironment
+} from 'loot-design/src/util/environment';
import { useServerURL } from '../../hooks/useServerURL';
import { Title, Input } from './subscribe/common';
@@ -78,6 +83,11 @@ export default function ConfigServer() {
history.push('/');
}
+ async function onCreateTestFile() {
+ await dispatch(createBudget({ testMode: true }));
+ await onSkip();
+ }
+
return (
<>
<View style={{ width: 500, marginTop: -30 }}>
@@ -169,6 +179,16 @@ export default function ConfigServer() {
<Button bare style={{ color: colors.n4 }} onClick={onSkip}>
Don't use a server
</Button>
+
+ {(isDevelopmentEnvironment() || isPreviewEnvironment()) && (
+ <Button
+ primary
+ style={{ marginLeft: 15 }}
+ onClick={onCreateTestFile}
+ >
+ Create test file
+ </Button>
+ )}
</>
)}
</View>