diff --git a/pwa/src/templates/componentDetail/ComponentsDetailTemplate.module.css b/pwa/src/templates/componentDetail/ComponentsDetailTemplate.module.css index d132b2c2e..73370730a 100644 --- a/pwa/src/templates/componentDetail/ComponentsDetailTemplate.module.css +++ b/pwa/src/templates/componentDetail/ComponentsDetailTemplate.module.css @@ -149,11 +149,10 @@ .popup { position: fixed; max-width: var(--web-app-download-popup-width); - top: 50%; - left: 50%; - transform: translate(-50%, -50%); z-index: 700; outline: 0; + top: 50px; + left: 25%; } .organizations { diff --git a/pwa/src/templates/componentDetail/ComponentsDetailTemplate.tsx b/pwa/src/templates/componentDetail/ComponentsDetailTemplate.tsx index c5921b1fc..3b6b37682 100644 --- a/pwa/src/templates/componentDetail/ComponentsDetailTemplate.tsx +++ b/pwa/src/templates/componentDetail/ComponentsDetailTemplate.tsx @@ -64,6 +64,8 @@ export const ComponentsDetailTemplate: React.FC = const _useComponent = useComponent(queryClient); const _getComponent = _useComponent.getOne(componentId); + const rating = _getComponent.data?.embedded?.rating; + const layer: TCategories = t(_.upperFirst(_getComponent.data?.embedded?.nl?.embedded?.commonground.layerType)); const _categories = layer && @@ -284,8 +286,8 @@ export const ComponentsDetailTemplate: React.FC = <> @@ -297,9 +299,7 @@ export const ComponentsDetailTemplate: React.FC = )} - {!_getComponent.data.embedded?.rating && ( -
{t("No rating available")}
- )} + {!rating &&
{t("No rating available")}
} } layoutClassName={styles.infoCard} @@ -308,8 +308,8 @@ export const ComponentsDetailTemplate: React.FC =
} + title={`Rating (${rating?.rating}/${rating?.maxRating})`} + description={} primaryButton={{ label: t("Score calculation"), handleClick: () => { diff --git a/pwa/src/templates/templateParts/ratingOverview/RatingOverview.module.css b/pwa/src/templates/templateParts/ratingOverview/RatingOverview.module.css index b7fbc3aba..597e79acd 100644 --- a/pwa/src/templates/templateParts/ratingOverview/RatingOverview.module.css +++ b/pwa/src/templates/templateParts/ratingOverview/RatingOverview.module.css @@ -1,8 +1,11 @@ -.popupDescription { - max-height: 500px; - overflow: auto; +.container { + display: block; + max-height: 60vh; + overflow-y: scroll; } -ul { - list-style-type: none; +.header { + top: 0; + position: sticky; + background-color: var(--web-app-color-grey) !important; } diff --git a/pwa/src/templates/templateParts/ratingOverview/RatingOverview.tsx b/pwa/src/templates/templateParts/ratingOverview/RatingOverview.tsx index 449c2b08d..d4d16448b 100644 --- a/pwa/src/templates/templateParts/ratingOverview/RatingOverview.tsx +++ b/pwa/src/templates/templateParts/ratingOverview/RatingOverview.tsx @@ -1,51 +1,59 @@ import * as React from "react"; import * as styles from "./RatingOverview.module.css"; -import { QueryObserverSuccessResult } from "react-query"; -import { t } from "i18next"; -import { UnorderedList } from "@utrecht/component-library-react/dist/css-module"; +import { + StatusBadge, + Table, + TableBody, + TableCell, + TableHeader, + TableHeaderCell, + TableRow, +} from "@utrecht/component-library-react"; interface RatingOverviewProps { - getComponent: QueryObserverSuccessResult; + rating: any; } -export const RatingOverview: React.FC = ({ getComponent }) => { - return ( - <> - {getComponent.data.embedded?.rating?.rating && ( - {`${getComponent.data.embedded?.rating?.rating}/${getComponent.data.embedded?.rating?.maxRating}`} - )} - {!getComponent.data.embedded?.rating?.rating && {t("No rating available")}} +export const RatingOverview: React.FC = ({ rating }) => { + const [acceptedRatings, setAcceptedRatings] = React.useState([]); + const [rejectedRatings, setRejectedRatings] = React.useState([]); + + React.useEffect(() => { + setAcceptedRatings(rating.results.filter((rating: string) => !rating.includes("Cannot rate the"))); + setRejectedRatings(rating.results.filter((rating: string) => rating.includes("Cannot rate the"))); + }, [rating]); -
- - {getComponent.data.embedded?.rating?.rating >= 1 && ( - <> -
  • Behaalde punten
  • + return ( + + + + Status + Message + Points + + - {getComponent.data.embedded?.rating?.results - .filter((result: string) => !/^Cannot rate the/.test(result)) - .map((result: string) => ( -
      -
    • {result}
    • -
    - ))} - - )} - {getComponent.data.embedded?.rating?.rating !== getComponent.data.embedded?.rating?.maxRating && ( - <> -
  • Onbehaalde punten
  • + + {acceptedRatings.map((acceptedRating, idx) => ( + + + Passed + + {acceptedRating} + 1 + + ))} - {getComponent.data.embedded?.rating?.results - .filter((result: string) => /^Cannot rate the/.test(result)) - .map((result: string) => ( -
      -
    • {result}
    • -
    - ))} - - )} - - - + {rejectedRatings.map((rejectedRating, idx) => ( + + + Failed + + {rejectedRating} + 0 + + ))} +
    +
    ); };