From 8480ae5eaa5307f3513a5839ddab337d973abbd2 Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 3 Sep 2025 17:47:34 +0530 Subject: [PATCH] updates --- index.html | 7 ++-- package-lock.json | 29 +++++++++++----- package.json | 2 +- public/manifest.json | 14 ++++---- public/sw.js | 16 +++++++++ src/App.tsx | 2 ++ src/Components/AboutRideNitt.tsx | 20 +++++++++++ src/Components/Navigation.tsx | 5 +-- src/Hooks/useAuth.tsx | 3 +- src/Hooks/usePushNotifications.tsx | 54 ++++++++++++++++++++++++++++++ src/Pages/Account.tsx | 14 +++++++- src/Pages/Login.tsx | 42 +++++++++++------------ vite.config.ts | 22 +----------- 13 files changed, 158 insertions(+), 72 deletions(-) create mode 100644 public/sw.js create mode 100644 src/Components/AboutRideNitt.tsx create mode 100644 src/Hooks/usePushNotifications.tsx diff --git a/index.html b/index.html index 9048d12..99b08d3 100644 --- a/index.html +++ b/index.html @@ -9,16 +9,15 @@ - - - + - + +
diff --git a/package-lock.json b/package-lock.json index a47c6c0..aedfe8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "@tailwindcss/postcss": "^4.0.1", - "axios": "^1.7.9", + "axios": "^1.11.0", "classnames": "^2.5.1", "daisyui": "^4.12.23", "dotenv": "^16.4.7", @@ -3382,7 +3382,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" }, "node_modules/at-least-node": { "version": "1.0.0", @@ -3446,12 +3447,13 @@ } }, "node_modules/axios": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", - "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.11.0.tgz", + "integrity": "sha512-1Lx3WLFQWm3ooKDYZD1eXmoGO9fxYQjrycfHFC8P0sCfQVXyROp0p9PFWBehewBOdCwHc+f/b8I0fMto5eSfwA==", + "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", + "form-data": "^4.0.4", "proxy-from-env": "^1.1.0" } }, @@ -3742,6 +3744,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", "dependencies": { "delayed-stream": "~1.0.0" }, @@ -4003,6 +4006,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", "engines": { "node": ">=0.4.0" } @@ -4686,13 +4690,15 @@ } }, "node_modules/form-data": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", - "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", "mime-types": "^2.1.12" }, "engines": { @@ -5666,6 +5672,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz", "integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==", + "license": "MIT", "engines": { "node": ">=18" } @@ -6057,6 +6064,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", "engines": { "node": ">= 0.6" } @@ -6065,6 +6073,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", "dependencies": { "mime-db": "1.52.0" }, @@ -6624,6 +6633,7 @@ "version": "18.3.1", "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", "dependencies": { "loose-envify": "^1.1.0" }, @@ -6635,6 +6645,7 @@ "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "license": "MIT", "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" diff --git a/package.json b/package.json index f36221a..c46e94b 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@tailwindcss/postcss": "^4.0.1", - "axios": "^1.7.9", + "axios": "^1.11.0", "classnames": "^2.5.1", "daisyui": "^4.12.23", "dotenv": "^16.4.7", diff --git a/public/manifest.json b/public/manifest.json index 080d6c7..f12a7b4 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,25 +1,25 @@ { - "short_name": "React App", - "name": "Create React App Sample", + "short_name": "Ride NITT", + "name": "Ride NITT", "icons": [ { - "src": "favicon.ico", + "src": "/logo.png", "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" + "type": "image/png" }, { - "src": "logo192.png", + "src": "/logo.png", "type": "image/png", "sizes": "192x192" }, { - "src": "logo512.png", + "src": "/logo.png", "type": "image/png", "sizes": "512x512" } ], "start_url": ".", "display": "standalone", - "theme_color": "#000000", + "theme_color": "#008955", "background_color": "#ffffff" } diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..ab346c8 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,16 @@ +self.addEventListener("push", (event) => { + const data = event.data.json(); + + event.waitUntil( + self.registration.showNotification(data.title, { + body: data.body, + icon: data.icon || "/logo.png", + data: { url: data.url || "/" } + }) + ); +}); + +self.addEventListener("notificationclick", (event) => { + event.notification.close(); + event.waitUntil(clients.openWindow(event.notification.data.url)); +}); diff --git a/src/App.tsx b/src/App.tsx index 76808de..53661c0 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -19,6 +19,7 @@ import LoadingScreen from "./Components/LoadingScreen"; import React from "react"; import NewAccountSignup from "./Pages/NewAccountSignup.tsx"; import Redirect from "./Components/Redirect.tsx"; +import usePushNotifications from "./Hooks/usePushNotifications"; const App: React.FC = () => { return ( @@ -31,6 +32,7 @@ const App: React.FC = () => { const CustomRouter = () => { const { authLoading, user, hasSignedUp } = useAuth() + usePushNotifications(user); return ( diff --git a/src/Components/AboutRideNitt.tsx b/src/Components/AboutRideNitt.tsx new file mode 100644 index 0000000..4226708 --- /dev/null +++ b/src/Components/AboutRideNitt.tsx @@ -0,0 +1,20 @@ +import React from "react"; + +const AboutRideNitt: React.FC<{ show: boolean; onClose: () => void }> = ({ show, onClose }) => { + if (!show) return null; + return ( +
+
e.stopPropagation()} + > +

About RideNITT

+

content

+ +
+
+ ); +}; + +export default AboutRideNitt; diff --git a/src/Components/Navigation.tsx b/src/Components/Navigation.tsx index 16796f2..f91404d 100644 --- a/src/Components/Navigation.tsx +++ b/src/Components/Navigation.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from "react"; +import React from "react"; import { Link, useLocation } from "react-router-dom"; import { useAuth } from "../Hooks/useAuth"; import { IoSpeedometer, IoSpeedometerOutline } from "react-icons/io5"; @@ -8,9 +8,6 @@ const Navigation: React.FC = () => { const { user } = useAuth() const location = useLocation() - useEffect(() => { - console.log(location.pathname) - }, [location]) return (