Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [IOCOM-867] Add service info in MessageDetailsScreen #5461

Merged
merged 29 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7cced1c
add title, date and content
adelloste Jan 24, 2024
239d8d3
add tests
adelloste Jan 24, 2024
cd149ef
change text color
adelloste Jan 24, 2024
bcfcb8e
Update message timestamp and color
adelloste Jan 24, 2024
d430980
Merge branch 'master' into IOCOM-868-message-header
adelloste Jan 24, 2024
c8af535
update snap
adelloste Jan 24, 2024
aea34c5
fix test
adelloste Jan 24, 2024
42b175b
add tags
adelloste Jan 25, 2024
e64bfd3
Merge branch 'master' into IOCOM-866-tags
adelloste Jan 25, 2024
54045e6
Merge branch 'master' into IOCOM-866-tags
Vangaorth Jan 26, 2024
052b115
Merge branch 'master' into IOCOM-866-tags
Vangaorth Jan 26, 2024
0e68739
Merge branch 'master' into IOCOM-866-tags
adelloste Jan 29, 2024
6602fe8
update tests
adelloste Jan 29, 2024
0766ed5
Merge branch 'master' into IOCOM-866-tags
adelloste Jan 29, 2024
0a82268
applied suggestion
adelloste Jan 29, 2024
46c9b1a
update test
adelloste Jan 29, 2024
2207604
Merge branch 'master' into IOCOM-866-tags
adelloste Jan 30, 2024
5e1eb41
Merge branch 'master' into IOCOM-866-tags
adelloste Jan 30, 2024
beb4469
add OrganizationHeader component
adelloste Jan 30, 2024
2696258
Merge branch 'master' into IOCOM-867-org-header
adelloste Jan 30, 2024
fe25855
Merge branch 'master' into IOCOM-867-org-header
adelloste Jan 31, 2024
6f123e1
added missing deps to useCallback
adelloste Jan 31, 2024
f848965
removed useless prop
adelloste Jan 31, 2024
a4ae216
Merge branch 'master' into IOCOM-867-org-header
adelloste Jan 31, 2024
d2b7760
update snap
adelloste Jan 31, 2024
0584d1b
update snap
adelloste Jan 31, 2024
60e0a9d
Merge branch 'master' into IOCOM-867-org-header
adelloste Feb 2, 2024
13af2ed
use logosForService
adelloste Feb 2, 2024
b725c7f
update test
adelloste Feb 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added img/test/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { Divider, H3, LabelSmall, VSpacer } from "@pagopa/io-app-design-system";
import React, { PropsWithChildren } from "react";
import { StyleSheet, View } from "react-native";
import {
ContentWrapper,
Divider,
H3,
LabelSmall,
VSpacer
} from "@pagopa/io-app-design-system";
import { localeDateFormat } from "../../../../utils/locale";
import I18n from "../../../../i18n";
import { ServicePublic } from "../../../../../definitions/backend/ServicePublic";
import { logosForService } from "../../../../utils/services";
import { OrganizationHeader } from "./OrganizationHeader";

export type MessageDetailHeaderProps = PropsWithChildren<{
createdAt: Date;
Expand All @@ -12,12 +19,6 @@ export type MessageDetailHeaderProps = PropsWithChildren<{
service?: ServicePublic;
}>;

const styles = StyleSheet.create({
header: {
paddingHorizontal: 24
}
});

const MessageHeaderContent = ({
subject,
createdAt
Expand All @@ -36,13 +37,24 @@ const MessageHeaderContent = ({

export const MessageDetailHeader = ({
children,
service,
...rest
}: MessageDetailHeaderProps) => (
<View style={styles.header}>
<ContentWrapper>
{children}
<MessageHeaderContent {...rest} />
<VSpacer size={8} />
<Divider />
{/* TODO: Add MessageHeaderService */}
</View>
{service && (
<>
{/* TODO: update logoUri when MultiImage component will be available in DS */}
<OrganizationHeader
logoUri={logosForService(service)[0]}
organizationName={service.organization_name}
serviceName={service.service_name}
/>
<Divider />
</>
)}
</ContentWrapper>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from "react";
import { ImageURISource, StyleSheet, View } from "react-native";
import {
Avatar,
IOSpacingScale,
IOStyles,
LabelSmall
} from "@pagopa/io-app-design-system";

export type OrganizationHeaderProps = {
organizationName: string;
serviceName: string;
logoUri: ImageURISource;
};

const ITEM_PADDING_VERTICAL: IOSpacingScale = 6;
const AVATAR_MARGIN_LEFT: IOSpacingScale = 16;

const styles = StyleSheet.create({
item: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
paddingVertical: ITEM_PADDING_VERTICAL
},
itemAvatar: {
marginLeft: AVATAR_MARGIN_LEFT
}
});

export const OrganizationHeader = ({
logoUri,
organizationName,
serviceName
}: OrganizationHeaderProps) => (
<View style={styles.item}>
<View style={IOStyles.flex}>
<LabelSmall fontSize="regular" color="grey-700">
{organizationName}
</LabelSmall>
<LabelSmall fontSize="regular" color="blueIO-500">
{serviceName}
</LabelSmall>
</View>
<View style={styles.itemAvatar}>
<Avatar logoUri={logoUri} size="small" shape="circle" />
</View>
</View>
);
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,22 @@ describe("MessageDetailHeader component", () => {
const component = render(
<MessageDetailHeader
{...defaultProps}
sender="Sender"
sender="#### Sender ####"
service={service}
/>
);
expect(component.toJSON()).toMatchSnapshot();
});

it("should render the organization info when the service is defined", () => {
const component = render(
<MessageDetailHeader
{...defaultProps}
sender="#### Sender ####"
service={service}
/>
);
expect(component.queryByText(service.organization_name)).not.toBeNull();
expect(component.queryByText(service.service_name)).not.toBeNull();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { render } from "@testing-library/react-native";
import { OrganizationHeader } from "../OrganizationHeader";

describe("OrganizationHeader component", () => {
it("should match the snapshot", () => {
const component = render(
<OrganizationHeader
logoUri={require("../../../../../../img/test/logo.png")}
organizationName={"#### organization_name ####"}
serviceName={"#### service name ####"}
/>
);
expect(component.toJSON()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,137 @@ exports[`MessageDetailHeader component should match the snapshot with all props
}
}
/>
<View
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"justifyContent": "space-between",
"paddingVertical": 6,
}
}
>
<View
style={
Object {
"flex": 1,
}
}
>
<Text
allowFontScaling={false}
color="grey-700"
defaultColor="blue"
defaultWeight="Bold"
font="TitilliumWeb"
fontSize="regular"
fontStyle={
Object {
"fontSize": 14,
"lineHeight": 21,
}
}
style={
Array [
Object {
"fontSize": 14,
"lineHeight": 21,
},
Object {
"color": "#555C70",
"fontFamily": "Titillium Web",
"fontStyle": "normal",
"fontWeight": "700",
},
]
}
weight="Bold"
>
Organization foo
</Text>
<Text
allowFontScaling={false}
color="blueIO-500"
defaultColor="blue"
defaultWeight="Bold"
font="TitilliumWeb"
fontSize="regular"
fontStyle={
Object {
"fontSize": 14,
"lineHeight": 21,
}
}
style={
Array [
Object {
"fontSize": 14,
"lineHeight": 21,
},
Object {
"color": "#0B3EE3",
"fontFamily": "Titillium Web",
"fontStyle": "normal",
"fontWeight": "700",
},
]
}
weight="Bold"
>
health
</Text>
</View>
<View
style={
Object {
"marginLeft": 16,
}
}
>
<View
style={
Array [
Object {
"borderColor": "rgba(14,15,19,0.1)",
"borderWidth": 1,
"overflow": "hidden",
"resizeMode": "contain",
},
Object {
"backgroundColor": "#FFFFFF",
"borderRadius": 22,
"height": 44,
"padding": 6,
"width": 44,
},
]
}
>
<Image
onError={[Function]}
source={
Object {
"uri": "https://assets.cdn.io.italia.it/logos/services/serviceid.png",
}
}
style={
Object {
"height": "100%",
"width": "100%",
}
}
/>
</View>
</View>
</View>
<View
style={
Object {
"backgroundColor": "#D2D6E3",
"height": 0.5,
}
}
/>
</View>
`;

Expand Down
Loading
Loading