-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from cisagov/rsc-filter-resources
Filter Resources on RSC Dashboard Details Page
- Loading branch information
Showing
5 changed files
with
120 additions
and
44 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
12 changes: 12 additions & 0 deletions
12
frontend/src/components/ReadySetCyber/components/IconType.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,12 @@ | ||
import React from 'react'; | ||
import { getIconType } from '../helpers/index'; | ||
|
||
// Filter the resource type and return the corresponding icon | ||
export const IconFilter = ({ type }: { type: string }) => { | ||
const IconType = getIconType(type); | ||
return ( | ||
<> | ||
<IconType /> | ||
</> | ||
); | ||
}; |
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 @@ | ||
export * from './IconType'; |
31 changes: 31 additions & 0 deletions
31
frontend/src/components/ReadySetCyber/helpers/filterResources.ts
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,31 @@ | ||
import React from 'react'; | ||
import { | ||
VideoLibrary, | ||
Article, | ||
LibraryBooks, | ||
Handyman, | ||
NotificationsActive | ||
} from '@mui/icons-material'; | ||
|
||
interface ResourceTypes { | ||
[key: string]: React.ElementType; | ||
} | ||
|
||
const resourcetypes: ResourceTypes = { | ||
video: VideoLibrary, | ||
article: Article, | ||
tool: Handyman, | ||
alerts: NotificationsActive | ||
}; | ||
|
||
// Filter resource visibility by response | ||
export const isResourceVisible = (response: string) => { | ||
const r = response.toLowerCase(); | ||
return r === 'no' || r === 'not in scope' || r === 'not started'; | ||
}; | ||
|
||
// Filter the resource type and return the corresponding icon | ||
export const getIconType = (type: string) => { | ||
const ResourceIcon = resourcetypes[type]; | ||
return ResourceIcon ? ResourceIcon : LibraryBooks; | ||
}; |
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 @@ | ||
export * from './filterResources'; |