feat: added web scrapping and improved ui, part-I#4
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds web scraping functionality and improves the UI as part of the first phase of enhancements. It introduces destination data fetching from external APIs, enhances the trip planning interface with currency support, and adds AI chat functionality for trip assistance.
Key changes include:
- Added currency field to trip schema with USD as default
- Integrated web scraping packages (axios, crawl4ai, ioredis) and UI components
- Enhanced trip planning page with destination insights and AI chat
- Improved create trip form with currency selection and custom interests
Reviewed Changes
Copilot reviewed 10 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| prisma/schema.prisma | Added currency field to Trip model with USD default |
| package.json | Added web scraping, Redis, and UI component dependencies |
| app/trips/[tripId]/plan/page.tsx | New page displaying destination attractions and AI chat interface |
| app/trips/[tripId]/page.tsx | Enhanced trip display with currency formatting and improved activity UI |
| app/create-trip/page.tsx | Added currency selection and custom interests functionality |
| app/components/ui/select.tsx | New select component for dropdowns |
| app/components/ui/scroll-area.tsx | New scroll area component for better UX |
| app/api/trips/create/route.ts | Added currency field support in trip creation |
| app/api/trips/[tripId]/generate-itinerary/route.ts | Enhanced with currency-aware budget generation |
| app/api/chat/route.ts | New AI chat endpoint for destination queries |
Comments suppressed due to low confidence (1)
package.json:25
- The package 'crawl4ai' version '^1.0.1' may not exist. This appears to be a specialized web scraping library that should be verified for availability.
"crawl4ai": "^1.0.1",
| const response = await fetch( | ||
| `http://127.0.0.1:8000/tripadvisor/things-to-do?city=${encodeURIComponent(destination)}`, |
There was a problem hiding this comment.
Hard-coded localhost URL creates a security risk and will fail in production. Use environment variables or relative URLs for API endpoints.
| const response = await fetch( | |
| `http://127.0.0.1:8000/tripadvisor/things-to-do?city=${encodeURIComponent(destination)}`, | |
| const apiBaseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || ""; | |
| const response = await fetch( | |
| `${apiBaseUrl}/tripadvisor/things-to-do?city=${encodeURIComponent(destination)}`, |
| src={attraction.imageLink || "/placeholder.svg"} | ||
| alt={attraction.title} | ||
| fill | ||
| className="object-cover group-hover:scale-105 transition-transform duration-300" | ||
| onError={(e) => { | ||
| const target = e.target as HTMLImageElement | ||
| target.srcset = `/placeholder.svg?height=128&width=300&text=No+Image+Available` | ||
| target.src = `/placeholder.svg?height=128&width=300&text=No+Image+Available` |
There was a problem hiding this comment.
Setting srcset property directly may not work as expected. Consider using src property only or implementing proper responsive image handling.
| src={attraction.imageLink || "/placeholder.svg"} | |
| alt={attraction.title} | |
| fill | |
| className="object-cover group-hover:scale-105 transition-transform duration-300" | |
| onError={(e) => { | |
| const target = e.target as HTMLImageElement | |
| target.srcset = `/placeholder.svg?height=128&width=300&text=No+Image+Available` | |
| target.src = `/placeholder.svg?height=128&width=300&text=No+Image+Available` | |
| src={imgSrc} | |
| alt={attraction.title} | |
| fill | |
| className="object-cover group-hover:scale-105 transition-transform duration-300" | |
| onError={() => { | |
| setImgSrc("/placeholder.svg?height=128&width=300&text=No+Image+Available") |
| const model = genAI.getGenerativeModel({ model: "gemini-2.0-flash" }) | ||
|
|
||
| // Currency data for proper formatting and conversion context | ||
| const currencies = { |
There was a problem hiding this comment.
Large currency mapping object should be extracted to a separate constants file to improve maintainability and enable reuse across components.
| const currencies = [ | ||
| { code: "USD", symbol: "$", name: "US Dollar" }, | ||
| { code: "EUR", symbol: "€", name: "Euro" }, | ||
| { code: "GBP", symbol: "£", name: "British Pound" }, | ||
| { code: "JPY", symbol: "¥", name: "Japanese Yen" }, | ||
| { code: "CAD", symbol: "C$", name: "Canadian Dollar" }, | ||
| { code: "AUD", symbol: "A$", name: "Australian Dollar" }, | ||
| { code: "CHF", symbol: "CHF", name: "Swiss Franc" }, | ||
| { code: "CNY", symbol: "¥", name: "Chinese Yuan" }, | ||
| { code: "INR", symbol: "₹", name: "Indian Rupee" }, | ||
| { code: "KRW", symbol: "₩", name: "South Korean Won" }, | ||
| { code: "SGD", symbol: "S$", name: "Singapore Dollar" }, | ||
| { code: "HKD", symbol: "HK$", name: "Hong Kong Dollar" }, | ||
| { code: "NOK", symbol: "kr", name: "Norwegian Krone" }, | ||
| { code: "SEK", symbol: "kr", name: "Swedish Krona" }, | ||
| { code: "DKK", symbol: "kr", name: "Danish Krone" }, | ||
| { code: "PLN", symbol: "zł", name: "Polish Zloty" }, | ||
| { code: "CZK", symbol: "Kč", name: "Czech Koruna" }, | ||
| { code: "HUF", symbol: "Ft", name: "Hungarian Forint" }, | ||
| { code: "RUB", symbol: "₽", name: "Russian Ruble" }, | ||
| { code: "BRL", symbol: "R$", name: "Brazilian Real" }, | ||
| { code: "MXN", symbol: "$", name: "Mexican Peso" }, | ||
| { code: "ZAR", symbol: "R", name: "South African Rand" }, | ||
| { code: "TRY", symbol: "₺", name: "Turkish Lira" }, | ||
| { code: "AED", symbol: "د.إ", name: "UAE Dirham" }, | ||
| { code: "SAR", symbol: "﷼", name: "Saudi Riyal" }, | ||
| ] |
There was a problem hiding this comment.
Currency definitions are duplicated between this file and the API route. Extract to a shared constants file to maintain DRY principle.
| const currencies = [ | |
| { code: "USD", symbol: "$", name: "US Dollar" }, | |
| { code: "EUR", symbol: "€", name: "Euro" }, | |
| { code: "GBP", symbol: "£", name: "British Pound" }, | |
| { code: "JPY", symbol: "¥", name: "Japanese Yen" }, | |
| { code: "CAD", symbol: "C$", name: "Canadian Dollar" }, | |
| { code: "AUD", symbol: "A$", name: "Australian Dollar" }, | |
| { code: "CHF", symbol: "CHF", name: "Swiss Franc" }, | |
| { code: "CNY", symbol: "¥", name: "Chinese Yuan" }, | |
| { code: "INR", symbol: "₹", name: "Indian Rupee" }, | |
| { code: "KRW", symbol: "₩", name: "South Korean Won" }, | |
| { code: "SGD", symbol: "S$", name: "Singapore Dollar" }, | |
| { code: "HKD", symbol: "HK$", name: "Hong Kong Dollar" }, | |
| { code: "NOK", symbol: "kr", name: "Norwegian Krone" }, | |
| { code: "SEK", symbol: "kr", name: "Swedish Krona" }, | |
| { code: "DKK", symbol: "kr", name: "Danish Krone" }, | |
| { code: "PLN", symbol: "zł", name: "Polish Zloty" }, | |
| { code: "CZK", symbol: "Kč", name: "Czech Koruna" }, | |
| { code: "HUF", symbol: "Ft", name: "Hungarian Forint" }, | |
| { code: "RUB", symbol: "₽", name: "Russian Ruble" }, | |
| { code: "BRL", symbol: "R$", name: "Brazilian Real" }, | |
| { code: "MXN", symbol: "$", name: "Mexican Peso" }, | |
| { code: "ZAR", symbol: "R", name: "South African Rand" }, | |
| { code: "TRY", symbol: "₺", name: "Turkish Lira" }, | |
| { code: "AED", symbol: "د.إ", name: "UAE Dirham" }, | |
| { code: "SAR", symbol: "﷼", name: "Saudi Riyal" }, | |
| ] | |
| import { currencies } from "@/constants/currencies" |
| import { ScrollArea } from "@/app/components/ui/scroll-area" | ||
|
|
||
| // Currency symbols mapping | ||
| // const currencySymbols: Record<string, string> = { |
There was a problem hiding this comment.
Large block of commented code should be removed to improve code cleanliness. If currency functionality is needed, implement it properly or remove entirely.
No description provided.