datamk commited on
Commit
9d647a4
·
verified ·
1 Parent(s): fb43d41

Upload 63 files

Browse files
Files changed (2) hide show
  1. src/App.jsx +107 -115
  2. 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, lazy, Suspense } from 'react';
7
  import { socket } from './socket';
8
  import { useLocation } from 'react-router-dom';
9
 
10
- // Lazy load heavy dashboard and overlay components
11
- const BuyerDashboard = lazy(() => import('./components/BuyerDashboard').then(m => ({ default: m.BuyerDashboard })));
12
- const SellerDashboard = lazy(() => import('./components/SellerDashboard').then(m => ({ default: m.SellerDashboard })));
13
- const AddListing = lazy(() => import('./components/AddListing').then(m => ({ default: m.AddListing })));
14
- const ListingDetails = lazy(() => import('./components/ListingDetails').then(m => ({ default: m.ListingDetails })));
15
- const CallOverlay = lazy(() => import('./components/CallOverlay').then(m => ({ default: m.CallOverlay })));
16
- const HelpOverlay = lazy(() => import('./components/HelpOverlay').then(m => ({ default: m.HelpOverlay })));
17
- const ChatOverlay = lazy(() => import('./components/ChatOverlay').then(m => ({ default: m.ChatOverlay })));
18
- const InboxOverlay = lazy(() => import('./components/InboxOverlay').then(m => ({ default: m.InboxOverlay })));
19
- const AdminLogin = lazy(() => import('./components/admin/AdminLogin').then(m => ({ default: m.AdminLogin })));
20
- const AdminDashboard = lazy(() => import('./components/admin/AdminDashboard').then(m => ({ default: m.AdminDashboard })));
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
- <Suspense fallback={<LoadingFallback />}>
89
- {isAdminRoute ? (
90
- <Routes>
91
- <Route path="/admin" element={<AdminLogin />} />
92
- <Route path="/admin/dashboard" element={<AdminDashboard />} />
93
- </Routes>
94
- ) : (
95
- <>
96
- <header style={{
97
- padding: '15px 20px',
98
- display: 'flex',
99
- justifyContent: 'space-between',
100
- alignItems: 'center',
101
- borderBottom: '1px solid var(--border-color)',
102
- backdropFilter: 'blur(10px)',
103
- position: 'sticky',
104
- top: 0,
105
- zIndex: 10
106
- }}>
107
- <div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
108
- <h2 className="text-gradient" onClick={() => navigate('/')} style={{ cursor: 'pointer', margin: 0, fontSize: '20px' }}>🌾 Meri Mandi</h2>
 
 
 
 
 
 
 
 
 
 
 
109
  <button
110
- onClick={() => setShowQR(true)}
111
- 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' }}
 
112
  >
113
- <Heart size={12} fill="white" /> Support
114
  </button>
115
  </div>
116
- {currentUser && (
117
- <div style={{ display: 'flex', alignItems: 'center', gap: '15px' }}>
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
- <main style={{ flex: 1, padding: '15px', overflowY: 'auto' }}>
133
- <Routes>
134
- <Route path="/" element={
135
- !currentUser ? <Auth /> : (
136
- currentUser.role === 'buyer' ? <Navigate to="/buyer" /> : <Navigate to="/seller" />
137
- )
138
- } />
139
-
140
- <Route path="/buyer" element={
141
- <ProtectedRoute requiredRole="buyer">
142
- <BuyerDashboard />
143
- </ProtectedRoute>
144
- } />
145
- <Route path="/buyer/listing/:id" element={
146
- <ProtectedRoute requiredRole="buyer">
147
- <ListingDetails />
148
- </ProtectedRoute>
149
- } />
150
-
151
- <Route path="/seller" element={
152
- <ProtectedRoute requiredRole="seller">
153
- <SellerDashboard />
154
- </ProtectedRoute>
155
- } />
156
- <Route path="/seller/add" element={
157
- <ProtectedRoute requiredRole="seller">
158
- <AddListing />
159
- </ProtectedRoute>
160
- } />
161
- </Routes>
162
- </main>
163
 
164
- <CallOverlay />
165
- <HelpOverlay />
166
-
167
- {showQR && (
168
- <div style={{
169
- position: 'fixed', top: 0, left: 0, right: 0, bottom: 0, zIndex: 9999,
170
- background: 'rgba(0,0,0,0.8)', display: 'flex', alignItems: 'center', justifyContent: 'center', padding: '20px'
171
- }}>
172
- <div className="glass-panel" style={{ position: 'relative', width: '100%', maxWidth: '350px', padding: '30px', textAlign: 'center' }}>
173
- <button
174
- onClick={() => setShowQR(false)}
175
- 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' }}
176
- >
177
- <X size={16} />
178
- </button>
179
- <Heart size={40} color="#ec4899" fill="#ec4899" style={{ marginBottom: '16px' }} />
180
- <h3 style={{ fontSize: '20px', marginBottom: '8px' }}>Support Meri Mandi</h3>
181
- <p style={{ color: 'var(--text-muted)', fontSize: '14px', marginBottom: '24px' }}>Scan to keep Meri Mandi free for farmers!</p>
182
- <div style={{ background: 'white', padding: '10px', borderRadius: '16px', display: 'inline-block' }}>
183
- <img src="/upiqr.jpeg" alt="UPI QR Code" style={{ width: '200px', height: '200px', objectFit: 'contain', display: 'block' }} />
184
- </div>
185
  </div>
186
  </div>
187
- )}
188
- <InboxOverlay />
189
- <ChatOverlay />
190
- </>
191
- )}
192
- </Suspense>
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:3001',
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
  }