-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename component and refactor to use child components
- Loading branch information
1 parent
8ae3892
commit 096fa6f
Showing
7 changed files
with
60 additions
and
40 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
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
...s/assessment-management/assessment-settings/components/questionnaire-questions-column.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,15 @@ | ||
import React from "react"; | ||
import { Text } from "@patternfly/react-core"; | ||
import { Questionnaire } from "@app/api/models"; | ||
|
||
export const QuestionnaireQuestionsColumn: React.FC<{ | ||
questionnaire: Questionnaire; | ||
}> = ({ questionnaire }) => { | ||
const totalQuestions = (questionnaire.sections || []).reduce( | ||
(total, section) => { | ||
return total + (section.questions ? section.questions.length : 0); | ||
}, | ||
0 | ||
); | ||
return <Text>{totalQuestions}</Text>; | ||
}; |
27 changes: 27 additions & 0 deletions
27
.../assessment-management/assessment-settings/components/questionnaire-thresholds-column.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,27 @@ | ||
import React from "react"; | ||
import { ListItem } from "@patternfly/react-core"; | ||
import { Questionnaire, Thresholds } from "@app/api/models"; | ||
|
||
export const QuestionnaireThresholdsColumn: React.FC<{ | ||
questionnaire: Questionnaire; | ||
}> = ({ questionnaire }) => { | ||
const thresholdsToListItems = (thresholds: Thresholds) => { | ||
const thresholdKeys: (keyof Thresholds)[] = Object.keys( | ||
thresholds | ||
) as (keyof Thresholds)[]; | ||
|
||
return ( | ||
<> | ||
{thresholdKeys.map((color) => { | ||
const percentage: number = thresholds[color] || 0; | ||
return ( | ||
<ListItem key={color}> | ||
{color} {percentage}% | ||
</ListItem> | ||
); | ||
})} | ||
</> | ||
); | ||
}; | ||
return thresholdsToListItems(questionnaire.thresholds || {}); | ||
}; |
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