Upload 63 files
Browse files- src/App.jsx +107 -115
- vite.config.js +1 -20
src/App.jsx
CHANGED
|
@@ -3,27 +3,21 @@ import { useStore } from './store';
|
|
| 3 |
import { Auth } from './components/Auth';
|
| 4 |
import { ProtectedRoute } from './components/ProtectedRoute';
|
| 5 |
import { KeyRound, Heart, X } from 'lucide-react';
|
| 6 |
-
import { useEffect, useState
|
| 7 |
import { socket } from './socket';
|
| 8 |
import { useLocation } from 'react-router-dom';
|
| 9 |
|
| 10 |
-
//
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
const LoadingFallback = () => (
|
| 23 |
-
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100px', color: 'var(--text-muted)' }}>
|
| 24 |
-
<div className="loading-dots">Loading...</div>
|
| 25 |
-
</div>
|
| 26 |
-
);
|
| 27 |
|
| 28 |
export default function App() {
|
| 29 |
const { currentUser, initDevice, logout } = useStore();
|
|
@@ -85,111 +79,109 @@ export default function App() {
|
|
| 85 |
|
| 86 |
return (
|
| 87 |
<div className={isAdminRoute ? "admin-container" : "app-container"}>
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
<
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
<
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
}}>
|
| 107 |
-
<
|
| 108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
<button
|
| 110 |
-
onClick={
|
| 111 |
-
|
|
|
|
| 112 |
>
|
| 113 |
-
<
|
| 114 |
</button>
|
| 115 |
</div>
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
<span style={{ fontSize: '12px', color: 'var(--text-muted)', textTransform: 'capitalize', display: 'none', '@media (min-width: 480px)': { display: 'inline' } }}>
|
| 119 |
-
{currentUser.name}
|
| 120 |
-
</span>
|
| 121 |
-
<button
|
| 122 |
-
onClick={handleSwitchProfile}
|
| 123 |
-
className="btn-secondary"
|
| 124 |
-
style={{ fontSize: '11px', padding: '5px 10px', display: 'flex', alignItems: 'center', gap: '6px' }}
|
| 125 |
-
>
|
| 126 |
-
<KeyRound size={13} /> Switch
|
| 127 |
-
</button>
|
| 128 |
-
</div>
|
| 129 |
-
)}
|
| 130 |
-
</header>
|
| 131 |
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
</div>
|
| 185 |
</div>
|
| 186 |
</div>
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
</>
|
| 191 |
-
|
| 192 |
-
|
| 193 |
</div>
|
| 194 |
);
|
| 195 |
}
|
|
|
|
| 3 |
import { Auth } from './components/Auth';
|
| 4 |
import { ProtectedRoute } from './components/ProtectedRoute';
|
| 5 |
import { KeyRound, Heart, X } from 'lucide-react';
|
| 6 |
+
import { useEffect, useState } from 'react';
|
| 7 |
import { socket } from './socket';
|
| 8 |
import { useLocation } from 'react-router-dom';
|
| 9 |
|
| 10 |
+
// Static imports for maximum build stability on Hugging Face
|
| 11 |
+
import { BuyerDashboard } from './components/BuyerDashboard';
|
| 12 |
+
import { SellerDashboard } from './components/SellerDashboard';
|
| 13 |
+
import { AddListing } from './components/AddListing';
|
| 14 |
+
import { ListingDetails } from './components/ListingDetails';
|
| 15 |
+
import { CallOverlay } from './components/CallOverlay';
|
| 16 |
+
import { HelpOverlay } from './components/HelpOverlay';
|
| 17 |
+
import { ChatOverlay } from './components/ChatOverlay';
|
| 18 |
+
import { InboxOverlay } from './components/InboxOverlay';
|
| 19 |
+
import { AdminLogin } from './components/admin/AdminLogin';
|
| 20 |
+
import { AdminDashboard } from './components/admin/AdminDashboard';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
export default function App() {
|
| 23 |
const { currentUser, initDevice, logout } = useStore();
|
|
|
|
| 79 |
|
| 80 |
return (
|
| 81 |
<div className={isAdminRoute ? "admin-container" : "app-container"}>
|
| 82 |
+
{isAdminRoute ? (
|
| 83 |
+
<Routes>
|
| 84 |
+
<Route path="/admin" element={<AdminLogin />} />
|
| 85 |
+
<Route path="/admin/dashboard" element={<AdminDashboard />} />
|
| 86 |
+
</Routes>
|
| 87 |
+
) : (
|
| 88 |
+
<>
|
| 89 |
+
<header style={{
|
| 90 |
+
padding: '15px 20px',
|
| 91 |
+
display: 'flex',
|
| 92 |
+
justifyContent: 'space-between',
|
| 93 |
+
alignItems: 'center',
|
| 94 |
+
borderBottom: '1px solid var(--border-color)',
|
| 95 |
+
backdropFilter: 'blur(10px)',
|
| 96 |
+
position: 'sticky',
|
| 97 |
+
top: 0,
|
| 98 |
+
zIndex: 10
|
| 99 |
+
}}>
|
| 100 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
| 101 |
+
<h2 className="text-gradient" onClick={() => navigate('/')} style={{ cursor: 'pointer', margin: 0, fontSize: '20px' }}>🌾 Meri Mandi</h2>
|
| 102 |
+
<button
|
| 103 |
+
onClick={() => setShowQR(true)}
|
| 104 |
+
style={{ background: 'linear-gradient(135deg, #ec4899, #be185d)', color: 'white', border: 'none', borderRadius: '12px', padding: '4px 10px', fontSize: '11px', display: 'flex', alignItems: 'center', gap: '4px', cursor: 'pointer', fontWeight: 600, marginLeft: '8px' }}
|
| 105 |
+
>
|
| 106 |
+
<Heart size={12} fill="white" /> Support
|
| 107 |
+
</button>
|
| 108 |
+
</div>
|
| 109 |
+
{currentUser && (
|
| 110 |
+
<div style={{ display: 'flex', alignItems: 'center', gap: '15px' }}>
|
| 111 |
+
<span style={{ fontSize: '12px', color: 'var(--text-muted)', textTransform: 'capitalize', display: 'none', '@media (min-width: 480px)': { display: 'inline' } }}>
|
| 112 |
+
{currentUser.name}
|
| 113 |
+
</span>
|
| 114 |
<button
|
| 115 |
+
onClick={handleSwitchProfile}
|
| 116 |
+
className="btn-secondary"
|
| 117 |
+
style={{ fontSize: '11px', padding: '5px 10px', display: 'flex', alignItems: 'center', gap: '6px' }}
|
| 118 |
>
|
| 119 |
+
<KeyRound size={13} /> Switch
|
| 120 |
</button>
|
| 121 |
</div>
|
| 122 |
+
)}
|
| 123 |
+
</header>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
+
<main style={{ flex: 1, padding: '15px', overflowY: 'auto' }}>
|
| 126 |
+
<Routes>
|
| 127 |
+
<Route path="/" element={
|
| 128 |
+
!currentUser ? <Auth /> : (
|
| 129 |
+
currentUser.role === 'buyer' ? <Navigate to="/buyer" /> : <Navigate to="/seller" />
|
| 130 |
+
)
|
| 131 |
+
} />
|
| 132 |
+
|
| 133 |
+
<Route path="/buyer" element={
|
| 134 |
+
<ProtectedRoute requiredRole="buyer">
|
| 135 |
+
<BuyerDashboard />
|
| 136 |
+
</ProtectedRoute>
|
| 137 |
+
} />
|
| 138 |
+
<Route path="/buyer/listing/:id" element={
|
| 139 |
+
<ProtectedRoute requiredRole="buyer">
|
| 140 |
+
<ListingDetails />
|
| 141 |
+
</ProtectedRoute>
|
| 142 |
+
} />
|
| 143 |
+
|
| 144 |
+
<Route path="/seller" element={
|
| 145 |
+
<ProtectedRoute requiredRole="seller">
|
| 146 |
+
<SellerDashboard />
|
| 147 |
+
</ProtectedRoute>
|
| 148 |
+
} />
|
| 149 |
+
<Route path="/seller/add" element={
|
| 150 |
+
<ProtectedRoute requiredRole="seller">
|
| 151 |
+
<AddListing />
|
| 152 |
+
</ProtectedRoute>
|
| 153 |
+
} />
|
| 154 |
+
</Routes>
|
| 155 |
+
</main>
|
| 156 |
|
| 157 |
+
<CallOverlay />
|
| 158 |
+
<HelpOverlay />
|
| 159 |
+
|
| 160 |
+
{showQR && (
|
| 161 |
+
<div style={{
|
| 162 |
+
position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, zIndex: 9999,
|
| 163 |
+
background: 'rgba(0,0,0,0.8)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '20px'
|
| 164 |
+
}}>
|
| 165 |
+
<div className="glass-panel" style={{ position: 'relative', width: '100%', maxWidth: '350px', padding: '30px', textAlign: 'center' }}>
|
| 166 |
+
<button
|
| 167 |
+
onClick={() => setShowQR(false)}
|
| 168 |
+
style={{ position: 'absolute', top: '15px', right: '15px', background: 'var(--danger-glass)', border: 'none', color: 'var(--danger-color)', width: '30px', height: '30px', borderRadius: '50%', display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer' }}
|
| 169 |
+
>
|
| 170 |
+
<X size={16} />
|
| 171 |
+
</button>
|
| 172 |
+
<Heart size={40} color="#ec4899" fill="#ec4899" style={{ marginBottom: '16px' }} />
|
| 173 |
+
<h3 style={{ fontSize: '20px', marginBottom: '8px' }}>Support Meri Mandi</h3>
|
| 174 |
+
<p style={{ color: 'var(--text-muted)', fontSize: '14px', marginBottom: '24px' }}>Scan to keep Meri Mandi free for farmers!</p>
|
| 175 |
+
<div style={{ background: 'white', padding: '10px', borderRadius: '16px', display: 'inline-block' }}>
|
| 176 |
+
<img src="/upiqr.jpeg" alt="UPI QR Code" style={{ width: '200px', height: '200px', objectFit: 'contain', display: 'block' }} />
|
|
|
|
| 177 |
</div>
|
| 178 |
</div>
|
| 179 |
+
</div>
|
| 180 |
+
)}
|
| 181 |
+
<InboxOverlay />
|
| 182 |
+
<ChatOverlay />
|
| 183 |
+
</>
|
| 184 |
+
)}
|
| 185 |
</div>
|
| 186 |
);
|
| 187 |
}
|
vite.config.js
CHANGED
|
@@ -6,30 +6,11 @@ export default defineConfig({
|
|
| 6 |
build: {
|
| 7 |
outDir: 'dist',
|
| 8 |
emptyOutDir: true,
|
| 9 |
-
minify: 'esbuild',
|
| 10 |
-
rollupOptions: {
|
| 11 |
-
output: {
|
| 12 |
-
manualChunks: {
|
| 13 |
-
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
| 14 |
-
'vendor-ui': ['framer-motion', 'lucide-react'],
|
| 15 |
-
'vendor-utils': ['socket.io-client', 'zustand', 'uuid'],
|
| 16 |
-
},
|
| 17 |
-
},
|
| 18 |
-
},
|
| 19 |
},
|
| 20 |
server: {
|
| 21 |
proxy: {
|
| 22 |
'/api': {
|
| 23 |
-
target: 'http://localhost:
|
| 24 |
-
changeOrigin: true
|
| 25 |
-
},
|
| 26 |
-
'/uploads': {
|
| 27 |
-
target: 'http://localhost:3001',
|
| 28 |
-
changeOrigin: true
|
| 29 |
-
},
|
| 30 |
-
'/socket.io': {
|
| 31 |
-
target: 'http://localhost:3001',
|
| 32 |
-
ws: true,
|
| 33 |
changeOrigin: true
|
| 34 |
}
|
| 35 |
}
|
|
|
|
| 6 |
build: {
|
| 7 |
outDir: 'dist',
|
| 8 |
emptyOutDir: true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
},
|
| 10 |
server: {
|
| 11 |
proxy: {
|
| 12 |
'/api': {
|
| 13 |
+
target: 'http://localhost:7860',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
changeOrigin: true
|
| 15 |
}
|
| 16 |
}
|