File size: 657 Bytes
6c2bcb4
 
 
 
2f65818
6c2bcb4
 
 
2f65818
6c2bcb4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import axios from "axios";
import CropSquareIcon from "@mui/icons-material/CropSquare";
import IconButton from "@mui/material/IconButton";
import Tooltip from "@mui/material/Tooltip";
import { ShareProps } from "@/components/GameCreator";

export function Codesandbox({ title, content }: ShareProps) {
	return (
		<Tooltip title="Save to Codesandbox">
			<IconButton
				color="primary"
				aria-label="Codsandbox"
				onClick={async () => {
					const { data } = await axios.post<string>("/api/url/codesandbox", {
						content,
						title,
					});
					window.open(data, "_blank");
				}}
			>
				<CropSquareIcon />
			</IconButton>
		</Tooltip>
	);
}