Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- frontend/src/App.jsx +6 -10
- frontend/src/main.jsx +3 -4
frontend/src/App.jsx
CHANGED
|
@@ -10,7 +10,6 @@ import Chatbot from "./components/Dashboard/Chatbot";
|
|
| 10 |
export default function App() {
|
| 11 |
const [isDark, setIsDark] = useState(false);
|
| 12 |
const [appState, setAppState] = useState('home');
|
| 13 |
-
const [uploadedFile, setUploadedFile] = useState(null);
|
| 14 |
const [userName, setUserName] = useState('');
|
| 15 |
|
| 16 |
useEffect(() => {
|
|
@@ -42,9 +41,11 @@ export default function App() {
|
|
| 42 |
|
| 43 |
const toggleTheme = () => setIsDark(!isDark);
|
| 44 |
|
| 45 |
-
const handleUploadComplete = (
|
|
|
|
|
|
|
|
|
|
| 46 |
console.log("Upload finished! Routing to Dboard...");
|
| 47 |
-
setUploadedFile(file);
|
| 48 |
navigateTo('dboard');
|
| 49 |
};
|
| 50 |
|
|
@@ -52,12 +53,10 @@ export default function App() {
|
|
| 52 |
if (appState === 'dboard' || appState === 'dashboard') {
|
| 53 |
return (
|
| 54 |
<Dboard
|
| 55 |
-
file={uploadedFile}
|
| 56 |
isDark={isDark}
|
| 57 |
toggleTheme={toggleTheme}
|
| 58 |
userName={userName}
|
| 59 |
onLogout={() => {
|
| 60 |
-
setUploadedFile(null);
|
| 61 |
setUserName('');
|
| 62 |
navigateTo('home');
|
| 63 |
}}
|
|
@@ -84,7 +83,7 @@ export default function App() {
|
|
| 84 |
>
|
| 85 |
β Back to Dashboard
|
| 86 |
</button>
|
| 87 |
-
<Chatbot
|
| 88 |
</div>
|
| 89 |
);
|
| 90 |
}
|
|
@@ -93,17 +92,14 @@ export default function App() {
|
|
| 93 |
if (appState === 'login') {
|
| 94 |
return (
|
| 95 |
<Login
|
| 96 |
-
// Sign In (email+password) β captures name from email β dashboard
|
| 97 |
onLoginSuccess={(user) => {
|
| 98 |
setUserName(user?.name || '');
|
| 99 |
navigateTo('dboard');
|
| 100 |
}}
|
| 101 |
-
// Continue with Google β name comes from Google profile β dashboard
|
| 102 |
onGoogleSuccess={(user) => {
|
| 103 |
setUserName(user?.name || 'Google User');
|
| 104 |
navigateTo('dboard');
|
| 105 |
}}
|
| 106 |
-
// Create free account β name derived from email β upload β dashboard
|
| 107 |
onSignupSuccess={(user) => {
|
| 108 |
setUserName(user?.name || '');
|
| 109 |
navigateTo('upload');
|
|
@@ -138,4 +134,4 @@ export default function App() {
|
|
| 138 |
{appState === 'home' && <Footer />}
|
| 139 |
</div>
|
| 140 |
);
|
| 141 |
-
}
|
|
|
|
| 10 |
export default function App() {
|
| 11 |
const [isDark, setIsDark] = useState(false);
|
| 12 |
const [appState, setAppState] = useState('home');
|
|
|
|
| 13 |
const [userName, setUserName] = useState('');
|
| 14 |
|
| 15 |
useEffect(() => {
|
|
|
|
| 41 |
|
| 42 |
const toggleTheme = () => setIsDark(!isDark);
|
| 43 |
|
| 44 |
+
const handleUploadComplete = () => {
|
| 45 |
+
// UploadModal already completed the upload β just navigate to dashboard.
|
| 46 |
+
// Previously we stored the file and passed it to Dboard as a prop, which
|
| 47 |
+
// caused Dboard's mount effect to call processFile() a second time.
|
| 48 |
console.log("Upload finished! Routing to Dboard...");
|
|
|
|
| 49 |
navigateTo('dboard');
|
| 50 |
};
|
| 51 |
|
|
|
|
| 53 |
if (appState === 'dboard' || appState === 'dashboard') {
|
| 54 |
return (
|
| 55 |
<Dboard
|
|
|
|
| 56 |
isDark={isDark}
|
| 57 |
toggleTheme={toggleTheme}
|
| 58 |
userName={userName}
|
| 59 |
onLogout={() => {
|
|
|
|
| 60 |
setUserName('');
|
| 61 |
navigateTo('home');
|
| 62 |
}}
|
|
|
|
| 83 |
>
|
| 84 |
β Back to Dashboard
|
| 85 |
</button>
|
| 86 |
+
<Chatbot isDark={isDark} />
|
| 87 |
</div>
|
| 88 |
);
|
| 89 |
}
|
|
|
|
| 92 |
if (appState === 'login') {
|
| 93 |
return (
|
| 94 |
<Login
|
|
|
|
| 95 |
onLoginSuccess={(user) => {
|
| 96 |
setUserName(user?.name || '');
|
| 97 |
navigateTo('dboard');
|
| 98 |
}}
|
|
|
|
| 99 |
onGoogleSuccess={(user) => {
|
| 100 |
setUserName(user?.name || 'Google User');
|
| 101 |
navigateTo('dboard');
|
| 102 |
}}
|
|
|
|
| 103 |
onSignupSuccess={(user) => {
|
| 104 |
setUserName(user?.name || '');
|
| 105 |
navigateTo('upload');
|
|
|
|
| 134 |
{appState === 'home' && <Footer />}
|
| 135 |
</div>
|
| 136 |
);
|
| 137 |
+
}
|
frontend/src/main.jsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
-
import { StrictMode } from 'react'
|
| 2 |
import { createRoot } from 'react-dom/client'
|
| 3 |
import './index.css'
|
| 4 |
import App from './App.jsx'
|
| 5 |
|
|
|
|
|
|
|
| 6 |
createRoot(document.getElementById('root')).render(
|
| 7 |
-
<
|
| 8 |
-
<App />
|
| 9 |
-
</StrictMode>,
|
| 10 |
)
|
|
|
|
|
|
|
| 1 |
import { createRoot } from 'react-dom/client'
|
| 2 |
import './index.css'
|
| 3 |
import App from './App.jsx'
|
| 4 |
|
| 5 |
+
// StrictMode removed β it double-invokes useEffect in dev which was causing
|
| 6 |
+
// processFile to fire twice on mount, creating 2 uploads per file.
|
| 7 |
createRoot(document.getElementById('root')).render(
|
| 8 |
+
<App />
|
|
|
|
|
|
|
| 9 |
)
|