Commit ·
923b915
1
Parent(s): 12a2337
fix
Browse files- .eslintrc.json +3 -1
- pages/api/sendMessage.js +1 -3
- src/webzero/preview.tsx +4 -8
.eslintrc.json
CHANGED
|
@@ -3,6 +3,8 @@
|
|
| 3 |
"rules": {
|
| 4 |
"react/no-unescaped-entities": "off",
|
| 5 |
"@next/next/no-page-custom-font": "off",
|
| 6 |
-
"@typescript-eslint/no-unused-vars": "off"
|
|
|
|
|
|
|
| 7 |
}
|
| 8 |
}
|
|
|
|
| 3 |
"rules": {
|
| 4 |
"react/no-unescaped-entities": "off",
|
| 5 |
"@next/next/no-page-custom-font": "off",
|
| 6 |
+
"@typescript-eslint/no-unused-vars": "off",
|
| 7 |
+
"@next/next/no-assign-module-variable": "off",
|
| 8 |
+
"react/display-name": "off"
|
| 9 |
}
|
| 10 |
}
|
pages/api/sendMessage.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
import { generateUUID } from "@/lib/utils";
|
| 2 |
import { promises as fs } from "fs";
|
| 3 |
|
| 4 |
-
const
|
| 5 |
-
const flowId = "542c4118-8056-4a7e-a137-23d8fc24d24b";
|
| 6 |
-
const url = `${baseUrl}${flowId}?stream=false`;
|
| 7 |
|
| 8 |
export default async function handler(req, res) {
|
| 9 |
if (req.method !== "POST") {
|
|
|
|
| 1 |
import { generateUUID } from "@/lib/utils";
|
| 2 |
import { promises as fs } from "fs";
|
| 3 |
|
| 4 |
+
const url = "https://web-zero-web-zero.hf.space/api/v1/run/new?stream=false";
|
|
|
|
|
|
|
| 5 |
|
| 6 |
export default async function handler(req, res) {
|
| 7 |
if (req.method !== "POST") {
|
src/webzero/preview.tsx
CHANGED
|
@@ -5,22 +5,18 @@ interface DynamicFileProps {
|
|
| 5 |
}
|
| 6 |
|
| 7 |
const DynamicFileRenderer: React.FC<DynamicFileProps> = ({ id }) => {
|
| 8 |
-
const filepath = `
|
| 9 |
const [DynamicComponent, setDynamicComponent] =
|
| 10 |
useState<React.ComponentType | null>(null);
|
| 11 |
|
| 12 |
useEffect(() => {
|
| 13 |
const importComponent = async () => {
|
| 14 |
try {
|
| 15 |
-
const
|
| 16 |
-
setDynamicComponent(() =>
|
| 17 |
} catch (error) {
|
| 18 |
console.error("Error loading component:", error);
|
| 19 |
-
setDynamicComponent(() =>
|
| 20 |
-
const FallbackComponent = () => <div>Failed to load component</div>;
|
| 21 |
-
FallbackComponent.displayName = "FallbackComponent";
|
| 22 |
-
return FallbackComponent;
|
| 23 |
-
});
|
| 24 |
}
|
| 25 |
};
|
| 26 |
|
|
|
|
| 5 |
}
|
| 6 |
|
| 7 |
const DynamicFileRenderer: React.FC<DynamicFileProps> = ({ id }) => {
|
| 8 |
+
const filepath = `../../generated/${id}.tsx`;
|
| 9 |
const [DynamicComponent, setDynamicComponent] =
|
| 10 |
useState<React.ComponentType | null>(null);
|
| 11 |
|
| 12 |
useEffect(() => {
|
| 13 |
const importComponent = async () => {
|
| 14 |
try {
|
| 15 |
+
const module = await import(filepath);
|
| 16 |
+
setDynamicComponent(() => module.default);
|
| 17 |
} catch (error) {
|
| 18 |
console.error("Error loading component:", error);
|
| 19 |
+
setDynamicComponent(() => () => <div>Failed to load component</div>);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
};
|
| 22 |
|