Skip to content

Commit

Permalink
Release 1.2 - tussensprint (kostenbaten en genestheid)
Browse files Browse the repository at this point in the history
Release 1.2 - tussensprint (kostenbaten en genestheid)
  • Loading branch information
thesethtruth authored Mar 8, 2023
2 parents 24ab69d + 7e033c3 commit e660be8
Show file tree
Hide file tree
Showing 71 changed files with 12,188 additions and 818 deletions.
1 change: 1 addition & 0 deletions .devcontainer/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ load_fixture_data() {
python manage.py loaddata holon/fixtures/holon-fixture.json
python manage.py loaddata holon/fixtures/api-fixture.json
python manage.py loaddata holon/fixtures/main-casusfilter-fixture.json
python manage.py loaddata holon/fixtures/graph-colors-fixture.json
}

setup_frontend () {
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-push-images-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:
branches:
- main
- production
- acceptance
workflow_dispatch:

permissions:
Expand Down
14 changes: 13 additions & 1 deletion frontend/api/holon.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { InteractiveElement } from "@/components/Blocks/SectionBlock/KPIS";
import * as Cookies from "es-cookie";
import { postRequest } from "./wagtail";
import { httpGet } from "@/utils/Http";

const API_URL = process.env.NEXT_PUBLIC_WAGTAIL_API_URL || "/wt/api/nextjs";

Expand All @@ -18,3 +18,15 @@ export async function getHolonKPIs(data: { interactiveElements: InteractiveEleme

return json;
}

export async function getHolonDataSegments() {
return await httpGet(`/api/dummy-kosten-baten`);
}

export async function getHolonDataSegmentsDetail() {
return await httpGet(`/api/dummy-kosten-baten`);
}

export async function getHolonGraphColor() {
return await httpGet(`${API_URL}/v1/graph-colors/`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import React from "react";
import MediaContent from "@/components/MediaContent/MediaContent";
import { CardItem } from "../../Card/types";
import Card from "../../Card/Card";
import { Background } from "../types";

type Props = {
data: {
type: string;
value: {
background: {
color: string;
size: string;
};
background: Background;
buttons: CardItem[];
media: React.ComponentProps<typeof MediaContent>["media"];
altText: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,23 @@ import React, { Fragment, useEffect, useState } from "react";
import Confetti from "react-confetti";
import { Dialog, Transition } from "@headlessui/react";
import Button from "@/components/Button/Button";
import { FeedbackModal } from "./types";
import { KPIData } from "../../KPIDashboard/types";
import { Content } from "../SectionBlock/types";

export type StaticImage = {
id?: number;
title?: string;
img: {
alt: string;
height: number;
width: number;
src: string;
};
};

type KPIDashboardProps = {
data: Data;
type ChallengeFeedbackModalProps = {
kpis: KPIData;
loading: boolean;
dashboardId: string;
feedbackmodals: [
{
id: string;
type: string;
value: {
modaltitle: string;
modaltext: string;
modaltheme: string;
imageSelector: {
id: string;
title: string;
img: StaticImage;
};
conditions: [
{
id: string;
type: string;
value: {
parameter: string;
operator: string;
value: string;
};
}
];
};
}
];
};

type Data = {
local: {
netload: number;
costs: number;
sustainability: number;
selfSufficiency: number;
};
national: {
netload: number;
costs: number;
sustainability: number;
selfSufficiency: number;
};
content: Content;
feedbackmodals: FeedbackModal[];
};

export default function ChallengeFeedbackModal({
kpis,
content,
feedbackmodals,
}: KPIDashboardProps) {
}: ChallengeFeedbackModalProps) {
const [modal, setModal] = useState<{
isOpen: boolean;
}>({
Expand All @@ -91,7 +43,7 @@ export default function ChallengeFeedbackModal({
conditionItem.type == "interactive_input_condition"
? content?.find(
content => content.value.id == parseFloat(conditionItem.value.parameter)
).currentValue
)?.currentValue
: kpis[splittedParameter[0]][splittedParameter[1]];

const conditionValue = parseFloat(conditionItem.value.value);
Expand Down Expand Up @@ -132,8 +84,6 @@ export default function ChallengeFeedbackModal({

const modalstyling =
selectedModal?.value?.modaltheme === "green"
? "bg-holon-green"
: selectedModal?.value?.modaltheme === "greenwithconfetti"
? "bg-holon-green"
: selectedModal?.value?.modaltheme === "orange"
? "bg-holon-orange"
Expand Down Expand Up @@ -167,7 +117,7 @@ export default function ChallengeFeedbackModal({
leaveTo="opacity-0 scale-95">
<Dialog.Panel
className={`w-full p-relative max-w-md min-w-[50vw] transform overflow-hidden rounded p-6 text-center align-middle shadow-xl transition-all text-white flex flex-col gap-4 ${modalstyling}`}>
{selectedModal.value.modaltheme === "greenwithconfetti" && <Confetti />}
{selectedModal.value.modaltheme === "green" && <Confetti />}
<Dialog.Title as="h2" className="leading-6 text-2xl font-bold">
{selectedModal.value.modaltitle}
</Dialog.Title>
Expand Down
27 changes: 27 additions & 0 deletions frontend/components/Blocks/ChallengeFeedbackModal/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { StaticImage } from "@/components/ImageSelector/types";

export type FeedbackModal = {
id: string;
type: string;
value: {
modaltitle: string;
modaltext: string;
modaltheme: string;
imageSelector: {
id: string;
title: string;
img: StaticImage;
};
conditions: [
{
id: string;
type: string;
value: {
parameter: string;
operator: string;
value: string;
};
}
];
};
}
39 changes: 6 additions & 33 deletions frontend/components/Blocks/ContentBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,22 @@ import HeaderFullImageBlock from "./HeaderFullImageBlock/HeaderFullImageBlock";
import ParagraphBlock from "./ParagraphBlock";
import TableBlock from "./TableBlock/TableBlock";
import SectionBlock from "./SectionBlock/SectionBlock";
import { FeedbackModal } from "./ChallengeFeedbackModal/types";

export type Feedbackmodals = [
{
id: string;
type: string;
value: {
modaltitle: string;
modaltext: string;
modaltheme: string;
imageSelector: {
id: number;
title: string;
img: {
src: string;
width: number;
height: number;
alt: string;
};
};
};
conditions: [
{
id: string;
type: string;
value: {
parameter: string;
oparator: string;
value: string;
};
}
];
}
];
export type Feedbackmodals = [FeedbackModal];

type ContentBlockProps = PageProps<
TextAndMediaVariant | HeroBlockVariant | TitleBlockVariant | CardBlockVariant
>;

const ContentBlocks = ({
content,
pagetype,
feedbackmodals,
}: {
content: ContentBlockProps[];
feedbackmodals: Feedbackmodals[];
feedbackmodals?: Feedbackmodals[];
pagetype?: string;
}) => {
return (
<React.Fragment>
Expand Down Expand Up @@ -88,6 +60,7 @@ const ContentBlocks = ({
<SectionBlock
key={`section ${contentItem.id}`}
data={contentItem}
pagetype={pagetype}
feedbackmodals={feedbackmodals}
/>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import { StaticImage } from "../../ImageSelector/types";

/* eslint-disable @next/next/no-img-element */
type Props = {
data: {
type: string;
value: {
title: string;
size: React.ElementType;
imageSelector: {
id: number;
title: string;
img: {
src: string;
width: number;
height: number;
alt: string;
};
};
imageSelector: StaticImage;
altText: string;
};
id: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import React, { useEffect, useState } from "react";
import { StaticImage } from "@/components/ImageSelector/types";
import { Content } from "@/components/Blocks/SectionBlock/types";

export type HolarchyFeedbackImageProps = {
id: string;
type: string;
value: {
imageSelector: {
id: string;
title: string;
img: StaticImage;
};
conditions: [
{
id: string;
type: string;
value: {
parameter: string;
operator: string;
value: string;
};
}
];
};
};

type Props = {
content: Array<Content>;
holarchyfeedbackimages: Array<HolarchyFeedbackImageProps>;
};

export default function HolarchyFeedbackImage({ content, holarchyfeedbackimages }: Props) {
const [selectedImage, setSelectedImage] = useState({});

useEffect(() => {
setSelectedImage({});

setSelectedImage(
//loop through al configured images
holarchyfeedbackimages.filter(feedbackimage => {
if (feedbackimage.value.conditions.length > 0 && content.length) {
//loop through all conditions within image...
for (const conditionItem of feedbackimage.value.conditions) {
//inputvalue is the vaule of the assessed validator
const inputvalue = content?.find(
content => content.value.id == parseFloat(conditionItem.value.parameter)
)?.currentValue;

const conditionValue = parseFloat(conditionItem.value.value);

if (inputvalue == null || inputvalue == undefined) {
return false;
} else if (conditionItem.value.operator == "bigger" && inputvalue <= conditionValue) {
return false;
} else if (
conditionItem.value.operator == "biggerequal" &&
inputvalue < conditionValue
) {
return false;
} else if (
conditionItem.value.operator == "equal" &&
inputvalue != conditionItem.value.value
) {
return false;
} else if (
conditionItem.value.operator == "notequal" &&
inputvalue == conditionItem.value.value
) {
return false;
} else if (conditionItem.value.operator == "lower" && inputvalue >= conditionValue) {
return false;
} else if (
conditionItem.value.operator == "lowerequal" &&
inputvalue > conditionValue
) {
return false;
} else {
}
}
return true;
}
})[0]
);
}, [content, holarchyfeedbackimages]);

return (
<React.Fragment>
{selectedImage && selectedImage.value ? (
<img
src={selectedImage?.value.imageSelector?.img?.src}
alt={selectedImage?.value.imageSelector?.img?.alt}
className="image z-10 absolute translate-x-[-50%] translate-y-[-50%] top-1/2 left-1/2 h-[300%] object-contain max-w-none"
/>
) : (
<img
src={holarchyfeedbackimages[0]?.value.imageSelector?.img?.src}
alt={holarchyfeedbackimages[0].value.imageSelector?.img?.alt}
className="image z-10 absolute translate-x-[-50%] translate-y-[-50%] top-1/2 left-1/2 h-[300%] object-contain max-w-none"
/>
)}
</React.Fragment>
);
}
Loading

0 comments on commit e660be8

Please sign in to comment.