-
Notifications
You must be signed in to change notification settings - Fork 15
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
c0f05f5
commit e808e6b
Showing
21 changed files
with
419 additions
and
147 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
53 changes: 53 additions & 0 deletions
53
src/components/AlertFilterSettings/AlertFilterSettings.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,53 @@ | ||
import DropDown from '../DropDown/DropDown' | ||
import { FC, useState } from 'react' | ||
import useClickOutside from '../../hooks/useClickOutside' | ||
import { StatusColor } from '../../types' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
export type FilterValue = StatusColor | 'all' | ||
|
||
export interface AlertFilterSettingsProps { | ||
onChange: (value: FilterValue) => void | ||
value: FilterValue | ||
} | ||
|
||
const AlertFilterSettings: FC<AlertFilterSettingsProps> = ({ onChange, value }) => { | ||
const { t } = useTranslation() | ||
const [isOpen, toggle] = useState(false) | ||
|
||
const openDrop = () => toggle(true) | ||
const closeDrop = () => toggle(false) | ||
|
||
const { ref } = useClickOutside<HTMLDivElement>(closeDrop) | ||
|
||
const selectOption = (value: FilterValue) => { | ||
onChange(value) | ||
closeDrop() | ||
} | ||
const filterOptions = [ | ||
{ text: t('alertMessages.all'), value: 'all' }, | ||
{ text: t('alertMessages.severe'), value: StatusColor.ERROR }, | ||
{ text: t('alertMessages.warning'), value: StatusColor.WARNING }, | ||
{ text: t('alertMessages.fair'), value: StatusColor.SUCCESS }, | ||
] | ||
|
||
return ( | ||
<div ref={ref} className='relative'> | ||
<i onClick={openDrop} className='bi-sliders2 text-dark400 cursor-pointer' /> | ||
<DropDown width='w-42' position='right-0' isOpen={isOpen}> | ||
{filterOptions.map((option, index) => ( | ||
<li | ||
key={index} | ||
className='block cursor-pointer flex justify-between py-2 px-4 hover:bg-gray-100 dark:hover:bg-dark750 dark:hover:text-white' | ||
onClick={() => selectOption(option.value as FilterValue)} | ||
> | ||
{option.text} | ||
{option.value === value && <i className='bi-check-circle' />} | ||
</li> | ||
))} | ||
</DropDown> | ||
</div> | ||
) | ||
} | ||
|
||
export default AlertFilterSettings |
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
Oops, something went wrong.