import React from 'react'; import Typography from '@mui/material/Typography'; import { styled } from '@mui/material/styles'; const Frame = styled('div', { name: 'MuiStat', // The component name slot: 'root', // The slot name })(({ theme }) => ({ flex: "1 1 auto", gap: theme.spacing(0.5), padding: theme.spacing(3, 4), backgroundColor: theme.palette.background.paper, width: "100%", height: "100%" })); interface Tone3000AuthCompleteProps { } function Tone3000AuthComplete(props: Tone3000AuthCompleteProps) { function postApiKey() { let url = new URL(window.location.href); let apiKey = url.searchParams.get("api_key"); if (apiKey) { let myUrl = new URL(window.location.href); let port = myUrl.port; if (port === "5173") { // when running debug server. port = "8080"; } let postUrl = "http://" + myUrl.hostname + ":" + port + "/var/Tone3000Auth?api_key=" + encodeURIComponent(apiKey); fetch(postUrl, { method: "POST", headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ api_key: apiKey }) }).then((response) => { if (!response.ok) { alert("Failed to post API key to Pipedal: " + response.statusText); } return response.json(); }) .catch((error) => { alert("Error posting API key to Pipedal: " + error.message); }) } else { alert("No API key found in URL."); } } React.useEffect(() => { postApiKey(); return () => { }; }) return (