-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add subsidized tags and dropdown filter
* Add 'Subsidized' and 'Partially Subsidized' tags to Realtoken Dashboard for enhanced property status clarity - resolves #8 * add translation * Add subsidized rent dopdown fileter - resolves #13 * Small translation adjustment * fix: an asset without subsidy value is not subsidized * fix: disable subsidy filter by default Relies #8, #13
- Loading branch information
Showing
10 changed files
with
165 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { Select } from '@mantine/core' | ||
|
||
import { useAtom } from 'jotai' | ||
|
||
import { assetSubsidyChoosedAtom } from 'src/states' | ||
import { Realtoken } from 'src/store/features/realtokens/realtokensSelector' | ||
|
||
import { useInputStyles } from '../inputs/useInputStyles' | ||
import { AssetSubsidyType } from './types' | ||
|
||
export const AssetsSubsidyFilter: FC = () => { | ||
const { t } = useTranslation('common', { keyPrefix: 'assetSubsidy' }) | ||
const { classes: inputClasses } = useInputStyles() | ||
|
||
const [choosenSubsidyType, setChoosenSubsidyType] = useAtom( | ||
assetSubsidyChoosedAtom | ||
) | ||
|
||
const viewOptions = [ | ||
{ | ||
value: AssetSubsidyType.ALL, | ||
label: t('options.all'), | ||
}, | ||
{ | ||
value: AssetSubsidyType.FULLY_SUBSIDIZED, | ||
label: t('options.fullySubsidized'), | ||
}, | ||
{ | ||
value: AssetSubsidyType.SUBSIDIZED, | ||
label: t('options.subsidized'), | ||
}, | ||
{ | ||
value: AssetSubsidyType.NOT_SUBSIDIZED, | ||
label: t('options.notSubsidized'), | ||
}, | ||
] | ||
|
||
return ( | ||
<Select | ||
label={t('label')} | ||
data={viewOptions} | ||
value={choosenSubsidyType} | ||
onChange={(value: AssetSubsidyType) => | ||
value && setChoosenSubsidyType(value) | ||
} | ||
classNames={inputClasses} | ||
/> | ||
) | ||
} | ||
AssetsSubsidyFilter.displayName = 'AssetsSubsidyFilter' | ||
|
||
export function useAssetsSubsidyFilter() { | ||
const [choosenSubsidyType] = useAtom(assetSubsidyChoosedAtom) | ||
|
||
return (asset: Realtoken) => { | ||
switch (choosenSubsidyType) { | ||
case AssetSubsidyType.FULLY_SUBSIDIZED: | ||
return asset.subsidyStatus === 'yes' && !!asset.subsidyStatusValue | ||
case AssetSubsidyType.SUBSIDIZED: | ||
return asset.subsidyStatus !== 'no' && !!asset.subsidyStatusValue | ||
case AssetSubsidyType.NOT_SUBSIDIZED: | ||
return !asset.subsidyStatus || asset.subsidyStatus === 'no' | ||
default: | ||
return true | ||
} | ||
} | ||
} |
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,6 @@ | ||
export enum AssetSubsidyType { | ||
FULLY_SUBSIDIZED = 'fullySubsidized', | ||
SUBSIDIZED = 'Subsidized', | ||
NOT_SUBSIDIZED = 'notSubsidized', | ||
ALL = 'all', | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './assetSort.type' | ||
export * from './assetView.type' | ||
export * from './assetSubsidy.type' |
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,33 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { Badge } from '@mantine/core' | ||
|
||
import { OwnedRealtoken } from 'src/store/features/wallets/walletsSelector' | ||
|
||
export const SubsidyStatusTag: FC<{ value: OwnedRealtoken }> = (props) => { | ||
const { t } = useTranslation('common', { keyPrefix: 'assetCard' }) | ||
const { subsidyStatus, subsidyStatusValue } = props.value | ||
|
||
if (!subsidyStatusValue) { | ||
return <></> | ||
} | ||
|
||
switch (subsidyStatus) { | ||
case 'yes': | ||
return ( | ||
<Badge size={'xs'} variant={'dot'} color={'blue'}> | ||
{t('subsidyStatus.full')} | ||
</Badge> | ||
) | ||
case 'partial': | ||
return ( | ||
<Badge size={'xs'} variant={'filled'} color={'cyan.4'}> | ||
{t('subsidyStatus.partial')} | ||
</Badge> | ||
) | ||
default: | ||
return <></> | ||
} | ||
} | ||
SubsidyStatusTag.displayName = 'SubsidyStatusTag' |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './RentStatusTag' | ||
export * from './RmmStatusTag' | ||
export * from './SubsidyStatusTag' |
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