Skip to content

Commit d6755cc

Browse files
authored
docs: add react people-queries story (#3284)
1 parent 440211b commit d6755cc

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

packages/mgt-components/src/components/mgt-person-card/mgt-person-card.graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const getPersonCardGraphData = async (
4848
personDetails: IDynamicPerson,
4949
isMe: boolean
5050
): Promise<MgtPersonCardState> => {
51-
const userId: string = personDetails.id || (personDetails as Person).userPrincipalName;
51+
const userId: string = personDetails?.id || (personDetails as Person)?.userPrincipalName;
5252
const email = getEmailFromGraphEntity(personDetails);
5353
const cache: CacheStore<CacheCardState> = CacheService.getCache<CacheCardState>(
5454
schemas.users,

packages/mgt-components/src/graph/graph.people.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export const getEmailFromGraphEntity = (entity: IDynamicPerson): string => {
216216
const user = entity as User;
217217
const contact = entity as Contact;
218218

219-
if (user.mail) {
219+
if (user?.mail) {
220220
return extractEmailAddress(user.mail);
221221
} else if (person.scoredEmailAddresses?.length) {
222222
return extractEmailAddress(person.scoredEmailAddresses[0].address);

samples/react-contoso/src/pages/HomePage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import * as React from 'react';
22
import { PageHeader } from '../components/PageHeader';
3+
import { People } from '@microsoft/mgt-react';
4+
const peopleDisplay: string[] = ['LidiaH', 'Megan Bowen', 'Lynne Robbins', 'JoniS'];
35

46
const HomePage: React.FunctionComponent = () => {
57
return (
68
<>
79
<PageHeader title={'Home'} description={'Welcome to Contoso!'}></PageHeader>
10+
<People peopleQueries={peopleDisplay}></People>
811
</>
912
);
1013
};

stories/components/people/people.react.stories.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ export const People = () => html`
2424
);
2525
</react>
2626
`;
27+
28+
export const PeopleQueries = () => html`
29+
<mgt-people></mgt-people>
30+
<react>
31+
import { People } from '@microsoft/mgt-react';
32+
const peopleDisplay: string[] = ['LidiaH', 'Megan Bowen', 'Lynne Robbins', 'JoniS'];
33+
34+
export default () => (
35+
<People peopleQueries={peopleDisplay}></People>
36+
);
37+
</react>
38+
`;

0 commit comments

Comments
 (0)