-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mobile): add statistic view and filter transactions by period (#240
) Resolves #38 https://github.com/user-attachments/assets/3b602037-f379-42bc-910d-df1a5c8dd748
- Loading branch information
Showing
13 changed files
with
777 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { cn } from '@/lib/utils' | ||
import { t } from '@lingui/macro' | ||
import { useLingui } from '@lingui/react' | ||
import { FilterIcon } from 'lucide-react-native' | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectGroup, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from '../ui/select' | ||
|
||
export enum HomeFilter { | ||
All = 'ALL', | ||
ByDay = 'BY_DAY', | ||
ByWeek = 'BY_WEEK', | ||
ByMonth = 'BY_MONTH', | ||
} | ||
|
||
type SelectFilterProps = { | ||
value?: HomeFilter | ||
onSelect?: (type: HomeFilter) => void | ||
} | ||
|
||
export function SelectFilter({ | ||
value = HomeFilter.All, | ||
onSelect, | ||
}: SelectFilterProps) { | ||
const { i18n } = useLingui() | ||
|
||
const options = [ | ||
{ | ||
value: HomeFilter.All, | ||
label: t(i18n)`All entries`, | ||
}, | ||
{ | ||
value: HomeFilter.ByDay, | ||
label: t(i18n)`By day`, | ||
}, | ||
{ | ||
value: HomeFilter.ByWeek, | ||
label: t(i18n)`By week`, | ||
}, | ||
{ | ||
value: HomeFilter.ByMonth, | ||
label: t(i18n)`By month`, | ||
}, | ||
] | ||
|
||
return ( | ||
<Select | ||
value={options.find((option) => option.value === value) ?? options[0]} | ||
onValueChange={(selected) => { | ||
onSelect?.(selected?.value as HomeFilter) | ||
}} | ||
> | ||
<SelectTrigger | ||
hideArrow | ||
hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }} | ||
className={cn( | ||
'!h-10 !px-2.5 flex-row items-center gap-2', | ||
value !== HomeFilter.All && 'border-primary bg-primary', | ||
)} | ||
> | ||
<FilterIcon | ||
className={cn( | ||
'h-5 w-5 text-primary', | ||
value !== HomeFilter.All && 'text-primary-foreground', | ||
)} | ||
/> | ||
{value !== HomeFilter.All && ( | ||
<SelectValue | ||
className={cn('font-medium font-sans text-primary-foreground')} | ||
placeholder={t(i18n)`All Accounts`} | ||
> | ||
{value} | ||
</SelectValue> | ||
)} | ||
</SelectTrigger> | ||
<SelectContent sideOffset={6} align="end"> | ||
<SelectGroup className="max-w-[260px] px-1"> | ||
{options.map((option) => ( | ||
<SelectItem | ||
key={option.value} | ||
value={option.value} | ||
label={option.label} | ||
className="flex-row items-center justify-between" | ||
> | ||
{option.label} | ||
</SelectItem> | ||
))} | ||
</SelectGroup> | ||
</SelectContent> | ||
</Select> | ||
) | ||
} |
Oops, something went wrong.