Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Feature/behavior annotations match be (#4150)
Browse files Browse the repository at this point in the history
* schema edit for Backend

* Adjusted naming for backend input and added locale
  • Loading branch information
Jorrik-Klijnsma-Work authored Apr 5, 2022
1 parent 8627c00 commit d149798
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
40 changes: 21 additions & 19 deletions packages/app/schema/nl/behavior_annotations.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"title": "nl_behavior_annotations",
"type": "object",
"properties": {
"source_type": {
"behavior_indicator": {
"enum": [
"wash_hands",
"curfew",
Expand All @@ -34,23 +34,22 @@
"selftest_visit"
]
},
"behaviour_type": {
"enum": [
"wash_hands",
"curfew",
"keep_distance",
"work_from_home",
"avoid_crowds",
"symptoms_stay_home_if_mandatory",
"symptoms_get_tested",
"wear_mask_public_indoors",
"wear_mask_public_transport",
"sneeze_cough_elbow",
"max_visitors",
"ventilate_home",
"selftest_visit"
]
"message_title_nl": {
"minLength": 1,
"type": "string"
},
"message_title_en": {
"minLength": 1,
"type": "string"
},
"message_desc_nl": {
"minLength": 1,
"type": "string"
},
"message_desc_en": {
"minLength": 1,
"type": "string"
},
"date_start_unix": {
"type": "integer"
},
Expand All @@ -62,8 +61,11 @@
}
},
"required": [
"source_type",
"behaviour_type",
"behavior_indicator",
"message_title_nl",
"message_title_en",
"message_desc_nl",
"message_desc_en",
"date_start_unix",
"date_end_unix",
"date_of_insertion_unix"
Expand Down
13 changes: 6 additions & 7 deletions packages/app/src/pages/landelijk/gedrag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export const getStaticProps = createGetStaticProps(
(siteText) => ({
caterogyTexts: siteText.common.nationaal_layout.headings.gedrag,
metadataTexts: siteText.pages.topicalPage.nl.nationaal_metadata,
subjectTexts: siteText.common.behavior.subjects,
text: siteText.pages.behaviorPage,
}),
locale
Expand Down Expand Up @@ -80,8 +79,8 @@ export default function BehaviorPage(
const behaviorLastValue = data.behavior.last_value;

const behaviorAnnotationsFeature = useFeature('nlBehaviorAnnotations');
const { formatNumber, formatDateFromSeconds, formatPercentage } = useIntl();
const { caterogyTexts, subjectTexts, metadataTexts, text } = pageText;
const { formatNumber, formatDateFromSeconds, formatPercentage, locale } = useIntl();
const { caterogyTexts, metadataTexts, text } = pageText;

const metadata = {
...metadataTexts,
Expand Down Expand Up @@ -115,17 +114,17 @@ export default function BehaviorPage(
const { currentTimelineEvents } = useMemo(() => {
// Timeline event from the current selected behaviour
const currentTimelineEvents = data.behavior_annotations.values.filter(
(a) => (a.source_type === currentId)
(a) => (a.behavior_indicator === currentId)
).map((event) => ({
title: subjectTexts[event.behaviour_type],
description: text.shared.annotation_description[event.behaviour_type],
title: event[`message_title_${locale}`],
description: event[`message_desc_${locale}`],
start: event.date_start_unix,
end: event.date_end_unix
})
);

return { currentTimelineEvents };
}, [currentId, data.behavior_annotations.values, text.shared.annotation_description, subjectTexts]);
}, [currentId, data.behavior_annotations.values, locale]);

const timelineProp = behaviorAnnotationsFeature.isEnabled
? { timelineEvents: currentTimelineEvents }
Expand Down
20 changes: 5 additions & 15 deletions packages/common/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -836,21 +836,7 @@ export interface NlBehaviorAnnotations {
values: NlBehaviorAnnotations1[];
}
export interface NlBehaviorAnnotations1 {
source_type:
| "wash_hands"
| "curfew"
| "keep_distance"
| "work_from_home"
| "avoid_crowds"
| "symptoms_stay_home_if_mandatory"
| "symptoms_get_tested"
| "wear_mask_public_indoors"
| "wear_mask_public_transport"
| "sneeze_cough_elbow"
| "max_visitors"
| "ventilate_home"
| "selftest_visit";
behaviour_type:
behavior_indicator:
| "wash_hands"
| "curfew"
| "keep_distance"
Expand All @@ -864,6 +850,10 @@ export interface NlBehaviorAnnotations1 {
| "max_visitors"
| "ventilate_home"
| "selftest_visit";
message_title_nl: string;
message_title_en: string;
message_desc_nl: string;
message_desc_en: string;
date_start_unix: number;
date_end_unix: number;
date_of_insertion_unix: number;
Expand Down

0 comments on commit d149798

Please sign in to comment.