-
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.
🐛 Exclude non-required questionnaires in assessed calculation
Signed-off-by: ibolton336 <[email protected]>
- Loading branch information
1 parent
2ea144d
commit 9e1a64b
Showing
4 changed files
with
92 additions
and
20 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
51 changes: 51 additions & 0 deletions
51
...ages/applications/components/application-detail-drawer/components/assessed-archetypes.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,51 @@ | ||
import React from "react"; | ||
import { Ref } from "@app/api/models"; | ||
import { Label, LabelGroup, Spinner } from "@patternfly/react-core"; | ||
import { EmptyTextMessage } from "@app/components/EmptyTextMessage"; | ||
import { useTranslation } from "react-i18next"; | ||
import { useFetchArchetypes } from "@app/queries/archetypes"; | ||
import { useFetchAllAssessmentsWithArchetypes } from "@app/queries/assessments"; | ||
|
||
interface IAssessedArchetypesProps { | ||
archetypeRefs: Ref[] | undefined; | ||
} | ||
|
||
export const AssessedArchetypes: React.FC<IAssessedArchetypesProps> = ({ | ||
archetypeRefs, | ||
}) => { | ||
const { t } = useTranslation(); | ||
const { archetypes, isFetching: isFetchingArchetypes } = useFetchArchetypes(); | ||
const applicationArchetypes = archetypes.filter( | ||
(archetype) => archetypeRefs?.some((ref) => ref.id === archetype.id) | ||
); | ||
|
||
const { | ||
assessmentsWithArchetypes, | ||
isLoading: isFetchingAllAssessmentsWithArchetypesLoading, | ||
} = useFetchAllAssessmentsWithArchetypes(applicationArchetypes || []); | ||
const filteredArchetypes = assessmentsWithArchetypes | ||
?.filter((assessmentsWithArchetype) => { | ||
return ( | ||
assessmentsWithArchetype.archetype.assessed && | ||
assessmentsWithArchetype.assessments.some( | ||
(assessment) => assessment?.required === true | ||
) | ||
); | ||
}) | ||
.map((assessmentsWithArchetype) => assessmentsWithArchetype.archetype); | ||
|
||
if (isFetchingArchetypes || isFetchingAllAssessmentsWithArchetypesLoading) { | ||
return <Spinner size="md" />; | ||
} | ||
return ( | ||
<LabelGroup> | ||
{filteredArchetypes?.length ? ( | ||
filteredArchetypes?.map((archetype) => ( | ||
<Label key={archetype?.id}>{archetype?.name}</Label> | ||
)) | ||
) : ( | ||
<EmptyTextMessage message={t("terms.none")} /> | ||
)} | ||
</LabelGroup> | ||
); | ||
}; |
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