diff --git a/README.md b/README.md index b87cb00..fcb235f 100644 --- a/README.md +++ b/README.md @@ -1,46 +1,162 @@ -# Getting Started with Create React App +# TripGo - Your Ultimate Travel Planning Application 🌍✈️ + +## Overview + +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/images/README.md) + +## ✨ Features + +### πŸ›οΈ City-wise Tourist Spots +- Comprehensive database of tourist destinations +- High-quality images and detailed information +- Local tips and recommendations +- Seasonal visit guides +- Popular local experiences + +### 🎯 Easy Navigation +- Intuitive user interface +- Smart search functionality +- Quick filters for destinations +- Interactive maps +- 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 + +## πŸš€ 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 +\`\`\` -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). +4. Start the development server: +\`\`\`bash +npm start +\`\`\` -## Available Scripts +The application will open in your default browser at `http://localhost:3000`. -In the project directory, you can run: +## πŸ› οΈ Built With -### `npm start` +- **React** - Frontend framework +- **TypeScript** - Programming language +- **Supabase** - Backend and authentication +- **CSS Modules** - Styling +- **React Router** - Navigation +- **React Icons** - Icon library -Runs the app in the development mode.\ -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. +## πŸ“ Project Structure -The page will reload if you make edits.\ -You will also see any lint errors in the console. +\`\`\` +tripgo/ +β”œβ”€β”€ public/ +β”‚ └── images/ +β”œβ”€β”€ src/ +β”‚ β”œβ”€β”€ components/ +β”‚ β”œβ”€β”€ config/ +β”‚ β”œβ”€β”€ data/ +β”‚ β”œβ”€β”€ pages/ +β”‚ └── styles/ +β”œβ”€β”€ package.json +└── README.md +\`\`\` -### `npm test` +## 🎨 Key Components -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. +### 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 + +### 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 + +## πŸ” Authentication + +TripGo uses Supabase for user authentication, providing: +- Secure user registration and login +- Password recovery +- Session management +- Protected routes + +## 🎯 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 -### `npm run build` +## 🀝 Contributing -Builds the app for production to the `build` folder.\ -It correctly bundles React in production mode and optimizes the build for the best performance. +Contributions are welcome! Please feel free to submit a Pull Request. -The build is minified and the filenames include the hashes.\ -Your app is ready to be deployed! +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 -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. +## πŸ“„ License -### `npm run eject` +This project is licensed under the MIT License - see the LICENSE file for details. -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** +## πŸ‘₯ Authors -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. +- **Shruti Kulkarni** - *Initial work* - [shrutu0929](https://github.com/shrutu0929) -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. +## πŸ™ Acknowledgments -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. +- Thanks to all contributors who have helped shape TripGo +- Special thanks to the React and TypeScript communities +- Image credits to respective photographers -## Learn More +## πŸ“ž Contact -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). +For any queries or suggestions, please reach out through: +- GitHub Issues +- Project Email: [your-email@example.com] -To learn React, check out the [React documentation](https://reactjs.org/). +--- + +Made with ❀️ by Shruti Kulkarni \ No newline at end of file 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