Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display Goal/Target Information on Mobile #4546

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 106 additions & 82 deletions packages/desktop-client/src/components/budget/BalanceWithCarryover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
};

Expand All @@ -96,6 +97,7 @@ export function BalanceWithCarryover({
budgeted,
longGoal,
isDisabled,
isMobileEnvelopeModal,
CarryoverIndicator: CarryoverIndicatorComponent = CarryoverIndicator,
children,
...props
Expand Down Expand Up @@ -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}>
Expand All @@ -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' }}
Expand Down Expand Up @@ -262,6 +274,18 @@ export function BalanceWithCarryover({
style={getBalanceAmountStyle(balanceValue)}
/>
)}
{isMobileEnvelopeModal &&
isGoalTemplatesEnabled &&
goalValue !== null && (
<>
<hr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<hr> is not used in the codebase.
Please check how separators are done in this component:

<View key={idx} style={{ margin: '3px 0px' }}>
<View style={{ borderTop: '1px solid ' + theme.menuBorder }} />
</View>
)

style={{
width: '50%',
}}
/>
<div>{GoalStatusDisplay(balanceValue, type)}</div>
</>
)}
</>
)}
</CellValue>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export function EnvelopeBalanceMenuModal({
</Text>
<BalanceWithCarryover
isDisabled
isMobileEnvelopeModal
carryover={envelopeBudget.catCarryover(categoryId)}
balance={envelopeBudget.catBalance(categoryId)}
goal={envelopeBudget.catGoal(categoryId)}
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/4546.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [tempiz]
---

Display goal & target info on mobile.