Spaces:
Running
Running
passing custom api key
Browse files- components/Canvas.js +25 -9
- components/CanvasContainer.js +2 -0
components/Canvas.js
CHANGED
@@ -39,6 +39,8 @@ const Canvas = forwardRef(({
|
|
39 |
styleMode,
|
40 |
setStyleMode,
|
41 |
isSendingToDoodle,
|
|
|
|
|
42 |
}, ref) => {
|
43 |
const [showBezierGuides, setShowBezierGuides] = useState(true);
|
44 |
const [activePoint, setActivePoint] = useState(-1);
|
@@ -195,6 +197,7 @@ const Canvas = forwardRef(({
|
|
195 |
},
|
196 |
body: JSON.stringify({
|
197 |
imageData: compressedImage.split(",")[1],
|
|
|
198 |
}),
|
199 |
});
|
200 |
|
@@ -293,7 +296,7 @@ const Canvas = forwardRef(({
|
|
293 |
};
|
294 |
|
295 |
reader.readAsDataURL(file);
|
296 |
-
}, [canvasRef, currentTool, onDrawingChange, saveCanvasState, setCurrentTool]);
|
297 |
|
298 |
// Keep the ref updated
|
299 |
useEffect(() => {
|
@@ -1108,7 +1111,7 @@ const Canvas = forwardRef(({
|
|
1108 |
</div>
|
1109 |
)}
|
1110 |
|
1111 |
-
{/* Updated doodle conversion error overlay with dismiss button */}
|
1112 |
{doodleError && (
|
1113 |
<div className="absolute inset-0 flex flex-col items-center justify-center bg-gray-400/80 rounded-xl z-50">
|
1114 |
<div className="bg-white shadow-lg rounded-xl p-6 flex flex-col items-center max-w-md">
|
@@ -1116,13 +1119,26 @@ const Canvas = forwardRef(({
|
|
1116 |
<p className="text-gray-900 font-medium text-lg">Failed to Convert Image</p>
|
1117 |
<p className="text-gray-700 text-center mt-2">{doodleError}</p>
|
1118 |
<p className="text-gray-500 text-sm mt-4">Try a different image or try again later</p>
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1126 |
</div>
|
1127 |
</div>
|
1128 |
)}
|
|
|
39 |
styleMode,
|
40 |
setStyleMode,
|
41 |
isSendingToDoodle,
|
42 |
+
customApiKey,
|
43 |
+
onOpenApiKeyModal,
|
44 |
}, ref) => {
|
45 |
const [showBezierGuides, setShowBezierGuides] = useState(true);
|
46 |
const [activePoint, setActivePoint] = useState(-1);
|
|
|
197 |
},
|
198 |
body: JSON.stringify({
|
199 |
imageData: compressedImage.split(",")[1],
|
200 |
+
customApiKey,
|
201 |
}),
|
202 |
});
|
203 |
|
|
|
296 |
};
|
297 |
|
298 |
reader.readAsDataURL(file);
|
299 |
+
}, [canvasRef, currentTool, onDrawingChange, saveCanvasState, setCurrentTool, customApiKey]);
|
300 |
|
301 |
// Keep the ref updated
|
302 |
useEffect(() => {
|
|
|
1111 |
</div>
|
1112 |
)}
|
1113 |
|
1114 |
+
{/* Updated doodle conversion error overlay with dismiss button and API key button */}
|
1115 |
{doodleError && (
|
1116 |
<div className="absolute inset-0 flex flex-col items-center justify-center bg-gray-400/80 rounded-xl z-50">
|
1117 |
<div className="bg-white shadow-lg rounded-xl p-6 flex flex-col items-center max-w-md">
|
|
|
1119 |
<p className="text-gray-900 font-medium text-lg">Failed to Convert Image</p>
|
1120 |
<p className="text-gray-700 text-center mt-2">{doodleError}</p>
|
1121 |
<p className="text-gray-500 text-sm mt-4">Try a different image or try again later</p>
|
1122 |
+
|
1123 |
+
{/* Add buttons in a row */}
|
1124 |
+
<div className="flex gap-3 mt-4">
|
1125 |
+
<button
|
1126 |
+
type="button"
|
1127 |
+
className="px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 transition-colors"
|
1128 |
+
onClick={clearDoodleError}
|
1129 |
+
>
|
1130 |
+
Dismiss
|
1131 |
+
</button>
|
1132 |
+
|
1133 |
+
{/* New API Key button that shows in grayscale */}
|
1134 |
+
<button
|
1135 |
+
type="button"
|
1136 |
+
className="px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors"
|
1137 |
+
onClick={onOpenApiKeyModal}
|
1138 |
+
>
|
1139 |
+
Add API Key
|
1140 |
+
</button>
|
1141 |
+
</div>
|
1142 |
</div>
|
1143 |
</div>
|
1144 |
)}
|
components/CanvasContainer.js
CHANGED
@@ -1605,6 +1605,8 @@ const CanvasContainer = () => {
|
|
1605 |
styleMode={styleMode}
|
1606 |
setStyleMode={setStyleMode}
|
1607 |
isSendingToDoodle={isSendingToDoodle}
|
|
|
|
|
1608 |
/>
|
1609 |
</div>
|
1610 |
|
|
|
1605 |
styleMode={styleMode}
|
1606 |
setStyleMode={setStyleMode}
|
1607 |
isSendingToDoodle={isSendingToDoodle}
|
1608 |
+
customApiKey={customApiKey}
|
1609 |
+
onOpenApiKeyModal={() => setShowApiKeyModal(true)}
|
1610 |
/>
|
1611 |
</div>
|
1612 |
|