Skip to content

A local-first personal finance app

Display Goal/Target Information on Mobile (#4546)

tempizca5cd55585d3
diff --git a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
index 45c0859c2c..298ad7a2a9 100644
--- a/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
+++ b/packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
@@ -86,6 +86,7 @@ type BalanceWithCarryoverProps = Omit<
budgeted: Binding<'envelope-budget', 'budget'>;
longGoal: Binding<'envelope-budget', 'long-goal'>;
isDisabled?: boolean;
+ isMobileEnvelopeModal?: boolean;
CarryoverIndicator?: ComponentType<CarryoverIndicatorProps>;
};
@@ -96,6 +97,7 @@ export function BalanceWithCarryover({
budgeted,
longGoal,
isDisabled,
+ isMobileEnvelopeModal,
CarryoverIndicator: CarryoverIndicatorComponent = CarryoverIndicator,
children,
...props
@@ -140,6 +142,97 @@ export function BalanceWithCarryover({
}),
[getBalanceAmountStyle, isDisabled],
);
+ const GoalStatusDisplay = useCallback(
+ (balanceValue, type) => {
+ return (
+ <>
+ <span style={{ fontWeight: 'bold' }}>
+ {getDifferenceToGoal(balanceValue) === 0 ? (
+ <span style={{ color: theme.noticeText }}>
+ <Trans>Fully funded</Trans>
+ </span>
+ ) : getDifferenceToGoal(balanceValue) > 0 ? (
+ <span style={{ color: theme.noticeText }}>
+ <Trans>
+ Overfunded (
+ {{
+ amount: format(
+ getDifferenceToGoal(balanceValue),
+ 'financial',
+ ),
+ }}
+ )
+ </Trans>
+ </span>
+ ) : (
+ <span style={{ color: theme.errorText }}>
+ <Trans>
+ Underfunded (
+ {{
+ amount: format(
+ getDifferenceToGoal(balanceValue),
+ 'financial',
+ ),
+ }}
+ )
+ </Trans>
+ </span>
+ )}
+ </span>
+ <GoalTooltipRow>
+ <Trans>
+ <div>Goal Type:</div>
+ <div>
+ {
+ {
+ type: longGoalValue === 1 ? t('Long') : t('Template'),
+ } as TransObjectLiteral
+ }
+ </div>
+ </Trans>
+ </GoalTooltipRow>
+ <GoalTooltipRow>
+ <Trans>
+ <div>Goal:</div>
+ <div>
+ {
+ {
+ amount: format(goalValue, 'financial'),
+ } as TransObjectLiteral
+ }
+ </div>
+ </Trans>
+ </GoalTooltipRow>
+ <GoalTooltipRow>
+ {longGoalValue !== 1 ? (
+ <Trans>
+ <div>Budgeted:</div>
+ <div>
+ {
+ {
+ amount: format(budgetedValue, 'financial'),
+ } as TransObjectLiteral
+ }
+ </div>
+ </Trans>
+ ) : (
+ <Trans>
+ <div>Balance:</div>
+ <div>
+ {
+ {
+ amount: format(balanceValue, type),
+ } as TransObjectLiteral
+ }
+ </div>
+ </Trans>
+ )}
+ </GoalTooltipRow>
+ </>
+ );
+ },
+ [budgetedValue, format, getDifferenceToGoal, goalValue, longGoalValue, t],
+ );
return (
<CellValue binding={balance} type="financial" {...props}>
@@ -148,88 +241,7 @@ export function BalanceWithCarryover({
<Tooltip
content={
<View style={{ padding: 10 }}>
- <span style={{ fontWeight: 'bold' }}>
- {getDifferenceToGoal(balanceValue) === 0 ? (
- <span style={{ color: theme.noticeText }}>
- <Trans>Fully funded</Trans>
- </span>
- ) : getDifferenceToGoal(balanceValue) > 0 ? (
- <span style={{ color: theme.noticeText }}>
- <Trans>
- Overfunded (
- {{
- amount: format(
- getDifferenceToGoal(balanceValue),
- 'financial',
- ),
- }}
- )
- </Trans>
- </span>
- ) : (
- <span style={{ color: theme.errorText }}>
- <Trans>
- Underfunded (
- {{
- amount: format(
- getDifferenceToGoal(balanceValue),
- 'financial',
- ),
- }}
- )
- </Trans>
- </span>
- )}
- </span>
- <GoalTooltipRow>
- <Trans>
- <div>Goal Type:</div>
- <div>
- {
- {
- type: longGoalValue === 1 ? t('Long') : t('Template'),
- } as TransObjectLiteral
- }
- </div>
- </Trans>
- </GoalTooltipRow>
- <GoalTooltipRow>
- <Trans>
- <div>Goal:</div>
- <div>
- {
- {
- amount: format(goalValue, 'financial'),
- } as TransObjectLiteral
- }
- </div>
- </Trans>
- </GoalTooltipRow>
- <GoalTooltipRow>
- {longGoalValue !== 1 ? (
- <Trans>
- <div>Budgeted:</div>
- <div>
- {
- {
- amount: format(budgetedValue, 'financial'),
- } as TransObjectLiteral
- }
- </div>
- </Trans>
- ) : (
- <Trans>
- <div>Balance:</div>
- <div>
- {
- {
- amount: format(balanceValue, type),
- } as TransObjectLiteral
- }
- </div>
- </Trans>
- )}
- </GoalTooltipRow>
+ {GoalStatusDisplay(balanceValue, type)}
</View>
}
style={{ ...styles.tooltip, borderRadius: '0px 5px 5px 0px' }}
@@ -262,6 +274,20 @@ export function BalanceWithCarryover({
style={getBalanceAmountStyle(balanceValue)}
/>
)}
+ {isMobileEnvelopeModal &&
+ isGoalTemplatesEnabled &&
+ goalValue !== null && (
+ <>
+ <View
+ style={{
+ borderTop: '1px solid ' + theme.tableBorderSeparator,
+ width: '160px',
+ margin: '3px 0px',
+ }}
+ />
+ <View>{GoalStatusDisplay(balanceValue, type)}</View>
+ </>
+ )}
</>
)}
</CellValue>
diff --git a/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx b/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
index 51ff6d5337..c399a53e9b 100644
--- a/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
+++ b/packages/desktop-client/src/components/modals/EnvelopeBalanceMenuModal.tsx
@@ -73,6 +73,7 @@ export function EnvelopeBalanceMenuModal({
</Text>
<BalanceWithCarryover
isDisabled
+ isMobileEnvelopeModal
carryover={envelopeBudget.catCarryover(categoryId)}
balance={envelopeBudget.catBalance(categoryId)}
goal={envelopeBudget.catGoal(categoryId)}
diff --git a/upcoming-release-notes/4546.md b/upcoming-release-notes/4546.md
new file mode 100644
index 0000000000..0bece9c927
--- /dev/null
+++ b/upcoming-release-notes/4546.md
@@ -0,0 +1,6 @@
+---
+category: Enhancements
+authors: [tempiz]
+---
+
+Display goal & target info on mobile.
\ No newline at end of file