-
-
Notifications
You must be signed in to change notification settings - Fork 960
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
faba272
commit 56ca8bc
Showing
31 changed files
with
609 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/desktop-client/src/components/budget/report/CategoryBudgetMenu.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import type React, { ComponentPropsWithoutRef } from 'react'; | ||
|
||
import { useFeatureFlag } from '../../../hooks/useFeatureFlag'; | ||
import { Menu } from '../../common/Menu'; | ||
|
||
type CategoryBudgetMenuProps = Omit< | ||
ComponentPropsWithoutRef<typeof Menu>, | ||
'onMenuSelect' | 'items' | ||
> & { | ||
onCopyLastMonthAverage: () => void; | ||
onSetMonthsAverage: (numberOfMonths: number) => void; | ||
onApplyBudgetTemplate: () => void; | ||
}; | ||
export function CategoryBudgetMenu({ | ||
onCopyLastMonthAverage, | ||
onSetMonthsAverage, | ||
onApplyBudgetTemplate, | ||
...props | ||
}: CategoryBudgetMenuProps) { | ||
const isGoalTemplatesEnabled = useFeatureFlag('goalTemplatesEnabled'); | ||
const onMenuSelect = (name: string) => { | ||
switch (name) { | ||
case 'copy-single-last': | ||
onCopyLastMonthAverage?.(); | ||
break; | ||
case 'set-single-3-avg': | ||
onSetMonthsAverage?.(3); | ||
break; | ||
case 'set-single-6-avg': | ||
onSetMonthsAverage?.(6); | ||
break; | ||
case 'set-single-12-avg': | ||
onSetMonthsAverage?.(12); | ||
break; | ||
case 'apply-single-category-template': | ||
onApplyBudgetTemplate?.(); | ||
break; | ||
default: | ||
throw new Error(`Unrecognized menu item: ${name}`); | ||
} | ||
}; | ||
|
||
return ( | ||
<Menu | ||
{...props} | ||
onMenuSelect={onMenuSelect} | ||
items={[ | ||
{ | ||
name: 'copy-single-last', | ||
text: 'Copy last month’s budget', | ||
}, | ||
{ | ||
name: 'set-single-3-avg', | ||
text: 'Set to 3 month average', | ||
}, | ||
{ | ||
name: 'set-single-6-avg', | ||
text: 'Set to 6 month average', | ||
}, | ||
{ | ||
name: 'set-single-12-avg', | ||
text: 'Set to yearly average', | ||
}, | ||
...(isGoalTemplatesEnabled | ||
? [ | ||
{ | ||
name: 'apply-single-category-template', | ||
text: 'Apply budget template', | ||
}, | ||
] | ||
: []), | ||
]} | ||
/> | ||
); | ||
} |
Oops, something went wrong.