From 85fe4db5c4f4561191b868cdcd2c94f6fa11455b Mon Sep 17 00:00:00 2001 From: haseebzaki-07 Date: Wed, 16 Oct 2024 20:50:46 +0530 Subject: [PATCH 1/3] Add favorites frontend --- frontend/src/Pages/stations.jsx | 294 +++++++++----------------------- 1 file changed, 77 insertions(+), 217 deletions(-) diff --git a/frontend/src/Pages/stations.jsx b/frontend/src/Pages/stations.jsx index f96cb95..76b24e1 100644 --- a/frontend/src/Pages/stations.jsx +++ b/frontend/src/Pages/stations.jsx @@ -2,7 +2,7 @@ import React, { useState , useEffect} from "react"; import { FaTrain } from "react-icons/fa"; // Using FontAwesome train icon -import { AiFillStar, AiOutlineStar } from "react-icons/ai"; // Star icons for favorites +import { AiFillCaretDown, AiFillCaretUp, AiFillStar, AiOutlineStar } from "react-icons/ai"; // Star icons for favorites import { useNavigate } from "react-router-dom"; import backicon from "../assets/svg/backicon.svg"; import { div, h1 } from "framer-motion/client"; @@ -24,149 +24,6 @@ const RailwayStations = () => { navigate("/"); // Navigates to the home page }; - // const stations = [ - // { name: "Agartala Railway Station (AGTL)", state: "Tripura" }, - // { name: "Agra Cantonment (AGC)", state: "Uttar Pradesh" }, - // { name: "Ahmedabad Junction (ADI)", state: "Gujarat" }, - // { name: "Ahmednagar (ANG)", state: "Maharashtra" }, - // { name: "Aizawl (AZS)", state: "Mizoram" }, - // { name: "Ajmer Junction (AII)", state: "Rajasthan" }, - // { name: "Akola Junction (AK)", state: "Maharashtra" }, - // { name: "Alappuzha (ALLP)", state: "Kerala" }, - // { name: "Aligarh Junction (ALJN)", state: "Uttar Pradesh" }, - // { name: "Allahabad Junction (Prayagraj)", state: "Uttar Pradesh" }, - // { name: "Almora (ALM)", state: "Uttarakhand" }, - // { name: "Ambala Cantonment (UMB)", state: "Haryana" }, - // { name: "Ambarnath (ABH)", state: "Maharashtra" }, - // { name: "Amritsar Junction (ASR)", state: "Punjab" }, - // { name: "Anand Junction (ANND)", state: "Gujarat" }, - // { name: "Anand Vihar Terminal (ANVT)", state: "Delhi" }, - // { name: "Anantnag (ANT)", state: "Jammu and Kashmir" }, - // { name: "Angul (ANGL)", state: "Odisha" }, - // { name: "Ankleshwar Junction (AKV)", state: "Gujarat" }, - // { name: "Arakkonam Junction (AK)", state: "Tamil Nadu" }, - // { name: "Aurangabad (ABD)", state: "Maharastra" }, - // { name: "Ayodhya (AY)", state: "Uttar Pradesh" }, - // { name: "Bangalore City Railway Station (SBC)", state: "Karnataka" }, - // { name: "Bareilly Junction (BE)", state: "Uttar Pradesh" }, - // { name: "Bhopal Junction (BPL)", state: "Madhya Pradesh" }, - // { name: "Bhubaneswar Railway Station (BBS)", state: "Odisha" }, - // { name: "Bhilai Nagar (BIA)", state: "Chhattisgarh" }, - // { name: "Bikaner Junction (BNK)", state: "Rajasthan" }, - // { name: "Bilaspur Junction (BSP)", state: "Chhattisgarh" }, - // { name: "Bokaro Steel City (BKSC)", state: "Jharkhand" }, - // { name: "Bangalore Cantt (BNC)", state: "Karnataka" }, - // { name: "Bangalore East (BNCE)", state: "Karnataka" }, - // { name: "Bangalore South (BNCS)", state: "Karnataka" }, - // { name: "Bangalore West (BNCW)", state: "Karnataka" }, - // { name: "Balurghat Junction (BGQ)", state: "West Bengal" }, - // { name: "Belgaum (BGM)", state: "Karnataka" }, - // { name: "Bhuj Junction (BHJ)", state: "Gujarat" }, - // { name: "Baroda (BRC)", state: "Gujarat" }, - // { name: "Bikaner City (BNK)", state: "Rajasthan" }, - // { name: "Bokaro Town (BKOT)", state: "Jharkhand" }, - // { name: "Chandigarh Junction (CDG)", state: "Chandigarh" }, - // { name: "Chennai Central (MAS)", state: "Tamil Nadu" }, - // { name: "Chennai Egmore (EMU)", state: "Tamil Nadu" }, - // { name: "Chennai Park (CPK)", state: "Tamil Nadu" }, - // { name: "Chennai Port (CPT)", state: "Tamil Nadu" }, - // { name: "Chennai Tambaram (TBM)", state: "Tamil Nadu" }, - // { name: "Chitradurga (CDT)", state: "Karnataka" }, - // { name: "Chittaranjan (CRJ)", state: "West Bengal" }, - // { name: "Coimbatore Junction (CBE)", state: "Tamil Nadu" }, - // { name: "Cochin Ernakulam Junction (ERS)", state: "Kerala" }, - // { name: "Cooch Behar Junction (COB)", state: "West Bengal" }, - // { name: "Coonoor (ONR)", state: "Tamil Nadu" }, - // { name: "Dabhoi Junction (DB)", state: "Gujarat" }, - // { name: "Darbhanga Junction (DBG)", state: "Bihar" }, - // { name: "Dadar Western (DDR)", state: "Maharashtra" }, - // { name: "Darjeeling (DJ)", state: "West Bengal" }, - // { name: "Dharwad Junction (DWR)", state: "Karnataka" }, - // { name: "Dharmavaram (DMM)", state: "Andhra Pradesh" }, - // { name: "Delhi Junction (DLI)", state: "Delhi" }, - // { name: "Delhi Cantt (DEC)", state: "Delhi" }, - // { name: "Delhi Sarai Rohilla (DEE)", state: "Delhi" }, - // { name: "Delhi Anand Vihar (ANVR)", state: "Delhi" }, - // { name: "Delhi Rajdhani (NDLS)", state: "Delhi" }, - // { name: "Dhanbad Junction (DHN)", state: "Jharkhand" }, - // { name: "Dhanera Junction (DHR)", state: "Gujarat" }, - // { name: "Dibrugarh Junction (DBR)", state: "Assam" }, - // { name: "Dibrugarh Town (DBRT)", state: "Assam" }, - // { name: "Dibrugarh Station(DBRG)", state: "Assam" }, - // { name: "Dharamshala Junction ", state: "Himachal Pradesh" }, - // { name: "Dharamshala Railway Station (DHM)", state: "Himachal Pradesh" }, - // { name: "Ernakulam Junction (ERK)", state: "Kerala" }, - // { name: "Gwalior Junction (GWL)", state: "Madhya Pradesh" }, - // { name: "Gurgaon Junction (GGN)", state: "Haryana" }, - // { name: "Guwahati Junction (GHY)", state: "Assam" }, - // { name: "Gaya Junction (GAYA)", state: "Bihar" }, - // { name: "Howrah Junction (HWH)", state: "West Bengal" }, - // { name: "Hubli Junction (UBL)", state: "Karnataka" }, - // { name: "Hyderabad Deccan (HYB)", state: "Telangana" }, - // { name: "Hazaribagh Junction (HZB)", state: "Jharkhand" }, - // { name: "Hazart Nizamuddin (NZM)", state: "Delhi" }, - // { name: "Indore Junction (INDB)", state: "Madhya Pradesh" }, - // { name: "Itarsi Junction (ET)", state: "Madhya Pradesh" }, - // { name: "Jabalpur Junction (JBP)", state: "Madhya Pradesh" }, - // { name: "Jaipur Junction (JP)", state: "Rajasthan" }, - // { name: "Jalandhar City (JUC)", state: "Punjab" }, - // { name: "Jammu Tawi (JAT)", state: "Jammu and Kashmir" }, - // { name: "Jodhpur Junction (JOD)", state: "Rajasthan" }, - // { name: "Kanpur Central (CNB)", state: "Uttar Pradesh" }, - // { name: "Kalyan Junction (KYN)", state: "Maharashtra" }, - // { name: "Kolkata Chitpur (Howrah)", state: "West Bengal" }, - // { name: "Kharagpur Junction (KGP)", state: "West Bengal" }, - // { name: "Kota Junction (KOTA)", state: "Rajasthan" }, - // { name: "Lucknow Charbagh (LKO)", state: "Uttar Pradesh" }, - // { name: "Ludhiana Junction (LDH)", state: "Punjab" }, - // { name: "Madurai Junction (MDU)", state: "Tamil Nadu" }, - // { name: "Mangalore Junction (MAJN)", state: "Karnataka" }, - // { name: "Mumbai Central (MMCT)", state: "Maharashtra" }, - // { - // name: "Mumbai CST (Chhatrapati Shivaji Maharaj Terminus)", - // state: "Maharashtra", - // }, - // { name: "Mysore Junction (MYS)", state: "Karnataka" }, - // { name: "Mathura Junction (MTJ)", state: "Uttar Pradesh" }, - // { name: "Nagpur Junction (NGP)", state: "Maharashtra" }, - // { name: "Nanded Junction (NED)", state: "Maharashtra" }, - // { name: "New Delhi Railway Station (NDLS)", state: "Delhi" }, - // { name: "Patna Junction (PNBE)", state: "Bihar" }, - // { name: "Pune Junction (PUNE)", state: "Maharashtra" }, - // { name: "Patiala Junction (PTA)", state: "Punjab" }, - // { name: "Panvel Junction (PNVL)", state: "Maharashtra" }, - // { name: "Panki Railway Station (PNK)", state: "Uttar Pradesh" }, - // { name: "Panipat Junction (PNP)", state: "Haryana" }, - // { name: "Quilon Junction (QLN)", state: "Kerala" }, - // { name: "Ranchi Junction (RNC)", state: "Jharkhand" }, - // { name: "Rajkot Junction (RJT)", state: "Gujarat" }, - // { name: "Rourkela Junction (ROU)", state: "Odisha" }, - // { name: "Rohtak Junction (ROK)", state: "Haryana" }, - // { name: "Rewari Junction (RE)", state: "Haryana" }, - // { name: "Secunderabad Junction (SC)", state: "Telangana" }, - // { name: "Siliguri Junction (SGUJ)", state: "West Bengal" }, - // { name: "Sonebhadra (SBP)", state: "Uttar Pradesh" }, - // { name: "Surat Junction (ST)", state: "Gujarat" }, - // { name: "Thiruvananthapuram Central (TVC)", state: "Kerala" }, - // { name: "Trivandrum Central (TVC)", state: "Kerala" }, - // { name: "Tirupati Railway Station (TPTY)", state: "Andhra Pradesh" }, - // { name: "Thanjavur Junction (TJ)", state: "Tamil Nadu" }, - // { name: "Udaipur City (UDZ)", state: "Rajasthan" }, - // { name: "Ujjain Junction (UJN)", state: "Madhya Pradesh" }, - // { name: "Vadodara Junction (BRC)", state: "Gujarat" }, - // { name: "Varanasi Junction (VNS)", state: "Uttar Pradesh" }, - // { name: "Vellore Cantt (VLCY)", state: "Tamil Nadu" }, - // { name: "Vijayawada Junction (BZA)", state: "Andhra Pradesh" }, - // { name: "Visakhapatnam Junction (VSKP)", state: "Andhra Pradesh" }, - // { name: "West Bengal Howrah (HWH)", state: "West Bengal" }, - // { name: "Wayanad (WY)", state: "Kerala" }, - // { name: "Warangal (WL)", state: "Telangana" }, - // { name: "Yeshvantpur Junction (YPR)", state: "Karnataka" }, - // { name: "Yelahanka Junction (YNK)", state: "Karnataka" }, - // { name: "Ziyadpur Junction (ZYP)", state: "Uttar Pradesh" }, // Replace "Unknown" with the correct state if known - // // Add more stations as needed - // ]; - const [stations, setStations] = useState(allStations); @@ -199,6 +56,7 @@ const RailwayStations = () => { const [favorites, setFavorites] = useState([]); const [selectedZone, setSelectedZone] = useState("All"); const [loading, setLoading] = useState(false); + const [showFavorites, setShowFavorites] = useState(false); // Function to toggle favorite stations const toggleFavorite = (station) => { @@ -206,6 +64,7 @@ const RailwayStations = () => { setFavorites(favorites.filter((fav) => fav !== station)); } else { setFavorites([...favorites, station]); + console.log(favorites); } }; @@ -250,14 +109,10 @@ const RailwayStations = () => { {/* Header Section */}
+

Railway Stations

@@ -265,76 +120,79 @@ const RailwayStations = () => {

- {/* Search Bar and State Filter */} -
- setSearchTerm(e.target.value)} - className="w-full max-w-md px-4 py-2 transition duration-300 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" - /> - -
+ {/* Main Content: Stations Grid and Favorites Side-by-Side */} +
+ {/* Stations Grid on the Left */} +
+ {/* Search Bar and State Filter */} +
+ setSearchTerm(e.target.value)} + className="w-full max-w-md px-4 py-2 transition duration-300 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" + /> + +
- {/* Stations Grid */} -
-
- {filteredStations.length > 0 ? ( - filteredStations.map((station, index) => ( -
-
- - - {station.name} - + {/* Stations Grid */} +
+
+ {filteredStations.length > 0 ? ( + filteredStations.map((station, index) => ( +
+
+ + + {station.name} + +
+ +
+ )) + ) : ( +
+ No stations found.
- -
- )) - ) : ( -
- No stations found. + )}
- )} +
-
- {/* Favorites Section (Optional) */} - {favorites.length > 0 && ( -
-

- Your Favorite Stations -

-
-
+ {/* Favorites Section on the Right */} +
+

Your Favorite Stations

+ + {favorites.length > 0 ? ( +
{favorites.map((station, index) => (
{
))}
-
+ ) : ( +

No favorite stations selected.

+ )}
- )} +
); }; From 897525002a5e0e6075db22676fd959c82e7e6e04 Mon Sep 17 00:00:00 2001 From: haseebzaki-07 Date: Fri, 18 Oct 2024 22:15:58 +0530 Subject: [PATCH 2/3] update favorite location --- frontend/src/Pages/stations.jsx | 172 ++++++++++++++++---------------- 1 file changed, 85 insertions(+), 87 deletions(-) diff --git a/frontend/src/Pages/stations.jsx b/frontend/src/Pages/stations.jsx index 76b24e1..f6c4e95 100644 --- a/frontend/src/Pages/stations.jsx +++ b/frontend/src/Pages/stations.jsx @@ -112,113 +112,111 @@ const RailwayStations = () => {
- +

Railway Stations

Find and explore railway stations across India

- - {/* Main Content: Stations Grid and Favorites Side-by-Side */} -
- {/* Stations Grid on the Left */} -
- {/* Search Bar and State Filter */} -
- setSearchTerm(e.target.value)} - className="w-full max-w-md px-4 py-2 transition duration-300 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" - /> - -
- - {/* Stations Grid */} -
-
- {filteredStations.length > 0 ? ( - filteredStations.map((station, index) => ( -
-
- - - {station.name} - -
- -
- )) - ) : ( -
- No stations found. -
- )} -
-
+ + {/* Main Content: Stations Grid */} +
+ {/* Search Bar and State Filter */} +
+ setSearchTerm(e.target.value)} + className="w-full max-w-md px-4 py-2 transition duration-300 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500" + /> +
- - {/* Favorites Section on the Right */} -
-

Your Favorite Stations

- - {favorites.length > 0 ? ( -
- {favorites.map((station, index) => ( + + {/* Stations Grid */} +
+
+ {filteredStations.length > 0 ? ( + filteredStations.map((station, index) => (
- - {station} + + + {station.name} +
- ))} -
- ) : ( -

No favorite stations selected.

- )} + )) + ) : ( +
+ No stations found. +
+ )} +
+ + {/* Favorites Section - Moved to the Last */} +
+

Your Favorite Stations

+ + {favorites.length > 0 ? ( +
+ {favorites.map((station, index) => ( +
+
+ + {station} +
+ +
+ ))} +
+ ) : ( +

No favorite stations selected.

+ )} +
); + }; export default RailwayStations; From 37956b531384973d34aca54405c17802f9ee815a Mon Sep 17 00:00:00 2001 From: haseebzaki-07 Date: Sat, 19 Oct 2024 00:32:38 +0530 Subject: [PATCH 3/3] Fix signup errors --- frontend/src/Pages/Register.jsx | 2 +- frontend/src/validations/validation.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/Pages/Register.jsx b/frontend/src/Pages/Register.jsx index a469e94..6bbfe81 100644 --- a/frontend/src/Pages/Register.jsx +++ b/frontend/src/Pages/Register.jsx @@ -48,7 +48,7 @@ const Register = () => { try { const response = await fetch( - "https://stationguide.onrender.com/api/register", + "http://localhost:3000/api/register", { method: "POST", headers: { diff --git a/frontend/src/validations/validation.js b/frontend/src/validations/validation.js index 577eb05..131acce 100644 --- a/frontend/src/validations/validation.js +++ b/frontend/src/validations/validation.js @@ -17,7 +17,7 @@ export const registerValidation = yup.object().shape({ /^(?:\+91[-\s]?)?[789]\d{9}$/, "Phone number must be in a valid format" ) - .required("Phone number is required"), + .optional(""), password: yup .string() .min(6, "Password should be at least 6 characters")