import React from 'react'; import * as teamsJs from '@microsoft/teams-js'; import * as client from '@microsoft/teams.client'; import * as endpoints from '@microsoft/teams.graph-endpoints'; import { ConsoleLogger } from '@microsoft/teams.common'; import './App.css'; const clientId = import.meta.env.VITE_CLIENT_ID; export default function App() { const [content, setContent] = React.useState(''); const [app, setApp] = React.useState(null); React.useEffect(() => { (async () => { // initialize the app and prompt for Graph scope consent, if not already granted const app = new client.App(clientId, { logger: new ConsoleLogger('@tests/tab', { level: 'debug' }), }); await app.start(); app.log.info('app started'); setApp(app); })(); }, []); const showTeamsJsContext = React.useCallback(async () => { if (!app) { return; } const context = await teamsJs.app.getContext(); setContent(JSON.stringify(context, null, 2)); }, [app]); const postChatMessage = React.useCallback(async () => { if (!app) { return; } // get the bot to post a message to the current chat, whichever that is const { conversationId } = await app.exec<{ conversationId: string }>('post-to-chat', { message: 'Hello from the client!' }); setContent(`Message posted to conversation ${conversationId}`); }, [app]); const whoAmI = React.useCallback(async () => { if (!app) { return; } // get the current user from the Microsoft Graph const me = await app.graph.call(endpoints.me.get); setContent(JSON.stringify(me, null, 2)); }, [app]); const togglePresentationMode = React.useCallback(async () => { if (!app) { return; } // get current presence from the Microsoft Graph const { availability } = await app.graph.call(endpoints.me.presence.get); const isAvailable = availability === 'Available'; // toggle between Dnd/Presenting and Available/Available const newPresence = { sessionId: clientId, availability: isAvailable ? 'DoNotDisturb' : 'Available', activity: isAvailable ? 'Presenting' : 'Available' }; await app.graph.call(endpoints.me.presence.setPresence.create, newPresence); setContent(`You're now ${newPresence.activity}`); }, [app]); return (

👋 Welcome

This test app lets you try out some of the features offered by Teams SDK for Teams Tab app developers.

{content && (
            {content}
          
)}

For more information, please refer to the Teams SDK documentation.

); }