Skip to content

Commit

Permalink
Merge branch 'feature/add-data-source-create-event' into temp/components
Browse files Browse the repository at this point in the history
  • Loading branch information
anagperal committed Aug 21, 2024
2 parents 742b4e6 + 5c6418a commit b3503c2
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 22 deletions.
18 changes: 13 additions & 5 deletions src/data/repositories/TeamMemberD2Repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class TeamMemberD2Repository implements TeamMemberRepository {
})
).map(response => {
if (!response.users) throw new Error("Team Members not found");
return response.users.map(this.mapUserToTeamMember);
return response.users.map(d2User => this.mapUserToTeamMember(d2User));
});
}

Expand All @@ -37,16 +37,23 @@ export class TeamMemberD2Repository implements TeamMemberRepository {
}

// TODO: FIXME Property using next version of d2-api ('username' does not exist on type 'D2User')
mapUserToTeamMember(user: any): TeamMember {
private mapUserToTeamMember(user: any): TeamMember {
const photoUrlString = user?.avatar?.id
? `${this.api.baseUrl}/api/fileResources/${user?.avatar?.id}/data`
: undefined;

return new TeamMember({
id: user.id,
username: user.username,
name: user.name,
email: user.email,
phone: user.phoneNumber,
status: "Available",
role: { id: "1", name: "Incident Manager" },
photo: undefined, //TO DO : where will the photo URL be saved
status: "Available", // TODO: Get status when defined
role: { id: "1", name: "Incident Manager" }, // TODO: Get role when defined
photo:
photoUrlString && TeamMember.isValidPhotoUrl(photoUrlString)
? new URL(photoUrlString)
: undefined,
});
}
}
Expand All @@ -57,6 +64,7 @@ const d2UserFields = {
email: true,
phoneNumber: true,
username: true,
avatar: true,
};

type _D2User = MetadataPick<{
Expand Down
8 changes: 8 additions & 0 deletions src/domain/entities/incident-management-team/TeamMember.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ export class TeamMember extends Struct<TeamMemberAttrs>() {
//TO DO : any validations for phone number?
//TO DO : any validations for email?
}

static isValidPhotoUrl(urlString: string): boolean {
try {
return Boolean(new URL(urlString));
} catch (e) {
return false;
}
}
}
Binary file added src/webapp/assets/znphi-dark-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions src/webapp/components/layout/header-bar/HeaderBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react";
import styled from "styled-components";
import { HeaderBar as D2HeaderBar } from "@dhis2/ui";

import znphiLogo from "../../../assets/znphi-dark-logo.png";

type HeaderBarProps = {
name: string;
};
Expand All @@ -19,6 +21,10 @@ export const HeaderBar: React.FC<HeaderBarProps> = React.memo(({ name }) => {

<AppName>{name}</AppName>

<IconContainer>
<img src={znphiLogo} alt="ZNPHI logo" />
</IconContainer>

<StyledHeaderBar className="app-header" appName="ZEBRA App" />
</Container>
);
Expand All @@ -28,10 +34,19 @@ const Container = styled.div`
display: flex;
`;

const IconContainer = styled.div`
img {
background-color: ${props => props.theme.palette.header.color};
height: 48px;
width: 72px;
}
`;

const ButtonMenuContainer = styled.div`
background-color: ${props => props.theme.palette.header.color};
@media (max-width: 959px) {
width: 55px;
height: 48px;
}
`;

Expand All @@ -51,16 +66,16 @@ const AppName = styled.span`
height: 48px;
width: 94px;
min-width: 94px;
padding-inline: 16px;
padding-inline-start: 16px;
`;

const StyledHeaderBar = styled(D2HeaderBar)`
&.app-header {
background-color: ${props => props.theme.palette.header.color};
width: calc(100% - 176px);
width: calc(100% - 232px);
border: none;
@media (max-width: 959px) {
width: calc(100% - 231px);
width: calc(100% - 287px);
}
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ export const diseaseOutbreakEventFieldIds = {
areasAffectedProvinceIds: "areasAffectedProvinceIds",
areasAffectedDistrictIds: "areasAffectedDistrictIds",
incidentStatus: "incidentStatus",
emergedDate: "emerged_date",
emergedNarrative: "emerged_narrative",
detectedDate: "detected_date",
detectedNarrative: "detected_narrative",
notifiedDate: "notified_date",
notifiedNarrative: "notified_narrative",
emergedDate: "emergedDate",
emergedNarrative: "emergedNarrative",
detectedDate: "detectedDate",
detectedNarrative: "detectedNarrative",
notifiedDate: "notifiedDate",
notifiedNarrative: "notifiedNarrative",
initiateInvestigation: "initiateInvestigation",
conductEpidemiologicalAnalysis: "conductEpidemiologicalAnalysis",
laboratoryConfirmationDate: "laboratoryConfirmation_date",
laboratoryConfirmationNA: "laboratoryConfirmation_na",
appropriateCaseManagementDate: "appropriateCaseManagement_date",
appropriateCaseManagementNA: "appropriateCaseManagement_na",
initiatePublicHealthCounterMeasuresDate: "initiatePublicHealthCounterMeasures_date",
initiatePublicHealthCounterMeasuresNA: "initiatePublicHealthCounterMeasures_na",
initiateRiskCommunicationDate: "initiateRiskCommunication_date",
initiateRiskCommunicationNA: "initiateRiskCommunication_na",
laboratoryConfirmationDate: "laboratoryConfirmationDate",
laboratoryConfirmationNA: "laboratoryConfirmationNA",
appropriateCaseManagementDate: "appropriateCaseManagementDate",
appropriateCaseManagementNA: "appropriateCaseManagementNA",
initiatePublicHealthCounterMeasuresDate: "initiatePublicHealthCounterMeasuresDate",
initiatePublicHealthCounterMeasuresNA: "initiatePublicHealthCounterMeasuresNA",
initiateRiskCommunicationDate: "initiateRiskCommunicationDate",
initiateRiskCommunicationNA: "initiateRiskCommunicationNA",
establishCoordination: "establishCoordination",
responseNarrative: "responseNarrative",
incidentManagerName: "incidentManagerName",
Expand Down

0 comments on commit b3503c2

Please sign in to comment.