Initial commit: Tasteby - YouTube restaurant map service
Backend (FastAPI + Oracle ADB), Frontend (Next.js), daemon worker. Features: channel/video/restaurant management, semantic search, Google OAuth, user reviews. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
75
frontend/src/components/MapView.tsx
Normal file
75
frontend/src/components/MapView.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useState } from "react";
|
||||
import {
|
||||
APIProvider,
|
||||
Map,
|
||||
AdvancedMarker,
|
||||
InfoWindow,
|
||||
} from "@vis.gl/react-google-maps";
|
||||
import type { Restaurant } from "@/lib/api";
|
||||
|
||||
const SEOUL_CENTER = { lat: 37.5665, lng: 126.978 };
|
||||
const API_KEY = process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY || "";
|
||||
|
||||
interface MapViewProps {
|
||||
restaurants: Restaurant[];
|
||||
onSelectRestaurant?: (r: Restaurant) => void;
|
||||
}
|
||||
|
||||
export default function MapView({ restaurants, onSelectRestaurant }: MapViewProps) {
|
||||
const [selected, setSelected] = useState<Restaurant | null>(null);
|
||||
|
||||
const handleMarkerClick = useCallback(
|
||||
(r: Restaurant) => {
|
||||
setSelected(r);
|
||||
onSelectRestaurant?.(r);
|
||||
},
|
||||
[onSelectRestaurant]
|
||||
);
|
||||
|
||||
return (
|
||||
<APIProvider apiKey={API_KEY}>
|
||||
<Map
|
||||
defaultCenter={SEOUL_CENTER}
|
||||
defaultZoom={12}
|
||||
mapId="tasteby-map"
|
||||
className="h-full w-full"
|
||||
>
|
||||
{restaurants.map((r) => (
|
||||
<AdvancedMarker
|
||||
key={r.id}
|
||||
position={{ lat: r.latitude, lng: r.longitude }}
|
||||
onClick={() => handleMarkerClick(r)}
|
||||
/>
|
||||
))}
|
||||
|
||||
{selected && (
|
||||
<InfoWindow
|
||||
position={{ lat: selected.latitude, lng: selected.longitude }}
|
||||
onCloseClick={() => setSelected(null)}
|
||||
>
|
||||
<div className="max-w-xs p-1">
|
||||
<h3 className="font-bold text-base">{selected.name}</h3>
|
||||
{selected.cuisine_type && (
|
||||
<p className="text-sm text-gray-600">{selected.cuisine_type}</p>
|
||||
)}
|
||||
{selected.address && (
|
||||
<p className="text-xs text-gray-500 mt-1">{selected.address}</p>
|
||||
)}
|
||||
{selected.price_range && (
|
||||
<p className="text-xs text-gray-500">{selected.price_range}</p>
|
||||
)}
|
||||
<button
|
||||
onClick={() => onSelectRestaurant?.(selected)}
|
||||
className="mt-2 text-sm text-blue-600 hover:underline"
|
||||
>
|
||||
상세 보기
|
||||
</button>
|
||||
</div>
|
||||
</InfoWindow>
|
||||
)}
|
||||
</Map>
|
||||
</APIProvider>
|
||||
);
|
||||
}
|
||||
113
frontend/src/components/RestaurantDetail.tsx
Normal file
113
frontend/src/components/RestaurantDetail.tsx
Normal file
@@ -0,0 +1,113 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Restaurant, VideoLink } from "@/lib/api";
|
||||
import ReviewSection from "@/components/ReviewSection";
|
||||
|
||||
interface RestaurantDetailProps {
|
||||
restaurant: Restaurant;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
export default function RestaurantDetail({
|
||||
restaurant,
|
||||
onClose,
|
||||
}: RestaurantDetailProps) {
|
||||
const [videos, setVideos] = useState<VideoLink[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
api
|
||||
.getRestaurantVideos(restaurant.id)
|
||||
.then(setVideos)
|
||||
.catch(() => setVideos([]))
|
||||
.finally(() => setLoading(false));
|
||||
}, [restaurant.id]);
|
||||
|
||||
return (
|
||||
<div className="p-4 space-y-4">
|
||||
<div className="flex justify-between items-start">
|
||||
<h2 className="text-lg font-bold">{restaurant.name}</h2>
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="text-gray-400 hover:text-gray-600 text-xl leading-none"
|
||||
>
|
||||
x
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-1 text-sm">
|
||||
{restaurant.cuisine_type && (
|
||||
<p>
|
||||
<span className="text-gray-500">종류:</span> {restaurant.cuisine_type}
|
||||
</p>
|
||||
)}
|
||||
{restaurant.address && (
|
||||
<p>
|
||||
<span className="text-gray-500">주소:</span> {restaurant.address}
|
||||
</p>
|
||||
)}
|
||||
{restaurant.region && (
|
||||
<p>
|
||||
<span className="text-gray-500">지역:</span> {restaurant.region}
|
||||
</p>
|
||||
)}
|
||||
{restaurant.price_range && (
|
||||
<p>
|
||||
<span className="text-gray-500">가격대:</span> {restaurant.price_range}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-semibold text-sm mb-2">관련 영상</h3>
|
||||
{loading ? (
|
||||
<p className="text-sm text-gray-500">로딩 중...</p>
|
||||
) : videos.length === 0 ? (
|
||||
<p className="text-sm text-gray-500">관련 영상이 없습니다</p>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{videos.map((v) => (
|
||||
<div key={v.video_id} className="border rounded-lg p-3">
|
||||
<a
|
||||
href={v.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-sm font-medium text-blue-600 hover:underline"
|
||||
>
|
||||
{v.title}
|
||||
</a>
|
||||
{v.foods_mentioned.length > 0 && (
|
||||
<div className="flex flex-wrap gap-1 mt-2">
|
||||
{v.foods_mentioned.map((f, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className="px-2 py-0.5 bg-orange-50 text-orange-700 rounded text-xs"
|
||||
>
|
||||
{f}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{v.evaluation?.text && (
|
||||
<p className="mt-1 text-xs text-gray-600">
|
||||
{v.evaluation.text}
|
||||
</p>
|
||||
)}
|
||||
{v.guests.length > 0 && (
|
||||
<p className="mt-1 text-xs text-gray-500">
|
||||
게스트: {v.guests.join(", ")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<ReviewSection restaurantId={restaurant.id} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
44
frontend/src/components/RestaurantList.tsx
Normal file
44
frontend/src/components/RestaurantList.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
"use client";
|
||||
|
||||
import type { Restaurant } from "@/lib/api";
|
||||
|
||||
interface RestaurantListProps {
|
||||
restaurants: Restaurant[];
|
||||
selectedId?: string;
|
||||
onSelect: (r: Restaurant) => void;
|
||||
}
|
||||
|
||||
export default function RestaurantList({
|
||||
restaurants,
|
||||
selectedId,
|
||||
onSelect,
|
||||
}: RestaurantListProps) {
|
||||
if (!restaurants.length) {
|
||||
return (
|
||||
<div className="p-4 text-center text-gray-500 text-sm">
|
||||
표시할 식당이 없습니다
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="divide-y divide-gray-100">
|
||||
{restaurants.map((r) => (
|
||||
<button
|
||||
key={r.id}
|
||||
onClick={() => onSelect(r)}
|
||||
className={`w-full text-left px-4 py-3 hover:bg-gray-50 transition-colors ${
|
||||
selectedId === r.id ? "bg-blue-50 border-l-2 border-blue-500" : ""
|
||||
}`}
|
||||
>
|
||||
<h4 className="font-medium text-sm">{r.name}</h4>
|
||||
<div className="flex gap-2 mt-1 text-xs text-gray-500">
|
||||
{r.cuisine_type && <span>{r.cuisine_type}</span>}
|
||||
{r.region && <span>{r.region}</span>}
|
||||
{r.price_range && <span>{r.price_range}</span>}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
304
frontend/src/components/ReviewSection.tsx
Normal file
304
frontend/src/components/ReviewSection.tsx
Normal file
@@ -0,0 +1,304 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Review } from "@/lib/api";
|
||||
import { useAuth } from "@/lib/auth-context";
|
||||
|
||||
interface ReviewSectionProps {
|
||||
restaurantId: string;
|
||||
}
|
||||
|
||||
function StarDisplay({ rating }: { rating: number }) {
|
||||
const stars = [];
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
if (rating >= i) {
|
||||
stars.push(
|
||||
<span key={i} className="text-yellow-500">
|
||||
★
|
||||
</span>
|
||||
);
|
||||
} else if (rating >= i - 0.5) {
|
||||
stars.push(
|
||||
<span key={i} className="text-yellow-500">
|
||||
★
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
stars.push(
|
||||
<span key={i} className="text-gray-300">
|
||||
★
|
||||
</span>
|
||||
);
|
||||
}
|
||||
}
|
||||
return <span className="text-sm">{stars}</span>;
|
||||
}
|
||||
|
||||
function StarSelector({
|
||||
value,
|
||||
onChange,
|
||||
}: {
|
||||
value: number;
|
||||
onChange: (v: number) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-xs text-gray-500 mr-1">별점:</span>
|
||||
{[0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5].map((v) => (
|
||||
<button
|
||||
key={v}
|
||||
type="button"
|
||||
onClick={() => onChange(v)}
|
||||
className={`w-6 h-6 text-xs rounded border ${
|
||||
value === v
|
||||
? "bg-yellow-500 text-white border-yellow-600"
|
||||
: "bg-white text-gray-600 border-gray-300 hover:border-yellow-400"
|
||||
}`}
|
||||
>
|
||||
{v}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ReviewForm({
|
||||
initialRating = 3,
|
||||
initialText = "",
|
||||
initialDate = "",
|
||||
onSubmit,
|
||||
onCancel,
|
||||
submitLabel,
|
||||
}: {
|
||||
initialRating?: number;
|
||||
initialText?: string;
|
||||
initialDate?: string;
|
||||
onSubmit: (data: {
|
||||
rating: number;
|
||||
review_text?: string;
|
||||
visited_at?: string;
|
||||
}) => Promise<void>;
|
||||
onCancel: () => void;
|
||||
submitLabel: string;
|
||||
}) {
|
||||
const [rating, setRating] = useState(initialRating);
|
||||
const [text, setText] = useState(initialText);
|
||||
const [visitedAt, setVisitedAt] = useState(initialDate);
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setSubmitting(true);
|
||||
try {
|
||||
await onSubmit({
|
||||
rating,
|
||||
review_text: text || undefined,
|
||||
visited_at: visitedAt || undefined,
|
||||
});
|
||||
} finally {
|
||||
setSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="space-y-3 border rounded-lg p-3">
|
||||
<StarSelector value={rating} onChange={setRating} />
|
||||
<textarea
|
||||
value={text}
|
||||
onChange={(e) => setText(e.target.value)}
|
||||
placeholder="리뷰를 작성해주세요 (선택)"
|
||||
className="w-full border rounded p-2 text-sm resize-none"
|
||||
rows={3}
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<label className="text-xs text-gray-500">방문일:</label>
|
||||
<input
|
||||
type="date"
|
||||
value={visitedAt}
|
||||
onChange={(e) => setVisitedAt(e.target.value)}
|
||||
className="border rounded px-2 py-1 text-xs"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={submitting}
|
||||
className="px-3 py-1 bg-blue-600 text-white text-sm rounded hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
{submitting ? "저장 중..." : submitLabel}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onCancel}
|
||||
className="px-3 py-1 bg-gray-200 text-gray-700 text-sm rounded hover:bg-gray-300"
|
||||
>
|
||||
취소
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default function ReviewSection({ restaurantId }: ReviewSectionProps) {
|
||||
const { user } = useAuth();
|
||||
const [reviews, setReviews] = useState<Review[]>([]);
|
||||
const [avgRating, setAvgRating] = useState<number | null>(null);
|
||||
const [reviewCount, setReviewCount] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [showForm, setShowForm] = useState(false);
|
||||
const [editingId, setEditingId] = useState<string | null>(null);
|
||||
|
||||
const loadReviews = useCallback(() => {
|
||||
setLoading(true);
|
||||
api
|
||||
.getReviews(restaurantId)
|
||||
.then((data) => {
|
||||
setReviews(data.reviews);
|
||||
setAvgRating(data.avg_rating);
|
||||
setReviewCount(data.review_count);
|
||||
})
|
||||
.catch(() => setReviews([]))
|
||||
.finally(() => setLoading(false));
|
||||
}, [restaurantId]);
|
||||
|
||||
useEffect(() => {
|
||||
loadReviews();
|
||||
}, [loadReviews]);
|
||||
|
||||
const myReview = user
|
||||
? reviews.find((r) => r.user_id === user.id)
|
||||
: null;
|
||||
|
||||
const handleCreate = async (data: {
|
||||
rating: number;
|
||||
review_text?: string;
|
||||
visited_at?: string;
|
||||
}) => {
|
||||
await api.createReview(restaurantId, data);
|
||||
setShowForm(false);
|
||||
loadReviews();
|
||||
};
|
||||
|
||||
const handleUpdate = async (
|
||||
reviewId: string,
|
||||
data: { rating: number; review_text?: string; visited_at?: string }
|
||||
) => {
|
||||
await api.updateReview(reviewId, data);
|
||||
setEditingId(null);
|
||||
loadReviews();
|
||||
};
|
||||
|
||||
const handleDelete = async (reviewId: string) => {
|
||||
if (!confirm("리뷰를 삭제하시겠습니까?")) return;
|
||||
await api.deleteReview(reviewId);
|
||||
loadReviews();
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3 className="font-semibold text-sm mb-2">리뷰</h3>
|
||||
|
||||
{loading ? (
|
||||
<p className="text-sm text-gray-500">로딩 중...</p>
|
||||
) : (
|
||||
<>
|
||||
{reviewCount > 0 && avgRating !== null && (
|
||||
<div className="flex items-center gap-2 mb-3 text-sm">
|
||||
<StarDisplay rating={Math.round(avgRating * 2) / 2} />
|
||||
<span className="font-medium">{avgRating.toFixed(1)}</span>
|
||||
<span className="text-gray-500">({reviewCount}개)</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{user && !myReview && !showForm && (
|
||||
<button
|
||||
onClick={() => setShowForm(true)}
|
||||
className="mb-3 px-3 py-1 bg-blue-600 text-white text-sm rounded hover:bg-blue-700"
|
||||
>
|
||||
리뷰 작성
|
||||
</button>
|
||||
)}
|
||||
|
||||
{showForm && (
|
||||
<div className="mb-3">
|
||||
<ReviewForm
|
||||
onSubmit={handleCreate}
|
||||
onCancel={() => setShowForm(false)}
|
||||
submitLabel="작성"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{reviews.length === 0 ? (
|
||||
<p className="text-sm text-gray-500">아직 리뷰가 없습니다</p>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{reviews.map((review) => (
|
||||
<div key={review.id} className="border rounded-lg p-3">
|
||||
{editingId === review.id ? (
|
||||
<ReviewForm
|
||||
initialRating={review.rating}
|
||||
initialText={review.review_text || ""}
|
||||
initialDate={review.visited_at || ""}
|
||||
onSubmit={(data) => handleUpdate(review.id, data)}
|
||||
onCancel={() => setEditingId(null)}
|
||||
submitLabel="수정"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
{review.user_avatar_url && (
|
||||
<img
|
||||
src={review.user_avatar_url}
|
||||
alt=""
|
||||
className="w-5 h-5 rounded-full"
|
||||
/>
|
||||
)}
|
||||
<span className="text-sm font-medium">
|
||||
{review.user_nickname || "익명"}
|
||||
</span>
|
||||
<StarDisplay rating={review.rating} />
|
||||
<span className="text-xs text-gray-400">
|
||||
{new Date(review.created_at).toLocaleDateString(
|
||||
"ko-KR"
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
{review.review_text && (
|
||||
<p className="text-sm text-gray-700 mt-1">
|
||||
{review.review_text}
|
||||
</p>
|
||||
)}
|
||||
{review.visited_at && (
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
방문일: {review.visited_at}
|
||||
</p>
|
||||
)}
|
||||
{user && review.user_id === user.id && (
|
||||
<div className="flex gap-2 mt-2">
|
||||
<button
|
||||
onClick={() => setEditingId(review.id)}
|
||||
className="text-xs text-blue-600 hover:underline"
|
||||
>
|
||||
수정
|
||||
</button>
|
||||
<button
|
||||
onClick={() => handleDelete(review.id)}
|
||||
className="text-xs text-red-600 hover:underline"
|
||||
>
|
||||
삭제
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
48
frontend/src/components/SearchBar.tsx
Normal file
48
frontend/src/components/SearchBar.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
interface SearchBarProps {
|
||||
onSearch: (query: string, mode: "keyword" | "semantic" | "hybrid") => void;
|
||||
isLoading?: boolean;
|
||||
}
|
||||
|
||||
export default function SearchBar({ onSearch, isLoading }: SearchBarProps) {
|
||||
const [query, setQuery] = useState("");
|
||||
const [mode, setMode] = useState<"keyword" | "semantic" | "hybrid">("hybrid");
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (query.trim()) {
|
||||
onSearch(query.trim(), mode);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="flex gap-2 items-center">
|
||||
<input
|
||||
type="text"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder="식당, 지역, 음식 종류..."
|
||||
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 text-sm"
|
||||
/>
|
||||
<select
|
||||
value={mode}
|
||||
onChange={(e) => setMode(e.target.value as typeof mode)}
|
||||
className="px-3 py-2 border border-gray-300 rounded-lg text-sm bg-white"
|
||||
>
|
||||
<option value="hybrid">통합</option>
|
||||
<option value="keyword">키워드</option>
|
||||
<option value="semantic">의미</option>
|
||||
</select>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading || !query.trim()}
|
||||
className="px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50 text-sm"
|
||||
>
|
||||
{isLoading ? "..." : "검색"}
|
||||
</button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user