Skip to content

Commit 9a8d008

Browse files
authored
Merge pull request #70 from akshat-code21/new
UI changes and total potholes counter being fetched real-time
2 parents 3796d69 + e7cf20e commit 9a8d008

5 files changed

Lines changed: 188 additions & 155 deletions

File tree

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
MONGO_URL =
2-
JWT_SECRET =
2+
JWT_SECRET =
3+
TWITTER_API_KEY =
4+
TWITTER_API_SECRET =
5+
TWITTER_ACCESS_TOKEN =
6+
TWITTER_ACCESS_SECRET =
7+
CLOUDINARY_CLOUD_NAME=
8+
CLOUDINARY_API_KEY=
9+
CLOUDINARY_API_SECRET=
Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
1-
import express from "express"
1+
import express from "express";
22
import authRouter from "./routes/auth";
33
import potholeRouter from "./routes/pothole";
44
import path from "path";
55
import cors from "cors";
6+
import { ReportModel } from "./models";
67

78
const app = express();
89

910
// Enable CORS
10-
app.use(cors({
11-
origin: '*',
12-
methods: ['GET', 'POST'],
13-
allowedHeaders: ['Content-Type', 'Authorization'],
14-
}));
11+
app.use(
12+
cors({
13+
origin: "*",
14+
methods: ["GET", "POST"],
15+
allowedHeaders: ["Content-Type", "Authorization"],
16+
})
17+
);
1518

1619
// Body parser middleware
1720
app.use(express.json());
1821
app.use(express.urlencoded({ extended: true }));
1922

2023
// Serve uploaded files statically
21-
app.use('/uploads', express.static(path.join(__dirname, '../uploads')));
24+
app.use("/uploads", express.static(path.join(__dirname, "../uploads")));
2225

2326
// Routes
24-
app.use('/api/v1/auth', authRouter);
25-
app.use('/api/v1/pothole', potholeRouter);
27+
app.use("/api/v1/auth", authRouter);
28+
app.use("/api/v1/pothole", potholeRouter);
2629

27-
app.get('/', (req, res) => {
28-
res.send('Pot Hole Detector Backend');
30+
app.get("/", (req, res) => {
31+
res.send("Pot Hole Detector Backend");
32+
});
33+
app.get("/total-reports", async (req, res) => {
34+
const totalReports = await ReportModel.countDocuments();
35+
res.json({ totalReports });
2936
});
30-
3137

3238
const PORT = process.env.PORT || 3000;
3339

3440
app.listen(PORT, () => {
3541
console.log(`Server is running on port ${PORT}`);
36-
});
42+
});

App/Pot-Hole-Detector-Frontend/app/(tabs)/camera.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ const styles = StyleSheet.create({
503503
width: '100%',
504504
height: '80%',
505505
borderRadius: 15,
506-
marginBottom: 20,
506+
marginBottom: 10,
507507
},
508508
buttonContainer: {
509509
flexDirection: 'row',

App/Pot-Hole-Detector-Frontend/app/(tabs)/dashboard.tsx

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -314,48 +314,52 @@ export default function Dashboard() {
314314
<Text style={styles.loadingText}>Loading Dashboard...</Text>
315315
</View>
316316
) : (
317-
<FlatList
318-
data={recentDetections}
319-
keyExtractor={(item) => item.id.toString()}
320-
renderItem={renderRecentDetection}
321-
ListHeaderComponent={ListHeader}
322-
ListFooterComponent={
323-
<>
324-
{/* Map with Pothole Locations */}
325-
<View style={styles.mapCard}>
326-
<Text style={styles.cardTitle}>Pothole Locations in India</Text>
327-
{mapMarkers.length > 0 ? (
328-
<MapView
329-
style={styles.map}
330-
initialRegion={{
331-
latitude: 20.5937,
332-
longitude: 78.9629,
333-
latitudeDelta: 30,
334-
longitudeDelta: 30,
335-
}}
336-
>
337-
{mapMarkers.map((marker: MapMarker) => (
338-
<Marker
339-
key={marker.id}
340-
coordinate={{
341-
latitude: marker.latitude,
342-
longitude: marker.longitude,
343-
}}
344-
title={marker.title}
345-
/>
346-
))}
347-
</MapView>
348-
) : (
349-
<View style={[styles.map, styles.noMapData]}>
350-
<Text style={styles.noMapDataText}>No pothole locations to display</Text>
351-
</View>
352-
)}
353-
</View>
354-
</>
355-
}
356-
contentContainerStyle={styles.flatListContent}
357-
showsVerticalScrollIndicator={false}
358-
/>
317+
<View style={styles.contentContainer}>
318+
<FlatList
319+
data={recentDetections}
320+
keyExtractor={(item) => item.id.toString()}
321+
renderItem={renderRecentDetection}
322+
ListHeaderComponent={ListHeader}
323+
ListFooterComponent={
324+
<>
325+
{/* Map with Pothole Locations */}
326+
<View style={styles.mapCard}>
327+
<Text style={styles.cardTitle}>Pothole Locations in India</Text>
328+
{mapMarkers.length > 0 ? (
329+
<MapView
330+
style={styles.map}
331+
initialRegion={{
332+
latitude: 20.5937,
333+
longitude: 78.9629,
334+
latitudeDelta: 30,
335+
longitudeDelta: 30,
336+
}}
337+
>
338+
{mapMarkers.map((marker: MapMarker) => (
339+
<Marker
340+
key={marker.id}
341+
coordinate={{
342+
latitude: marker.latitude,
343+
longitude: marker.longitude,
344+
}}
345+
title={marker.title}
346+
/>
347+
))}
348+
</MapView>
349+
) : (
350+
<View style={[styles.map, styles.noMapData]}>
351+
<Text style={styles.noMapDataText}>No pothole locations to display</Text>
352+
</View>
353+
)}
354+
</View>
355+
{/* Add bottom padding to account for BottomNav */}
356+
<View style={{ height: 80 }} />
357+
</>
358+
}
359+
contentContainerStyle={styles.flatListContent}
360+
showsVerticalScrollIndicator={false}
361+
/>
362+
</View>
359363
)}
360364
<BottomNav />
361365
</View>
@@ -367,6 +371,9 @@ const styles = StyleSheet.create({
367371
flex: 1,
368372
backgroundColor: '#fff',
369373
},
374+
contentContainer: {
375+
flex: 1,
376+
},
370377
safeArea: {
371378
flex: 1,
372379
backgroundColor: '#EFEFEF',

0 commit comments

Comments
 (0)