1- import { useState } from 'react'
21import reactLogo from './assets/react.svg'
32import viteLogo from '/vite.svg'
43import './App.css'
54// Import everything needed to use the `useQuery` hook
6- import { useQuery , gql } from '@apollo/client' ;
5+ // import { useQuery, gql } from '@apollo/client';
6+ import { MsalAuthenticationTemplate } from "@azure/msal-react" ;
7+ import { loginRequest } from "./auth/authConfig" ;
8+ import { InteractionType } from '@azure/msal-browser' ;
9+ import { callMsGraph } from "./auth/MsGraph.ts" ;
710
811function App ( ) {
9- const [ count , setCount ] = useState ( 0 )
10- const GetEngagements = gql `
11- query GetEngagements {
12- engagements {
13- endCursor
14- hasNextPage
15- items {
16- endDate
17- id
18- name
19- programName
20- startDate
21- status
22- }
23- }
24- }
25- ` ;
26- const { loading, error, data } = useQuery ( GetEngagements ) ;
27- if ( loading ) return < p > Loading...</ p > ;
28- if ( error ) return < p > Error : { error . message } </ p > ;
12+ // const [count, setCount] = useState(0);
13+ // const [token, setToken] = useState<string>("");
14+
15+ // const { result, error } = useMsalAuthentication(InteractionType.Popup, {
16+ // ...loginRequest,
17+ // redirectUri: "/" // e.g. /redirect
18+ // });
19+ // const navigate = useNavigate();
20+ // const navigationClient = new CustomNavigationClient(navigate);
21+ // msalInstance.setNavigationClient(navigationClient);
22+
23+ // const GetEngagements = gql`
24+ // query GetEngagements {
25+ // engagements {
26+ // endCursor
27+ // hasNextPage
28+ // items {
29+ // endDate
30+ // id
31+ // name
32+ // programName
33+ // startDate
34+ // status
35+ // }
36+ // }
37+ // }
38+ // `;
39+
40+ // const { loading, error, data } = useQuery(GetEngagements);
41+ // if (loading) return <p>Loading...</p>;
42+ // if (error) return <p>Error : {error.message}</p>;
43+ const authRequest = {
44+ ...loginRequest
45+ } ;
2946 return (
30- < >
47+ < MsalAuthenticationTemplate
48+ interactionType = { InteractionType . Redirect }
49+ authenticationRequest = { authRequest }
50+ >
3151 < div >
3252 < a href = "https://vite.dev" target = "_blank" >
3353 < img src = { viteLogo } className = "logo" alt = "Vite logo" />
@@ -37,22 +57,13 @@ function App() {
3757 </ a >
3858 </ div >
3959 < h1 > Vite + React</ h1 >
40- // Display the data from the query
41- < ul >
42- { /* @typescript -eslint/no-explicit-any */ } ,
43- { data . engagements . items . map ( ( engagement : any ) => (
44- < li key = { engagement . id } >
45- < h2 > { engagement . name } </ h2 >
46- < p > Program: { engagement . programName } </ p >
47- < p > Status: { engagement . status } </ p >
48- < p > Start Date: { new Date ( engagement . startDate ) . toLocaleDateString ( ) } </ p >
49- < p > End Date: { new Date ( engagement . endDate ) . toLocaleDateString ( ) } </ p >
50- </ li >
51- ) ) }
52- </ ul >
60+
5361 < div className = "card" >
54- < button onClick = { ( ) => setCount ( ( count ) => count + 1 ) } >
55- count is { count }
62+ < button onClick = { async ( ) => {
63+ const response = await callMsGraph ( ) ;
64+ console . log ( "Response from MS Graph:" , response ) ;
65+ } } >
66+ Call MS Graph for testing
5667 </ button >
5768 < p >
5869 Edit < code > src/App.tsx</ code > and save to test HMR
@@ -61,7 +72,7 @@ function App() {
6172 < p className = "read-the-docs" >
6273 Click on the Vite and React logos to learn more
6374 </ p >
64- </ >
75+ </ MsalAuthenticationTemplate >
6576 )
6677}
6778
0 commit comments