42 lines
1.1 KiB
TypeScript
Raw Normal View History

"use client";
2024-04-06 19:03:04 -04:00
import dynamic from "next/dynamic";
import Loading from "@/components/editor/loading";
import { Sandbox, User } from "@/lib/types";
import { useEffect, useState } from "react";
2024-05-17 23:54:34 -07:00
// import { startServer } from "@/lib/utils";
import { toast } from "sonner";
2024-05-03 13:53:21 -07:00
const CodeEditor = dynamic(() => import("@/components/editor/editor"), {
ssr: false,
loading: () => <Loading />,
});
2024-04-06 19:03:04 -04:00
export default function Editor({
2024-05-01 01:53:49 -04:00
userData,
2024-05-05 00:06:10 -07:00
sandboxData,
}: {
userData: User;
sandboxData: Sandbox;
2024-04-26 22:34:56 -04:00
}) {
const [isServerRunning, setIsServerRunning] = useState(false);
const [didFail, setDidFail] = useState(false);
useEffect(() => {
2024-05-17 23:54:34 -07:00
// startServer(sandboxData.id, userData.id, (success: boolean) => {
// if (!success) {
// toast.error("Failed to start server.");
// setDidFail(true);
// } else {
// setIsServerRunning(true);
// }
// });
console.log("startServer");
}, []);
2024-05-13 15:31:48 -07:00
if (!isServerRunning || didFail)
return <Loading didFail={didFail} text="Creating your sandbox resources" />;
2024-05-07 21:19:32 -07:00
return <CodeEditor userData={userData} sandboxData={sandboxData} />;
2024-04-06 19:03:04 -04:00
}