Skip to content

Commit

Permalink
add react people-queries story
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnickii committed Sep 3, 2024
1 parent dfccd65 commit 0bf0f11
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const getPersonCardGraphData = async (
personDetails: IDynamicPerson,
isMe: boolean
): Promise<MgtPersonCardState> => {
const userId: string = personDetails.id || (personDetails as Person).userPrincipalName;
const userId: string = personDetails?.id || (personDetails as Person)?.userPrincipalName;
const email = getEmailFromGraphEntity(personDetails);
const cache: CacheStore<CacheCardState> = CacheService.getCache<CacheCardState>(
schemas.users,
Expand Down
2 changes: 1 addition & 1 deletion packages/mgt-components/src/graph/graph.people.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const getEmailFromGraphEntity = (entity: IDynamicPerson): string => {
const user = entity as User;
const contact = entity as Contact;

if (user.mail) {
if (user?.mail) {
return extractEmailAddress(user.mail);
} else if (person.scoredEmailAddresses?.length) {
return extractEmailAddress(person.scoredEmailAddresses[0].address);
Expand Down
3 changes: 3 additions & 0 deletions samples/react-contoso/src/pages/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import * as React from 'react';
import { PageHeader } from '../components/PageHeader';
import { People } from '@microsoft/mgt-react';
const peopleDisplay: string[] = ['LidiaH', 'Megan Bowen', 'Lynne Robbins', 'JoniS'];

const HomePage: React.FunctionComponent = () => {
return (
<>
<PageHeader title={'Home'} description={'Welcome to Contoso!'}></PageHeader>
<People peopleQueries={peopleDisplay}></People>
</>
);
};
Expand Down
12 changes: 12 additions & 0 deletions stories/components/people/people.react.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@ export const People = () => html`
);
</react>
`;

export const PeopleQueries = () => html`
<mgt-people></mgt-people>
<react>
import { People } from '@microsoft/mgt-react';
const peopleDisplay: string[] = ['LidiaH', 'Megan Bowen', 'Lynne Robbins', 'JoniS'];
export default () => (
<People peopleQueries={peopleDisplay}></People>
);
</react>
`;

0 comments on commit 0bf0f11

Please sign in to comment.