From d35cccafaaf33aeae27e461925e58753087caedb Mon Sep 17 00:00:00 2001 From: shrutu0929 <2023bcs006@sggs.ac.in> Date: Sun, 3 Aug 2025 18:52:18 +0530 Subject: [PATCH 1/2] docs: Add detailed README with project documentation --- README.md | 190 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 151 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index b87cb00..1cb8db1 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,158 @@ -# Getting Started with Create React App +# TripGo - Your Ultimate Travel Planning Application 🌍✈️ + +## Overview + +TripGo is a modern, user-friendly travel planning application built with React and TypeScript. It helps users discover and explore beautiful tourist destinations across India, offering detailed information about cities, attractions, and travel experiences. + +![TripGo Interface](public/logo192.png) + +## Features 🌟 + +### 1. City-wise Tourist Spots πŸ›οΈ +- Comprehensive database of tourist destinations +- High-quality images of attractions +- Detailed information about each location +- Seasonal visit recommendations +- Local tips and insights + +### 2. User-Friendly Navigation 🎯 +- Intuitive interface design +- Smart search functionality +- Quick filters for destinations +- Interactive maps +- Seamless user experience + +### 3. Personalized Experience πŸ’ +- User authentication system +- Favorite destination saving +- Custom travel planning +- Personal travel history +- Preference-based recommendations + +### 4. Mobile Responsive Design πŸ“± +- Fully responsive layout +- Cross-platform compatibility +- Touch-friendly interface +- Optimized performance +- Offline accessibility + +## Technical Stack πŸ’» + +- **Frontend Framework:** React +- **Language:** TypeScript +- **Styling:** CSS3 with modern features +- **Authentication:** Supabase +- **State Management:** React Context +- **Routing:** React Router +- **Icons:** React Icons +- **Animation:** Custom CSS animations + +## Getting Started πŸš€ + +### Prerequisites +- Node.js (v14 or higher) +- npm or yarn +- Git + +### Installation + +1. Clone the repository: +\`\`\`bash +git clone https://github.com/shrutu0929/TripGo.git +\`\`\` + +2. Navigate to the project directory: +\`\`\`bash +cd TripGo +\`\`\` + +3. Install dependencies: +\`\`\`bash +npm install +\`\`\` + +4. Create a .env file in the root directory and add your Supabase credentials: +\`\`\`env +REACT_APP_SUPABASE_URL=your_supabase_url +REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_key +\`\`\` + +5. Start the development server: +\`\`\`bash +npm start +\`\`\` + +The application will open in your default browser at `http://localhost:3000`. + +## Project Structure πŸ“ + +\`\`\` +tripgo/ +β”œβ”€β”€ public/ +β”‚ β”œβ”€β”€ images/ +β”‚ └── index.html +β”œβ”€β”€ src/ +β”‚ β”œβ”€β”€ components/ +β”‚ β”œβ”€β”€ config/ +β”‚ β”œβ”€β”€ data/ +β”‚ β”œβ”€β”€ pages/ +β”‚ β”œβ”€β”€ styles/ +β”‚ └── App.tsx +β”œβ”€β”€ package.json +└── README.md +\`\`\` + +## Key Components πŸ”‘ + +- **AnimatedBackground:** Creates engaging background animations +- **CurtainAnimation:** Handles loading transitions +- **FeatureDetails:** Displays detailed feature information +- **SearchBar:** Enables destination search functionality +- **UnifiedStarBackground:** Provides consistent themed backgrounds + +## Styling and Themes 🎨 + +The application uses a modern, clean design with: +- Responsive layouts +- Custom animations +- Consistent color schemes +- Professional typography +- Intuitive navigation elements + +## Authentication πŸ” + +User authentication is handled through Supabase, providing: +- Secure login/signup +- Password recovery +- Session management +- Protected routes +- User profile management + +## Contributing 🀝 + +We welcome contributions! Please follow these steps: + +1. Fork the repository +2. Create a feature branch +3. Commit your changes +4. Push to the branch +5. Open a Pull Request -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +## License πŸ“„ + +This project is licensed under the MIT License - see the LICENSE file for details. -## Available Scripts +## Contact πŸ“§ -In the project directory, you can run: +- Developer: Shruti Kulkarni +- GitHub: [@shrutu0929](https://github.com/shrutu0929) -### `npm start` +## Acknowledgments πŸ™ -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +- Thanks to all contributors +- Inspired by the need for better travel planning tools +- Special thanks to the React and TypeScript communities -The page will reload if you make edits.\ -You will also see any lint errors in the console. +--- -### `npm test` - -Launches the test runner in the interactive watch mode.\ -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` - -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### `npm run eject` - -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** - -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. - -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. - -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. - -## Learn More - -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). - -To learn React, check out the [React documentation](https://reactjs.org/). +Made with ❀️ by Shruti Kulkarni \ No newline at end of file From bddb898d93f9ee2dd4209dd16087640c69f53186 Mon Sep 17 00:00:00 2001 From: shrutu0929 <2023bcs006@sggs.ac.in> Date: Tue, 5 Aug 2025 19:19:11 +0530 Subject: [PATCH 2/2] Added OTP verification functionality with email verification --- README.md | 162 +++++++++++---------- src/App.tsx | 5 + src/components/OTPVerification.tsx | 121 +++++++++++++++ src/pages/SignUp.tsx | 138 +++++++++--------- src/pages/VerifyEmail.tsx | 84 +++++++++++ src/styles/OTPVerification.css | 19 +++ src/styles/VerifyEmail.css | 27 ++++ supabase/functions/send-otp-email/index.ts | 66 +++++++++ 8 files changed, 475 insertions(+), 147 deletions(-) create mode 100644 src/components/OTPVerification.tsx create mode 100644 src/pages/VerifyEmail.tsx create mode 100644 src/styles/OTPVerification.css create mode 100644 src/styles/VerifyEmail.css create mode 100644 supabase/functions/send-otp-email/index.ts diff --git a/README.md b/README.md index 1cb8db1..fcb235f 100644 --- a/README.md +++ b/README.md @@ -2,52 +2,41 @@ ## Overview -TripGo is a modern, user-friendly travel planning application built with React and TypeScript. It helps users discover and explore beautiful tourist destinations across India, offering detailed information about cities, attractions, and travel experiences. +TripGo is a modern, feature-rich travel planning application built with React and TypeScript. It helps users discover and explore beautiful tourist destinations across India with an intuitive and engaging user interface. -![TripGo Interface](public/logo192.png) +![TripGo Interface](public/images/README.md) -## Features 🌟 +## ✨ Features -### 1. City-wise Tourist Spots πŸ›οΈ +### πŸ›οΈ City-wise Tourist Spots - Comprehensive database of tourist destinations -- High-quality images of attractions -- Detailed information about each location -- Seasonal visit recommendations -- Local tips and insights +- High-quality images and detailed information +- Local tips and recommendations +- Seasonal visit guides +- Popular local experiences -### 2. User-Friendly Navigation 🎯 -- Intuitive interface design +### 🎯 Easy Navigation +- Intuitive user interface - Smart search functionality - Quick filters for destinations - Interactive maps -- Seamless user experience - -### 3. Personalized Experience πŸ’ -- User authentication system -- Favorite destination saving -- Custom travel planning -- Personal travel history -- Preference-based recommendations - -### 4. Mobile Responsive Design πŸ“± -- Fully responsive layout -- Cross-platform compatibility +- User-friendly design + +### πŸ‘€ Personalized Experience +- User authentication and profiles +- Favorite destination lists +- Custom travel plans +- Travel preference settings +- Personal travel diary + +### πŸ“± Mobile Friendly +- Responsive design for all devices +- Fast loading pages +- Offline content access +- Easy sharing features - Touch-friendly interface -- Optimized performance -- Offline accessibility -## Technical Stack πŸ’» - -- **Frontend Framework:** React -- **Language:** TypeScript -- **Styling:** CSS3 with modern features -- **Authentication:** Supabase -- **State Management:** React Context -- **Routing:** React Router -- **Icons:** React Icons -- **Animation:** Custom CSS animations - -## Getting Started πŸš€ +## πŸš€ Getting Started ### Prerequisites - Node.js (v14 or higher) @@ -71,87 +60,102 @@ cd TripGo npm install \`\`\` -4. Create a .env file in the root directory and add your Supabase credentials: -\`\`\`env -REACT_APP_SUPABASE_URL=your_supabase_url -REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_key -\`\`\` - -5. Start the development server: +4. Start the development server: \`\`\`bash npm start \`\`\` The application will open in your default browser at `http://localhost:3000`. -## Project Structure πŸ“ +## πŸ› οΈ Built With + +- **React** - Frontend framework +- **TypeScript** - Programming language +- **Supabase** - Backend and authentication +- **CSS Modules** - Styling +- **React Router** - Navigation +- **React Icons** - Icon library + +## πŸ“ Project Structure \`\`\` tripgo/ β”œβ”€β”€ public/ -β”‚ β”œβ”€β”€ images/ -β”‚ └── index.html +β”‚ └── images/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ components/ β”‚ β”œβ”€β”€ config/ β”‚ β”œβ”€β”€ data/ β”‚ β”œβ”€β”€ pages/ -β”‚ β”œβ”€β”€ styles/ -β”‚ └── App.tsx +β”‚ └── styles/ β”œβ”€β”€ package.json └── README.md \`\`\` -## Key Components πŸ”‘ +## 🎨 Key Components -- **AnimatedBackground:** Creates engaging background animations -- **CurtainAnimation:** Handles loading transitions -- **FeatureDetails:** Displays detailed feature information -- **SearchBar:** Enables destination search functionality -- **UnifiedStarBackground:** Provides consistent themed backgrounds +### Pages +- **Home** - Landing page with featured destinations +- **CityDetails** - Detailed information about each city +- **About** - Information about TripGo +- **Contact** - Contact form and information +- **Login/SignUp** - User authentication pages -## Styling and Themes 🎨 +### Features +- Animated backgrounds with star effects +- Professional curtain animations +- Interactive search functionality +- Responsive design +- User authentication +- City and tourist spot details +- Contact form with validation -The application uses a modern, clean design with: -- Responsive layouts -- Custom animations -- Consistent color schemes -- Professional typography -- Intuitive navigation elements +## πŸ” Authentication -## Authentication πŸ” - -User authentication is handled through Supabase, providing: -- Secure login/signup +TripGo uses Supabase for user authentication, providing: +- Secure user registration and login - Password recovery - Session management - Protected routes -- User profile management -## Contributing 🀝 +## 🎯 Future Enhancements + +- [ ] Add booking functionality +- [ ] Implement user reviews and ratings +- [ ] Add multi-language support +- [ ] Integrate weather information +- [ ] Add travel itinerary planner +- [ ] Implement social sharing features + +## 🀝 Contributing -We welcome contributions! Please follow these steps: +Contributions are welcome! Please feel free to submit a Pull Request. -1. Fork the repository -2. Create a feature branch -3. Commit your changes -4. Push to the branch +1. Fork the project +2. Create your feature branch (\`git checkout -b feature/AmazingFeature\`) +3. Commit your changes (\`git commit -m 'Add some AmazingFeature'\`) +4. Push to the branch (\`git push origin feature/AmazingFeature\`) 5. Open a Pull Request -## License πŸ“„ +## πŸ“„ License This project is licensed under the MIT License - see the LICENSE file for details. -## Contact πŸ“§ +## πŸ‘₯ Authors -- Developer: Shruti Kulkarni -- GitHub: [@shrutu0929](https://github.com/shrutu0929) +- **Shruti Kulkarni** - *Initial work* - [shrutu0929](https://github.com/shrutu0929) -## Acknowledgments πŸ™ +## πŸ™ Acknowledgments -- Thanks to all contributors -- Inspired by the need for better travel planning tools +- Thanks to all contributors who have helped shape TripGo - Special thanks to the React and TypeScript communities +- Image credits to respective photographers + +## πŸ“ž Contact + +For any queries or suggestions, please reach out through: +- GitHub Issues +- Project Email: [your-email@example.com] --- diff --git a/src/App.tsx b/src/App.tsx index eaad4c7..8197876 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -7,6 +7,7 @@ import About from './pages/About'; import Contact from './pages/Contact'; import Login from './pages/Login'; import SignUp from './pages/SignUp'; +import VerifyEmail from './pages/VerifyEmail'; import FeatureDetails from './components/FeatureDetails'; import CurtainAnimation from './components/CurtainAnimation'; import { supabase } from './config/supabaseClient'; @@ -143,6 +144,10 @@ function App() { ) } /> + } + /> = ({ email }) => { + const [otp, setOtp] = useState(''); + const [error, setError] = useState(''); + const [isLoading, setIsLoading] = useState(false); + const navigate = useNavigate(); + + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + + if (!otp) { + setError('Please enter the OTP'); + return; + } + + try { + setIsLoading(true); + setError(''); + + console.log('Verifying OTP for email:', email); + + console.log('Verifying OTP for email:', email); + + // Verify OTP + const { data, error: verifyError } = await supabase.auth.verifyOtp({ + email, + token: otp, + type: 'magiclink' + }); + + console.log('Verification response:', data); + + if (verifyError) { + console.error('Verification error:', verifyError); + throw verifyError; + } + + // If verification successful, redirect to login + navigate('/login'); + } catch (error) { + setError(error instanceof Error ? error.message : 'Failed to verify OTP'); + } finally { + setIsLoading(false); + } + }; + + const handleResendOTP = async () => { + try { + setIsLoading(true); + setError(''); + + console.log('Requesting new OTP for email:', email); + + // Resend OTP + const { error: resendError } = await supabase.auth.signInWithOtp({ + phone: email, // Using email instead of phone + options: { + channel: 'sms', + shouldCreateUser: false + } + }); + + if (resendError) { + console.error('Error resending OTP:', resendError); + throw resendError; + } + + console.log('New OTP email sent successfully'); + + alert('New OTP has been sent to your email'); + } catch (error) { + setError(error instanceof Error ? error.message : 'Failed to resend OTP'); + } finally { + setIsLoading(false); + } + }; + + return ( + <> + {isLoading && } +
+

+ Trip + Go +

+

Verify Your Email

+ {error &&
{error}
} +
+
+ + setOtp(e.target.value)} + placeholder="Enter OTP from your email" + required + /> +
+ +
+

+ Didn't receive OTP? +

+
+ + ); +}; + +export default OTPVerification; \ No newline at end of file diff --git a/src/pages/SignUp.tsx b/src/pages/SignUp.tsx index dd70d0d..9b91f03 100644 --- a/src/pages/SignUp.tsx +++ b/src/pages/SignUp.tsx @@ -3,6 +3,7 @@ import { useNavigate } from 'react-router-dom'; import { FaPlane, FaHotel, FaUmbrella, FaPassport, FaGlobeAmericas } from 'react-icons/fa'; import Loader from '../components/Loader'; import UnifiedStarBackground from '../components/UnifiedStarBackground'; +import OTPVerification from '../components/OTPVerification'; import { supabase } from '../config/supabaseClient'; import '../styles/Login.css'; @@ -12,6 +13,7 @@ const SignUp: React.FC = () => { const [confirmPassword, setConfirmPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); + const [showOTPVerification, setShowOTPVerification] = useState(false); const navigate = useNavigate(); const handleSubmit = async (e: React.FormEvent) => { @@ -32,32 +34,28 @@ const SignUp: React.FC = () => { setError(''); console.log('Starting signup process...'); - const { data, error: signUpError } = await supabase.auth.signUp({ - email, - password, + + // Send email OTP + const { data: otpData, error: otpError } = await supabase.auth.signInWithOtp({ + email: email, options: { - data: { - email: email - } + emailRedirectTo: `${window.location.origin}/verify` } }); - if (signUpError) { - console.error('Signup error:', signUpError); - throw signUpError; + if (otpError) { + console.error('Error sending OTP:', otpError); + throw otpError; } - console.log('Auth signup response:', data); + console.log('OTP sent successfully'); - if (data?.user) { - // Show success message and direct to login - setError(''); - console.log('Signup successful! Please check your email for verification.'); - navigate('/login'); - } else { - console.error('No user data received after signup'); - throw new Error('Failed to create user account'); - } + console.log('OTP sent successfully to:', email); + + // Show success message and OTP verification screen + setError(''); + setShowOTPVerification(true); + console.log('Please check your email for the verification code.'); } catch (error) { setError(error instanceof Error ? error.message : 'An error occurred during sign up'); } finally { @@ -77,55 +75,59 @@ const SignUp: React.FC = () => { -
-

- Trip - Go -

-

Create Your Account

- {error &&
{error}
} -
-
- - setEmail(e.target.value)} - placeholder="Enter your email" - required - /> -
-
- - setPassword(e.target.value)} - placeholder="Enter your password" - required - /> -
-
- - setConfirmPassword(e.target.value)} - placeholder="Confirm your password" - required - /> -
- -
-

- Already have an account? Login -

-
+ {showOTPVerification ? ( + + ) : ( +
+

+ Trip + Go +

+

Create Your Account

+ {error &&
{error}
} +
+
+ + setEmail(e.target.value)} + placeholder="Enter your email" + required + /> +
+
+ + setPassword(e.target.value)} + placeholder="Enter your password" + required + /> +
+
+ + setConfirmPassword(e.target.value)} + placeholder="Confirm your password" + required + /> +
+ +
+

+ Already have an account? Login +

+
+ )} ); diff --git a/src/pages/VerifyEmail.tsx b/src/pages/VerifyEmail.tsx new file mode 100644 index 0000000..90ad61e --- /dev/null +++ b/src/pages/VerifyEmail.tsx @@ -0,0 +1,84 @@ +import React, { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { supabase } from '../config/supabaseClient'; +import Loader from '../components/Loader'; +import UnifiedStarBackground from '../components/UnifiedStarBackground'; +import '../styles/Login.css'; + +const VerifyEmail: React.FC = () => { + const [verificationStatus, setVerificationStatus] = useState<'pending' | 'success' | 'error'>('pending'); + const [message, setMessage] = useState('Verifying your email...'); + const [isLoading, setIsLoading] = useState(true); + const navigate = useNavigate(); + + useEffect(() => { + const handleVerification = async () => { + try { + // Get the current session + const { data: { session }, error: sessionError } = await supabase.auth.getSession(); + + if (sessionError) { + throw sessionError; + } + + if (!session?.user) { + setVerificationStatus('error'); + setMessage('No active session found. Please try signing up again.'); + return; + } + + // Update the user's profile to mark as verified + const { error: updateError } = await supabase + .from('profiles') + .update({ is_verified: true }) + .eq('id', session.user.id); + + if (updateError) { + throw updateError; + } + + setVerificationStatus('success'); + setMessage('Email verified successfully! Redirecting to login...'); + + // Redirect to login after 3 seconds + setTimeout(() => { + navigate('/login'); + }, 3000); + } catch (error) { + console.error('Verification error:', error); + setVerificationStatus('error'); + setMessage(error instanceof Error ? error.message : 'An error occurred during verification'); + } finally { + setIsLoading(false); + } + }; + + handleVerification(); + }, [navigate]); + + return ( +
+ + {isLoading && } +
+

+ Trip + Go +

+
+

{message}

+ {verificationStatus === 'error' && ( + + )} +
+
+
+ ); +}; + +export default VerifyEmail; \ No newline at end of file diff --git a/src/styles/OTPVerification.css b/src/styles/OTPVerification.css new file mode 100644 index 0000000..b14578a --- /dev/null +++ b/src/styles/OTPVerification.css @@ -0,0 +1,19 @@ +.resend-button { + background: none; + border: none; + color: #007bff; + text-decoration: underline; + cursor: pointer; + padding: 0; + font: inherit; +} + +.resend-button:hover { + color: #0056b3; +} + +.otp-input { + letter-spacing: 0.5em; + text-align: center; + font-size: 1.2em; +} \ No newline at end of file diff --git a/src/styles/VerifyEmail.css b/src/styles/VerifyEmail.css new file mode 100644 index 0000000..d629ebb --- /dev/null +++ b/src/styles/VerifyEmail.css @@ -0,0 +1,27 @@ +.verification-status { + text-align: center; + padding: 20px; + margin: 20px 0; + border-radius: 8px; +} + +.verification-status.pending { + background-color: rgba(255, 193, 7, 0.1); + border: 1px solid #ffc107; +} + +.verification-status.success { + background-color: rgba(40, 167, 69, 0.1); + border: 1px solid #28a745; +} + +.verification-status.error { + background-color: rgba(220, 53, 69, 0.1); + border: 1px solid #dc3545; +} + +.verification-status p { + margin: 0; + padding: 10px 0; + color: #fff; +} \ No newline at end of file diff --git a/supabase/functions/send-otp-email/index.ts b/supabase/functions/send-otp-email/index.ts new file mode 100644 index 0000000..cedee97 --- /dev/null +++ b/supabase/functions/send-otp-email/index.ts @@ -0,0 +1,66 @@ +import { serve } from 'https://deno.land/std@0.168.0/http/server.ts' +import { SmtpClient } from 'https://deno.land/x/smtp@v0.7.0/mod.ts' + +const corsHeaders = { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', +} + +serve(async (req) => { + if (req.method === 'OPTIONS') { + return new Response('ok', { headers: corsHeaders }) + } + + try { + const { email, otp } = await req.json() + + if (!email || !otp) { + throw new Error('Email and OTP are required') + } + + // Configure SMTP client (you'll need to set these up in your Supabase dashboard) + const client = new SmtpClient() + await client.connectTLS({ + hostname: Deno.env.get('SMTP_HOSTNAME') || '', + port: parseInt(Deno.env.get('SMTP_PORT') || '587'), + username: Deno.env.get('SMTP_USERNAME') || '', + password: Deno.env.get('SMTP_PASSWORD') || '', + }) + + // Send email + await client.send({ + from: Deno.env.get('SMTP_FROM') || '', + to: email, + subject: 'Your TripGo Verification Code', + html: ` +
+

Welcome to TripGo!

+

Your verification code is:

+
+ ${otp} +
+

This code will expire in 10 minutes.

+

If you didn't request this code, please ignore this email.

+
+ `, + }) + + await client.close() + + return new Response( + JSON.stringify({ message: 'OTP sent successfully' }), + { + headers: { ...corsHeaders, 'Content-Type': 'application/json' }, + status: 200, + }, + ) + } catch (error) { + return new Response( + JSON.stringify({ error: error.message }), + { + headers: { ...corsHeaders, 'Content-Type': 'application/json' }, + status: 400, + }, + ) + } +}) \ No newline at end of file