Merge branch 'main' of https://github.com/Patel-Mann/TitanForge
This commit is contained in:
2
backend/.env
Normal file
2
backend/.env
Normal file
@@ -0,0 +1,2 @@
|
||||
SUPABASE_URL=https://tnpnlkosqqudoadfylss.supabase.co
|
||||
SUPABASE_SERVICE_ROLE_KEY=sb_publishable_UqXeuY5gOjvGpoNO1ciZYw_g7nO2M1Q
|
||||
299
backend/api_routes.py
Normal file
299
backend/api_routes.py
Normal file
@@ -0,0 +1,299 @@
|
||||
"""
|
||||
Example Flask routes using db_queries.py
|
||||
Add these routes to your existing Flask app
|
||||
"""
|
||||
|
||||
from flask import Flask, jsonify, request
|
||||
|
||||
# Import all query functions
|
||||
from db_queries import (
|
||||
get_user_by_id,
|
||||
get_user_by_username,
|
||||
get_user_stats,
|
||||
get_post_by_id,
|
||||
get_posts_feed,
|
||||
get_user_posts,
|
||||
get_post_engagement,
|
||||
check_user_post_interactions,
|
||||
get_all_categories,
|
||||
get_posts_by_category,
|
||||
get_post_comments,
|
||||
get_listening_history,
|
||||
get_search_history,
|
||||
search_posts,
|
||||
get_trending_topics,
|
||||
get_user_bookmarks,
|
||||
get_pagination_info
|
||||
)
|
||||
|
||||
# Assuming you have the app instance
|
||||
# app = Flask(__name__)
|
||||
|
||||
|
||||
# ==================== USER ROUTES ====================
|
||||
|
||||
@app.get("/users/<int:user_id>")
|
||||
def get_user(user_id: int):
|
||||
"""Get user profile with stats."""
|
||||
user = get_user_by_id(user_id)
|
||||
if not user:
|
||||
return jsonify({"error": "User not found"}), 404
|
||||
|
||||
stats = get_user_stats(user_id)
|
||||
|
||||
return jsonify({
|
||||
"user": {
|
||||
"id": user["user_id"],
|
||||
"username": user["username"],
|
||||
"email": user["email"],
|
||||
"display_name": user["display_name"],
|
||||
"bio": user.get("bio"),
|
||||
"profile_image_url": user.get("profile_image_url"),
|
||||
"location": None, # Add to schema if needed
|
||||
"created_at": user["created_at"],
|
||||
"stats": stats
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@app.get("/users/me")
|
||||
def get_current_user():
|
||||
"""Get current user profile (requires auth)."""
|
||||
# In production, get user_id from JWT token
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
return get_user(user_id)
|
||||
|
||||
|
||||
# ==================== POST/FEED ROUTES ====================
|
||||
|
||||
@app.get("/posts")
|
||||
def get_feed():
|
||||
"""Get personalized feed."""
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
sort = request.args.get("sort", default="recent")
|
||||
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
if limit > 50:
|
||||
limit = 50
|
||||
|
||||
posts = get_posts_feed(user_id, page=page, limit=limit, sort=sort)
|
||||
|
||||
# For production, you'd get total count from a separate query
|
||||
total_count = len(posts) * 10 # Placeholder
|
||||
pagination = get_pagination_info(total_count, page, limit)
|
||||
|
||||
return jsonify({
|
||||
"posts": posts,
|
||||
"pagination": pagination
|
||||
})
|
||||
|
||||
|
||||
@app.get("/posts/<int:post_id>")
|
||||
def get_single_post(post_id: int):
|
||||
"""Get a single post by ID."""
|
||||
user_id = request.args.get("user_id", type=int) # For privacy check
|
||||
|
||||
post = get_post_by_id(post_id, requesting_user_id=user_id)
|
||||
if not post:
|
||||
return jsonify({"error": "Post not found or private"}), 404
|
||||
|
||||
# Add user interaction info if user_id provided
|
||||
if user_id:
|
||||
interactions = check_user_post_interactions(user_id, post_id)
|
||||
post.update(interactions)
|
||||
|
||||
return jsonify({"post": post})
|
||||
|
||||
|
||||
@app.get("/posts/user/<int:user_id>")
|
||||
def get_posts_by_user(user_id: int):
|
||||
"""Get posts by a specific user."""
|
||||
filter_type = request.args.get("filter", default="all")
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
|
||||
if limit > 50:
|
||||
limit = 50
|
||||
|
||||
posts = get_user_posts(user_id, filter_type=filter_type, page=page, limit=limit)
|
||||
|
||||
return jsonify({
|
||||
"posts": posts,
|
||||
"pagination": get_pagination_info(len(posts) * 5, page, limit) # Placeholder
|
||||
})
|
||||
|
||||
|
||||
@app.get("/posts/user/me")
|
||||
def get_my_posts():
|
||||
"""Get current user's posts."""
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
return get_posts_by_user(user_id)
|
||||
|
||||
|
||||
# ==================== CATEGORY ROUTES ====================
|
||||
|
||||
@app.get("/categories")
|
||||
def get_categories():
|
||||
"""Get all categories."""
|
||||
categories = get_all_categories()
|
||||
return jsonify({"categories": categories})
|
||||
|
||||
|
||||
@app.get("/categories/<int:category_id>/posts")
|
||||
def get_category_posts(category_id: int):
|
||||
"""Get posts in a category."""
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
|
||||
posts = get_posts_by_category(category_id, page=page, limit=limit)
|
||||
|
||||
return jsonify({
|
||||
"posts": posts,
|
||||
"pagination": get_pagination_info(len(posts) * 5, page, limit)
|
||||
})
|
||||
|
||||
|
||||
# ==================== COMMENT ROUTES ====================
|
||||
|
||||
@app.get("/posts/<int:post_id>/comments")
|
||||
def get_comments(post_id: int):
|
||||
"""Get comments for a post."""
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
|
||||
comments = get_post_comments(post_id, page=page, limit=limit)
|
||||
|
||||
return jsonify({
|
||||
"comments": comments,
|
||||
"pagination": get_pagination_info(len(comments) * 3, page, limit)
|
||||
})
|
||||
|
||||
|
||||
# ==================== HISTORY ROUTES ====================
|
||||
|
||||
@app.get("/history/listening")
|
||||
def get_user_listening_history():
|
||||
"""Get user's listening history."""
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=50, type=int)
|
||||
completed_only = request.args.get("completed", default="false").lower() == "true"
|
||||
|
||||
history = get_listening_history(user_id, page=page, limit=limit, completed_only=completed_only)
|
||||
|
||||
return jsonify({
|
||||
"history": history,
|
||||
"pagination": get_pagination_info(len(history) * 3, page, limit)
|
||||
})
|
||||
|
||||
|
||||
@app.get("/history/searches")
|
||||
def get_user_search_history():
|
||||
"""Get user's search history."""
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=50, type=int)
|
||||
|
||||
searches = get_search_history(user_id, page=page, limit=limit)
|
||||
|
||||
return jsonify({"searches": searches})
|
||||
|
||||
|
||||
# ==================== SEARCH ROUTES ====================
|
||||
|
||||
@app.get("/search")
|
||||
def search():
|
||||
"""Search posts."""
|
||||
query = request.args.get("q")
|
||||
if not query:
|
||||
return jsonify({"error": "Search query 'q' is required"}), 400
|
||||
|
||||
category_id = request.args.get("categoryId", type=int)
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
|
||||
results = search_posts(
|
||||
query=query,
|
||||
category_id=category_id,
|
||||
page=page,
|
||||
limit=limit,
|
||||
requesting_user_id=user_id
|
||||
)
|
||||
|
||||
return jsonify({
|
||||
"results": results,
|
||||
"pagination": get_pagination_info(len(results) * 5, page, limit)
|
||||
})
|
||||
|
||||
|
||||
# ==================== TRENDING ROUTES ====================
|
||||
|
||||
@app.get("/trending/topics")
|
||||
def get_trending():
|
||||
"""Get trending topics."""
|
||||
limit = request.args.get("limit", default=5, type=int)
|
||||
|
||||
topics = get_trending_topics(limit=limit)
|
||||
|
||||
return jsonify({"topics": topics})
|
||||
|
||||
|
||||
# ==================== BOOKMARK ROUTES ====================
|
||||
|
||||
@app.get("/bookmarks")
|
||||
def get_bookmarks():
|
||||
"""Get user's bookmarked posts."""
|
||||
user_id = request.args.get("user_id", type=int)
|
||||
if not user_id:
|
||||
return jsonify({"error": "user_id required"}), 400
|
||||
|
||||
page = request.args.get("page", default=1, type=int)
|
||||
limit = request.args.get("limit", default=20, type=int)
|
||||
|
||||
bookmarks = get_user_bookmarks(user_id, page=page, limit=limit)
|
||||
|
||||
return jsonify({
|
||||
"bookmarks": bookmarks,
|
||||
"pagination": get_pagination_info(len(bookmarks) * 3, page, limit)
|
||||
})
|
||||
|
||||
|
||||
# ==================== ENGAGEMENT STATS ROUTES ====================
|
||||
|
||||
@app.get("/posts/<int:post_id>/engagement")
|
||||
def get_post_engagement_stats(post_id: int):
|
||||
"""Get engagement statistics for a post."""
|
||||
engagement = get_post_engagement(post_id)
|
||||
return jsonify(engagement)
|
||||
|
||||
|
||||
# Example of how to use in your existing main.py:
|
||||
"""
|
||||
# In your main.py, import these routes:
|
||||
|
||||
from flask import Flask
|
||||
# ... your other imports ...
|
||||
from api_routes import * # Import all routes
|
||||
|
||||
# Or import specific routes:
|
||||
# from api_routes import get_user, get_feed, get_categories, etc.
|
||||
|
||||
# Then your existing routes will work alongside these new ones
|
||||
"""
|
||||
463
backend/db_queries.py
Normal file
463
backend/db_queries.py
Normal file
@@ -0,0 +1,463 @@
|
||||
"""
|
||||
Database query functions for VoiceVault backend.
|
||||
Handles all read operations from Supabase.
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from supabase import Client, create_client
|
||||
|
||||
# Initialize Supabase client
|
||||
SUPABASE_URL = os.getenv("SUPABASE_URL")
|
||||
SUPABASE_SERVICE_ROLE_KEY = os.getenv("SUPABASE_SERVICE_ROLE_KEY")
|
||||
|
||||
if not SUPABASE_URL or not SUPABASE_SERVICE_ROLE_KEY:
|
||||
raise RuntimeError(
|
||||
"Missing SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY environment variables."
|
||||
)
|
||||
|
||||
supabase: Client = create_client(SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY)
|
||||
|
||||
|
||||
# ==================== USER QUERIES ====================
|
||||
|
||||
def get_user_by_id(user_id: int) -> Optional[Dict[str, Any]]:
|
||||
"""Get user information by user ID."""
|
||||
response = supabase.table("users").select("*").eq("user_id", user_id).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
return data[0] if data else None
|
||||
|
||||
|
||||
def get_user_by_username(username: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get user information by username."""
|
||||
response = supabase.table("users").select("*").eq("username", username).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
return data[0] if data else None
|
||||
|
||||
|
||||
def get_user_by_email(email: str) -> Optional[Dict[str, Any]]:
|
||||
"""Get user information by email."""
|
||||
response = supabase.table("users").select("*").eq("email", email).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
return data[0] if data else None
|
||||
|
||||
|
||||
def get_user_stats(user_id: int) -> Dict[str, int]:
|
||||
"""Get user statistics (posts, followers, following)."""
|
||||
# Get post count
|
||||
posts_response = supabase.table("posts").select("post_id", count="exact").eq("user_id", user_id).execute()
|
||||
post_count = getattr(posts_response, "count", 0) or 0
|
||||
|
||||
# Get followers count
|
||||
followers_response = supabase.table("user_follows").select("follower_id", count="exact").eq("following_id", user_id).execute()
|
||||
followers_count = getattr(followers_response, "count", 0) or 0
|
||||
|
||||
# Get following count
|
||||
following_response = supabase.table("user_follows").select("following_id", count="exact").eq("follower_id", user_id).execute()
|
||||
following_count = getattr(following_response, "count", 0) or 0
|
||||
|
||||
# Get total listeners (sum of all listens on user's posts)
|
||||
listens_response = supabase.rpc("get_user_total_listeners", {"p_user_id": user_id}).execute()
|
||||
total_listeners = getattr(listens_response, "data", 0) or 0
|
||||
|
||||
return {
|
||||
"posts": post_count,
|
||||
"followers": followers_count,
|
||||
"following": following_count,
|
||||
"listeners": total_listeners
|
||||
}
|
||||
|
||||
|
||||
# ==================== POST QUERIES ====================
|
||||
|
||||
def get_post_by_id(post_id: int, requesting_user_id: Optional[int] = None) -> Optional[Dict[str, Any]]:
|
||||
"""
|
||||
Get a single post by ID with user info and categories.
|
||||
Returns None if post is private and requesting_user_id doesn't match post owner.
|
||||
"""
|
||||
response = (
|
||||
supabase.table("posts")
|
||||
.select("""
|
||||
*,
|
||||
users!inner(user_id, username, display_name, profile_image_url),
|
||||
post_categories!inner(category_id, categories!inner(name))
|
||||
""")
|
||||
.eq("post_id", post_id)
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
if not data:
|
||||
return None
|
||||
|
||||
post = data[0]
|
||||
|
||||
# Check privacy
|
||||
if post.get("is_private") and post.get("user_id") != requesting_user_id:
|
||||
return None
|
||||
|
||||
return _format_post(post)
|
||||
|
||||
|
||||
def get_posts_feed(
|
||||
user_id: int,
|
||||
page: int = 1,
|
||||
limit: int = 20,
|
||||
sort: str = "recent"
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Get personalized feed for a user.
|
||||
Includes posts from followed users and followed categories.
|
||||
"""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
# Base query
|
||||
query = (
|
||||
supabase.table("posts")
|
||||
.select("""
|
||||
*,
|
||||
users!inner(user_id, username, display_name, profile_image_url),
|
||||
post_categories(category_id, categories(name))
|
||||
""")
|
||||
.eq("is_private", False)
|
||||
)
|
||||
|
||||
# Apply sorting
|
||||
if sort == "recent":
|
||||
query = query.order("created_at", desc=True)
|
||||
elif sort == "popular":
|
||||
# Would need a view or function to sort by engagement
|
||||
query = query.order("created_at", desc=True)
|
||||
|
||||
response = query.range(offset, offset + limit - 1).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
|
||||
return [_format_post(post) for post in data]
|
||||
|
||||
|
||||
def get_user_posts(
|
||||
user_id: int,
|
||||
filter_type: str = "all",
|
||||
page: int = 1,
|
||||
limit: int = 20
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Get posts created by a specific user.
|
||||
filter_type: 'all', 'public', 'private'
|
||||
"""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
query = (
|
||||
supabase.table("posts")
|
||||
.select("""
|
||||
*,
|
||||
post_categories(category_id, categories(name))
|
||||
""")
|
||||
.eq("user_id", user_id)
|
||||
)
|
||||
|
||||
# Apply filter
|
||||
if filter_type == "public":
|
||||
query = query.eq("is_private", False)
|
||||
elif filter_type == "private":
|
||||
query = query.eq("is_private", True)
|
||||
|
||||
response = query.order("created_at", desc=True).range(offset, offset + limit - 1).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
|
||||
return [_format_post(post) for post in data]
|
||||
|
||||
|
||||
def get_post_engagement(post_id: int) -> Dict[str, int]:
|
||||
"""Get engagement metrics for a post (likes, comments, listens)."""
|
||||
# Get likes count
|
||||
likes_response = supabase.table("post_likes").select("user_id", count="exact").eq("post_id", post_id).execute()
|
||||
likes_count = getattr(likes_response, "count", 0) or 0
|
||||
|
||||
# Get comments count
|
||||
comments_response = supabase.table("comments").select("comment_id", count="exact").eq("post_id", post_id).execute()
|
||||
comments_count = getattr(comments_response, "count", 0) or 0
|
||||
|
||||
# Get listens count
|
||||
listens_response = supabase.table("audio_listening_history").select("history_id", count="exact").eq("post_id", post_id).execute()
|
||||
listens_count = getattr(listens_response, "count", 0) or 0
|
||||
|
||||
# Get bookmarks count
|
||||
bookmarks_response = supabase.table("bookmarks").select("user_id", count="exact").eq("post_id", post_id).execute()
|
||||
bookmarks_count = getattr(bookmarks_response, "count", 0) or 0
|
||||
|
||||
return {
|
||||
"likes": likes_count,
|
||||
"comments": comments_count,
|
||||
"listens": listens_count,
|
||||
"bookmarks": bookmarks_count
|
||||
}
|
||||
|
||||
|
||||
def check_user_post_interactions(user_id: int, post_id: int) -> Dict[str, bool]:
|
||||
"""Check if user has liked/bookmarked a post."""
|
||||
# Check if liked
|
||||
like_response = supabase.table("post_likes").select("user_id").eq("user_id", user_id).eq("post_id", post_id).execute()
|
||||
is_liked = len(getattr(like_response, "data", []) or []) > 0
|
||||
|
||||
# Check if bookmarked
|
||||
bookmark_response = supabase.table("bookmarks").select("user_id").eq("user_id", user_id).eq("post_id", post_id).execute()
|
||||
is_bookmarked = len(getattr(bookmark_response, "data", []) or []) > 0
|
||||
|
||||
return {
|
||||
"is_liked": is_liked,
|
||||
"is_bookmarked": is_bookmarked
|
||||
}
|
||||
|
||||
|
||||
# ==================== CATEGORY QUERIES ====================
|
||||
|
||||
def get_all_categories() -> List[Dict[str, Any]]:
|
||||
"""Get all categories."""
|
||||
response = supabase.table("categories").select("*").execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
return data
|
||||
|
||||
|
||||
def get_category_by_id(category_id: int) -> Optional[Dict[str, Any]]:
|
||||
"""Get category by ID."""
|
||||
response = supabase.table("categories").select("*").eq("category_id", category_id).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
return data[0] if data else None
|
||||
|
||||
|
||||
def get_posts_by_category(
|
||||
category_id: int,
|
||||
page: int = 1,
|
||||
limit: int = 20
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Get posts in a specific category."""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
response = (
|
||||
supabase.table("post_categories")
|
||||
.select("""
|
||||
posts!inner(*,
|
||||
users!inner(user_id, username, display_name, profile_image_url),
|
||||
post_categories(category_id, categories(name))
|
||||
)
|
||||
""")
|
||||
.eq("category_id", category_id)
|
||||
.eq("posts.is_private", False)
|
||||
.order("posts.created_at", desc=True)
|
||||
.range(offset, offset + limit - 1)
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
return [_format_post(item["posts"]) for item in data]
|
||||
|
||||
|
||||
# ==================== COMMENT QUERIES ====================
|
||||
|
||||
def get_post_comments(post_id: int, page: int = 1, limit: int = 20) -> List[Dict[str, Any]]:
|
||||
"""Get comments for a specific post."""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
response = (
|
||||
supabase.table("comments")
|
||||
.select("""
|
||||
*,
|
||||
users!inner(user_id, username, display_name, profile_image_url)
|
||||
""")
|
||||
.eq("post_id", post_id)
|
||||
.order("created_at", desc=True)
|
||||
.range(offset, offset + limit - 1)
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
return data
|
||||
|
||||
|
||||
# ==================== HISTORY QUERIES ====================
|
||||
|
||||
def get_listening_history(
|
||||
user_id: int,
|
||||
page: int = 1,
|
||||
limit: int = 50,
|
||||
completed_only: bool = False
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""Get user's listening history."""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
query = (
|
||||
supabase.table("audio_listening_history")
|
||||
.select("""
|
||||
*,
|
||||
posts!inner(*,
|
||||
users!inner(user_id, username, display_name, profile_image_url)
|
||||
)
|
||||
""")
|
||||
.eq("user_id", user_id)
|
||||
)
|
||||
|
||||
if completed_only:
|
||||
query = query.eq("completed", True)
|
||||
|
||||
response = query.order("listened_at", desc=True).range(offset, offset + limit - 1).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def get_search_history(user_id: int, page: int = 1, limit: int = 50) -> List[Dict[str, Any]]:
|
||||
"""Get user's search history."""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
response = (
|
||||
supabase.table("search_history")
|
||||
.select("*")
|
||||
.eq("user_id", user_id)
|
||||
.order("searched_at", desc=True)
|
||||
.range(offset, offset + limit - 1)
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
return data
|
||||
|
||||
|
||||
# ==================== SEARCH QUERIES ====================
|
||||
|
||||
def search_posts(
|
||||
query: str,
|
||||
category_id: Optional[int] = None,
|
||||
page: int = 1,
|
||||
limit: int = 20,
|
||||
requesting_user_id: Optional[int] = None
|
||||
) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Search posts by text query.
|
||||
Uses full-text search on title and transcribed_text.
|
||||
"""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
# Basic search using ilike (for simple text matching)
|
||||
# For production, you'd want to use PostgreSQL full-text search
|
||||
search_query = (
|
||||
supabase.table("posts")
|
||||
.select("""
|
||||
*,
|
||||
users!inner(user_id, username, display_name, profile_image_url),
|
||||
post_categories(category_id, categories(name))
|
||||
""")
|
||||
.eq("is_private", False)
|
||||
.or_(f"title.ilike.%{query}%,transcribed_text.ilike.%{query}%")
|
||||
)
|
||||
|
||||
if category_id:
|
||||
# This would need a join with post_categories
|
||||
pass
|
||||
|
||||
response = search_query.order("created_at", desc=True).range(offset, offset + limit - 1).execute()
|
||||
data = getattr(response, "data", None) or []
|
||||
|
||||
return [_format_post(post) for post in data]
|
||||
|
||||
|
||||
# ==================== TRENDING QUERIES ====================
|
||||
|
||||
def get_trending_topics(limit: int = 5) -> List[Dict[str, Any]]:
|
||||
"""
|
||||
Get trending categories based on recent post activity.
|
||||
This is a simplified version - for production, you'd want a materialized view.
|
||||
"""
|
||||
# This would ideally be a database view or function
|
||||
# For now, we'll get categories with most posts in last 7 days
|
||||
response = (
|
||||
supabase.rpc("get_trending_categories", {"p_limit": limit})
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
return data
|
||||
|
||||
|
||||
# ==================== BOOKMARKS QUERIES ====================
|
||||
|
||||
def get_user_bookmarks(user_id: int, page: int = 1, limit: int = 20) -> List[Dict[str, Any]]:
|
||||
"""Get user's bookmarked posts."""
|
||||
offset = (page - 1) * limit
|
||||
|
||||
response = (
|
||||
supabase.table("bookmarks")
|
||||
.select("""
|
||||
*,
|
||||
posts!inner(*,
|
||||
users!inner(user_id, username, display_name, profile_image_url),
|
||||
post_categories(category_id, categories(name))
|
||||
)
|
||||
""")
|
||||
.eq("user_id", user_id)
|
||||
.order("bookmarked_at", desc=True)
|
||||
.range(offset, offset + limit - 1)
|
||||
.execute()
|
||||
)
|
||||
|
||||
data = getattr(response, "data", None) or []
|
||||
return [_format_post(item["posts"]) for item in data]
|
||||
|
||||
|
||||
# ==================== HELPER FUNCTIONS ====================
|
||||
|
||||
def _format_post(post: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""Format post data to include engagement metrics and clean structure."""
|
||||
post_id = post.get("post_id")
|
||||
|
||||
# Get engagement metrics
|
||||
engagement = get_post_engagement(post_id) if post_id else {"likes": 0, "comments": 0, "listens": 0, "bookmarks": 0}
|
||||
|
||||
# Extract categories
|
||||
categories = []
|
||||
if "post_categories" in post and post["post_categories"]:
|
||||
for pc in post["post_categories"]:
|
||||
if "categories" in pc and pc["categories"]:
|
||||
categories.append(pc["categories"])
|
||||
|
||||
# Clean user data
|
||||
user_data = post.get("users", {})
|
||||
|
||||
return {
|
||||
"id": post.get("post_id"),
|
||||
"user_id": post.get("user_id"),
|
||||
"title": post.get("title"),
|
||||
"audio_url": post.get("audio_url"),
|
||||
"transcribed_text": post.get("transcribed_text"),
|
||||
"audio_duration_seconds": post.get("audio_duration_seconds"),
|
||||
"image_url": post.get("image_url"),
|
||||
"is_private": post.get("is_private"),
|
||||
"created_at": post.get("created_at"),
|
||||
"updated_at": post.get("updated_at"),
|
||||
"user": {
|
||||
"id": user_data.get("user_id"),
|
||||
"username": user_data.get("username"),
|
||||
"display_name": user_data.get("display_name"),
|
||||
"profile_image_url": user_data.get("profile_image_url")
|
||||
},
|
||||
"categories": categories,
|
||||
"likes": engagement["likes"],
|
||||
"comments": engagement["comments"],
|
||||
"listens": engagement["listens"],
|
||||
"bookmarks": engagement["bookmarks"]
|
||||
}
|
||||
|
||||
|
||||
def get_pagination_info(total_count: int, page: int, limit: int) -> Dict[str, Any]:
|
||||
"""Calculate pagination information."""
|
||||
total_pages = (total_count + limit - 1) // limit
|
||||
has_more = page < total_pages
|
||||
|
||||
return {
|
||||
"current_page": page,
|
||||
"total_pages": total_pages,
|
||||
"total_items": total_count,
|
||||
"items_per_page": limit,
|
||||
"has_more": has_more
|
||||
}
|
||||
23
backend/main.py
Normal file
23
backend/main.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
from flask import Flask, jsonify
|
||||
from flask_cors import CORS
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
app = Flask(__name__)
|
||||
CORS(app)
|
||||
|
||||
@app.get("/")
|
||||
def health_check():
|
||||
return jsonify({
|
||||
"status": "running",
|
||||
"service": "VoiceVault API"
|
||||
})
|
||||
|
||||
# Import and register blueprint
|
||||
from api_routes import api
|
||||
app.register_blueprint(api)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=5000, debug=True)
|
||||
24
frontend/.gitignore
vendored
Normal file
24
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
16
frontend/README.md
Normal file
16
frontend/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# React + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
|
||||
29
frontend/eslint.config.js
Normal file
29
frontend/eslint.config.js
Normal file
@@ -0,0 +1,29 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{js,jsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
ecmaFeatures: { jsx: true },
|
||||
sourceType: 'module',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
|
||||
},
|
||||
},
|
||||
])
|
||||
14
frontend/index.html
Normal file
14
frontend/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<!-- <link href="/src/index.css" rel="stylesheet"> -->
|
||||
<title>frontend</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.jsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
2927
frontend/package-lock.json
generated
Normal file
2927
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
frontend/package.json
Normal file
28
frontend/package.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"lucide-react": "^0.564.0",
|
||||
"react": "^19.2.0",
|
||||
"react-dom": "^19.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@types/react": "^19.2.7",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^5.1.1",
|
||||
"eslint": "^9.39.1",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.4.24",
|
||||
"globals": "^16.5.0",
|
||||
"vite": "^7.3.1"
|
||||
}
|
||||
}
|
||||
1
frontend/public/vite.svg
Normal file
1
frontend/public/vite.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
161
frontend/src/App.jsx
Normal file
161
frontend/src/App.jsx
Normal file
@@ -0,0 +1,161 @@
|
||||
import { useState } from 'react'
|
||||
import Header from './components/Header'
|
||||
import Sidebar from './components/Sidebar'
|
||||
// import RightSidebar from './components/RightSidebar'
|
||||
import Feed from './pages/Feed'
|
||||
import CreatePost from './pages/CreatePost'
|
||||
import History from './pages/History'
|
||||
import Settings from './pages/Settings'
|
||||
|
||||
export default function App() {
|
||||
const [activeTab, setActiveTab] = useState('feed')
|
||||
const [searchQuery, setSearchQuery] = useState('')
|
||||
|
||||
// Mock user data
|
||||
const user = {
|
||||
initials: 'JD',
|
||||
name: 'John Doe',
|
||||
role: 'Oral Historian',
|
||||
location: 'San Francisco, CA',
|
||||
stats: {
|
||||
posts: 127,
|
||||
listeners: '2.4k',
|
||||
following: 89
|
||||
}
|
||||
}
|
||||
|
||||
// Mock trending topics
|
||||
const trendingTopics = [
|
||||
{ name: 'Historical Events', count: '1.2k', growth: 23 },
|
||||
{ name: 'Family Stories', count: '892', growth: 18 },
|
||||
{ name: 'Cultural Heritage', count: '654', growth: 12 },
|
||||
]
|
||||
|
||||
// Mock posts data
|
||||
const posts = [
|
||||
{
|
||||
id: 1,
|
||||
user: {
|
||||
name: 'Diana Martinez',
|
||||
initials: 'DM',
|
||||
avatarColor: 'linear-gradient(135deg, #ec4899 0%, #db2777 100%)'
|
||||
},
|
||||
title: "My Grandmother's Journey Through WWII",
|
||||
timeAgo: '2 hours ago',
|
||||
categories: [
|
||||
{ name: 'Historical Events', color: 'yellow' },
|
||||
{ name: 'Personal Stories', color: 'blue' }
|
||||
],
|
||||
audio: {
|
||||
currentTime: '2:34',
|
||||
duration: '7:52',
|
||||
progress: 33
|
||||
},
|
||||
transcript: '"I remember the day clearly, despite all these years. We were living in a small village outside Warsaw when the news came. My mother gathered us all together and told us we had to leave everything behind..."',
|
||||
likes: 248,
|
||||
comments: 32
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
user: {
|
||||
name: 'Robert Miller',
|
||||
initials: 'RM',
|
||||
avatarColor: 'linear-gradient(135deg, #a855f7 0%, #9333ea 100%)'
|
||||
},
|
||||
title: 'Traditional Music of the Appalachian Mountains',
|
||||
timeAgo: '5 hours ago',
|
||||
categories: [
|
||||
{ name: 'Cultural Traditions', color: 'purple' },
|
||||
{ name: 'Oral History', color: 'green' }
|
||||
],
|
||||
audio: {
|
||||
currentTime: '4:15',
|
||||
duration: '8:30',
|
||||
progress: 50
|
||||
},
|
||||
transcript: '"This song has been passed down through five generations of our family. My great-great-grandfather used to play it on his banjo during summer evenings on the porch. The melody tells the story of..."',
|
||||
likes: 412,
|
||||
comments: 58
|
||||
},{
|
||||
id: 3,
|
||||
user: {
|
||||
name: 'Robert Miller',
|
||||
initials: 'RM',
|
||||
avatarColor: 'linear-gradient(135deg, #a855f7 0%, #9333ea 100%)'
|
||||
},
|
||||
title: 'Traditional Music of the Appalachian Mountains',
|
||||
timeAgo: '5 hours ago',
|
||||
categories: [
|
||||
{ name: 'Cultural Traditions', color: 'purple' },
|
||||
{ name: 'Oral History', color: 'green' }
|
||||
],
|
||||
audio: {
|
||||
currentTime: '4:15',
|
||||
duration: '8:30',
|
||||
progress: 50
|
||||
},
|
||||
transcript: '"This song has been passed down through five generations of our family. My great-great-grandfather used to play it on his banjo during summer evenings on the porch. The melody tells the story of..."',
|
||||
likes: 412,
|
||||
comments: 58
|
||||
}
|
||||
]
|
||||
|
||||
// Mock listening history
|
||||
const listeningHistory = [
|
||||
{
|
||||
id: 1,
|
||||
title: "My Grandmother's Journey Through WWII",
|
||||
user: { name: 'Diana Martinez', initials: 'DM', avatarColor: 'linear-gradient(135deg, #ec4899 0%, #db2777 100%)' },
|
||||
listenedAt: '2 hours ago',
|
||||
duration: '7:52',
|
||||
progress: 100,
|
||||
completed: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: 'Traditional Music of the Appalachian Mountains',
|
||||
user: { name: 'Robert Miller', initials: 'RM', avatarColor: 'linear-gradient(135deg, #a855f7 0%, #9333ea 100%)' },
|
||||
listenedAt: '1 day ago',
|
||||
duration: '8:30',
|
||||
progress: 75,
|
||||
completed: false
|
||||
}
|
||||
]
|
||||
|
||||
// Mock search history
|
||||
const searchHistory = [
|
||||
{ id: 1, query: 'WWII stories', searchedAt: '2 hours ago' },
|
||||
{ id: 2, query: 'traditional music', searchedAt: '1 day ago' },
|
||||
{ id: 3, query: 'family history', searchedAt: '3 days ago' }
|
||||
]
|
||||
|
||||
// Render current page
|
||||
const renderPage = () => {
|
||||
switch (activeTab) {
|
||||
case 'create':
|
||||
return <CreatePost onSubmit={(data) => console.log('Post created:', data)} />
|
||||
case 'history':
|
||||
return <History listeningHistory={listeningHistory} searchHistory={searchHistory} />
|
||||
case 'settings':
|
||||
return <Settings onUpdate={(settings) => console.log('Settings updated:', settings)} />
|
||||
default:
|
||||
return <Feed posts={posts} />
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-screen bg-gray-50 text-gray-800 flex flex-col overflow-hidden">
|
||||
<Header onSearch={setSearchQuery} />
|
||||
|
||||
<div className="flex-1 flex overflow-hidden max-w-[1400px] mx-auto w-full">
|
||||
<Sidebar user={user} activeTab={activeTab} onTabChange={setActiveTab} />
|
||||
|
||||
<main className="flex-1 overflow-y-auto p-6">
|
||||
{renderPage()}
|
||||
</main>
|
||||
|
||||
{/* <RightSidebar trendingTopics={trendingTopics} /> */}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
320
frontend/src/Example.jsx
Normal file
320
frontend/src/Example.jsx
Normal file
@@ -0,0 +1,320 @@
|
||||
import { Search, User, Play, Archive, History, Settings, Volume2, Heart, MessageCircle, Share2, Bookmark, MoreVertical } from 'lucide-react'
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<div className="h-screen bg-[#27282a] text-gray-200 flex flex-col overflow-hidden">
|
||||
{/* Header */}
|
||||
<header className="bg-[#27282a] border-b border-gray-700 px-4 py-3 flex-shrink-0">
|
||||
<div className="max-w-[1400px] mx-auto flex items-center justify-between gap-6">
|
||||
{/* Left: Logo */}
|
||||
<div className="flex items-center gap-3 flex-shrink-0">
|
||||
<div className="w-8 h-8 bg-[#f4b840] rounded-lg flex items-center justify-center">
|
||||
<Volume2 size={18} className="text-white" />
|
||||
</div>
|
||||
<h1 className="text-lg font-bold text-gray-200">VoiceVault</h1>
|
||||
</div>
|
||||
|
||||
{/* Center: Search Bar */}
|
||||
<div className="flex-1 max-w-2xl">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-400" size={18} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search archives, stories, history..."
|
||||
className="w-full bg-[#1f2022] border border-gray-700 rounded-lg pl-10 pr-4 py-2 text-sm text-gray-200 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right: Login */}
|
||||
<div className="flex items-center gap-3 flex-shrink-0">
|
||||
<button className="bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] px-4 py-2 rounded text-sm font-medium flex items-center gap-2">
|
||||
<User size={16} />
|
||||
Log In
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="flex-1 flex overflow-hidden max-w-[1400px] mx-auto w-full">
|
||||
{/* Sidebar - Profile */}
|
||||
<aside className="w-64 bg-[#27282a] border-r border-gray-700 p-6 hidden md:block flex-shrink-0 overflow-y-auto">
|
||||
<div className="sticky top-6">
|
||||
{/* Profile Image */}
|
||||
<div className="w-32 h-32 bg-gradient-to-br from-[#f4b840] to-[#e5a930] rounded-full flex items-center justify-center text-[#1a1a1a] font-bold text-4xl mx-auto mb-4">
|
||||
JD
|
||||
</div>
|
||||
<div className="text-center mb-6">
|
||||
<h2 className="text-xl font-semibold text-gray-200 mb-1">John Doe</h2>
|
||||
<p className="text-sm text-gray-400">Oral Historian</p>
|
||||
<p className="text-xs text-gray-500 mt-2">San Francisco, CA</p>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<div className="space-y-2 mb-6">
|
||||
<button className="w-full flex items-center gap-3 px-3 py-2 rounded text-sm text-gray-200 bg-gray-800 hover:bg-gray-750 transition-colors">
|
||||
<Play size={18} />
|
||||
<span>Post to Archive</span>
|
||||
</button>
|
||||
<button className="w-full flex items-center gap-3 px-3 py-2 rounded text-sm text-gray-300 hover:bg-gray-800 transition-colors">
|
||||
<Archive size={18} />
|
||||
<span>Posted Archives</span>
|
||||
</button>
|
||||
<button className="w-full flex items-center gap-3 px-3 py-2 rounded text-sm text-gray-300 hover:bg-gray-800 transition-colors">
|
||||
<History size={18} />
|
||||
<span>History</span>
|
||||
</button>
|
||||
<button className="w-full flex items-center gap-3 px-3 py-2 rounded text-sm text-gray-300 hover:bg-gray-800 transition-colors">
|
||||
<Settings size={18} />
|
||||
<span>Settings</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="grid grid-cols-3 gap-2 p-3 bg-[#1f2022] rounded border border-gray-700">
|
||||
<div className="text-center">
|
||||
<div className="text-base font-semibold text-gray-200">127</div>
|
||||
<div className="text-xs text-gray-500">Posts</div>
|
||||
</div>
|
||||
<div className="text-center border-x border-gray-700">
|
||||
<div className="text-base font-semibold text-gray-200">2.4k</div>
|
||||
<div className="text-xs text-gray-500">Listeners</div>
|
||||
</div>
|
||||
<div className="text-center">
|
||||
<div className="text-base font-semibold text-gray-200">89</div>
|
||||
<div className="text-xs text-gray-500">Following</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
{/* Main Content - Feed */}
|
||||
<main className="flex-1 overflow-y-auto p-6">
|
||||
<div className="max-w-3xl mx-auto space-y-6">
|
||||
|
||||
{/* Audio Post Card */}
|
||||
<article className="bg-[#1f2022] rounded-lg border border-gray-700 overflow-hidden">
|
||||
{/* Post Header */}
|
||||
<div className="p-6 pb-4">
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-12 h-12 bg-gradient-to-br from-pink-500 to-pink-600 rounded-full flex items-center justify-center text-white font-semibold text-lg">
|
||||
DM
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-gray-200">Diana Martinez</span>
|
||||
<span className="text-gray-500 text-sm">• 2 hours ago</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
<span className="text-xs px-2 py-1 bg-[#f4b840]/10 text-[#f4b840] rounded border border-[#f4b840]/20">Historical Events</span>
|
||||
<span className="text-xs px-2 py-1 bg-blue-500/10 text-blue-400 rounded border border-blue-500/20">Personal Stories</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-500 hover:text-gray-300">
|
||||
<MoreVertical size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3 className="text-lg font-semibold text-gray-200 mb-3">My Grandmother's Journey Through WWII</h3>
|
||||
|
||||
{/* Audio Player */}
|
||||
<div className="bg-[#27282a] rounded-lg p-4 border border-gray-700">
|
||||
<div className="flex items-center gap-4 mb-3">
|
||||
<button className="w-10 h-10 bg-[#f4b840] hover:bg-[#e5a930] rounded-full flex items-center justify-center text-[#1a1a1a]">
|
||||
<Play size={16} fill="currentColor" />
|
||||
</button>
|
||||
<div className="flex-1">
|
||||
<div className="h-1.5 bg-gray-700 rounded-full overflow-hidden mb-2">
|
||||
<div className="h-full w-1/3 bg-[#f4b840] rounded-full"></div>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs text-gray-400">
|
||||
<span>2:34</span>
|
||||
<span>7:52</span>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-400 hover:text-gray-200">
|
||||
<Volume2 size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Transcription Preview */}
|
||||
<div className="mt-4 p-4 bg-[#27282a] rounded-lg border border-gray-700">
|
||||
<p className="text-sm text-gray-300 leading-relaxed line-clamp-3">
|
||||
"I remember the day clearly, despite all these years. We were living in a small village outside Warsaw when the news came. My mother gathered us all together and told us we had to leave everything behind..."
|
||||
</p>
|
||||
<button className="text-xs text-[#f4b840] hover:text-[#e5a930] mt-2 font-medium">
|
||||
Read full transcript →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Post Actions */}
|
||||
<div className="px-6 py-4 border-t border-gray-700 flex items-center gap-6">
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<Heart size={18} />
|
||||
<span>248</span>
|
||||
</button>
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<MessageCircle size={18} />
|
||||
<span>32</span>
|
||||
</button>
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<Share2 size={18} />
|
||||
<span>Share</span>
|
||||
</button>
|
||||
<button className="ml-auto text-gray-400 hover:text-gray-200">
|
||||
<Bookmark size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{/* Second Audio Post Card */}
|
||||
<article className="bg-[#1f2022] rounded-lg border border-gray-700 overflow-hidden">
|
||||
<div className="p-6 pb-4">
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-12 h-12 bg-gradient-to-br from-purple-500 to-purple-600 rounded-full flex items-center justify-center text-white font-semibold text-lg">
|
||||
RM
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-gray-200">Robert Miller</span>
|
||||
<span className="text-gray-500 text-sm">• 5 hours ago</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
<span className="text-xs px-2 py-1 bg-purple-500/10 text-purple-400 rounded border border-purple-500/20">Cultural Traditions</span>
|
||||
<span className="text-xs px-2 py-1 bg-green-500/10 text-green-400 rounded border border-green-500/20">Oral History</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-500 hover:text-gray-300">
|
||||
<MoreVertical size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3 className="text-lg font-semibold text-gray-200 mb-3">Traditional Music of the Appalachian Mountains</h3>
|
||||
|
||||
<div className="bg-[#27282a] rounded-lg p-4 border border-gray-700">
|
||||
<div className="flex items-center gap-4 mb-3">
|
||||
<button className="w-10 h-10 bg-[#f4b840] hover:bg-[#e5a930] rounded-full flex items-center justify-center text-[#1a1a1a]">
|
||||
<Play size={16} fill="currentColor" />
|
||||
</button>
|
||||
<div className="flex-1">
|
||||
<div className="h-1.5 bg-gray-700 rounded-full overflow-hidden mb-2">
|
||||
<div className="h-full w-1/2 bg-[#f4b840] rounded-full"></div>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs text-gray-400">
|
||||
<span>4:15</span>
|
||||
<span>8:30</span>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-400 hover:text-gray-200">
|
||||
<Volume2 size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="mt-4 p-4 bg-[#27282a] rounded-lg border border-gray-700">
|
||||
<p className="text-sm text-gray-300 leading-relaxed line-clamp-3">
|
||||
"This song has been passed down through five generations of our family. My great-great-grandfather used to play it on his banjo during summer evenings on the porch. The melody tells the story of..."
|
||||
</p>
|
||||
<button className="text-xs text-[#f4b840] hover:text-[#e5a930] mt-2 font-medium">
|
||||
Read full transcript →
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="px-6 py-4 border-t border-gray-700 flex items-center gap-6">
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<Heart size={18} />
|
||||
<span>412</span>
|
||||
</button>
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<MessageCircle size={18} />
|
||||
<span>58</span>
|
||||
</button>
|
||||
<button className="flex items-center gap-2 text-gray-400 hover:text-gray-200 text-sm">
|
||||
<Share2 size={18} />
|
||||
<span>Share</span>
|
||||
</button>
|
||||
<button className="ml-auto text-gray-400 hover:text-gray-200">
|
||||
<Bookmark size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{/* Right Sidebar - Trending */}
|
||||
<aside className="w-64 bg-[#27282a] border-l border-gray-700 p-4 hidden lg:block overflow-y-auto">
|
||||
<div className="sticky top-4 space-y-6">
|
||||
|
||||
{/* Trending Categories */}
|
||||
<div className="bg-[#1f2022] rounded-lg p-4 border border-gray-700">
|
||||
<h3 className="text-sm font-semibold text-gray-200 mb-3">Trending Topics</h3>
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between p-2 rounded hover:bg-gray-800 cursor-pointer">
|
||||
<div>
|
||||
<p className="text-sm font-medium text-gray-200">Historical Events</p>
|
||||
<p className="text-xs text-gray-500">1.2k new stories</p>
|
||||
</div>
|
||||
<div className="text-xs text-[#f4b840] font-semibold">↑ 23%</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between p-2 rounded hover:bg-gray-800 cursor-pointer">
|
||||
<div>
|
||||
<p className="text-sm font-medium text-gray-200">Family Stories</p>
|
||||
<p className="text-xs text-gray-500">892 new stories</p>
|
||||
</div>
|
||||
<div className="text-xs text-green-400 font-semibold">↑ 18%</div>
|
||||
</div>
|
||||
<div className="flex items-center justify-between p-2 rounded hover:bg-gray-800 cursor-pointer">
|
||||
<div>
|
||||
<p className="text-sm font-medium text-gray-200">Cultural Heritage</p>
|
||||
<p className="text-xs text-gray-500">654 new stories</p>
|
||||
</div>
|
||||
<div className="text-xs text-blue-400 font-semibold">↑ 12%</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Suggested Follows */}
|
||||
<div className="bg-[#1f2022] rounded-lg p-4 border border-gray-700">
|
||||
<h3 className="text-sm font-semibold text-gray-200 mb-3">Suggested Historians</h3>
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-gradient-to-br from-red-500 to-red-600 rounded-full flex items-center justify-center text-white font-semibold text-sm">
|
||||
SL
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium text-gray-200 truncate">Sarah Lewis</p>
|
||||
<p className="text-xs text-gray-500">342 followers</p>
|
||||
</div>
|
||||
<button className="text-xs px-3 py-1 bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] rounded font-medium">
|
||||
Follow
|
||||
</button>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-gradient-to-br from-teal-500 to-teal-600 rounded-full flex items-center justify-center text-white font-semibold text-sm">
|
||||
MK
|
||||
</div>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium text-gray-200 truncate">Mike Kim</p>
|
||||
<p className="text-xs text-gray-500">218 followers</p>
|
||||
</div>
|
||||
<button className="text-xs px-3 py-1 bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] rounded font-medium">
|
||||
Follow
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
1
frontend/src/assets/react.svg
Normal file
1
frontend/src/assets/react.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
114
frontend/src/components/AudioPostCard.jsx
Normal file
114
frontend/src/components/AudioPostCard.jsx
Normal file
@@ -0,0 +1,114 @@
|
||||
import { Play, Volume2, Heart, MessageCircle, Share2, Bookmark, MoreVertical } from 'lucide-react'
|
||||
|
||||
export default function AudioPostCard({ post, onLike, onComment, onShare, onBookmark }) {
|
||||
return (
|
||||
<article className="bg-white rounded-lg border border-gray-200 overflow-hidden shadow-sm hover:shadow-md transition-shadow">
|
||||
{/* Post Header */}
|
||||
<div className="p-6 pb-4">
|
||||
<div className="flex items-start justify-between mb-4">
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className="w-12 h-12 rounded-full flex items-center justify-center text-white font-semibold text-lg"
|
||||
style={{ background: post.user.avatarColor }}
|
||||
>
|
||||
{post.user.initials}
|
||||
</div>
|
||||
<div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-semibold text-gray-900">{post.user.name}</span>
|
||||
<span className="text-gray-500 text-sm">• {post.timeAgo}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mt-1">
|
||||
{post.categories.map((category, index) => (
|
||||
<span
|
||||
key={index}
|
||||
className={`text-xs px-2 py-1 rounded border ${
|
||||
category.color === 'yellow' ? 'bg-[#f4b840]/10 text-[#f4b840] border-[#f4b840]/20' :
|
||||
category.color === 'blue' ? 'bg-blue-500/10 text-blue-600 border-blue-500/20' :
|
||||
category.color === 'purple' ? 'bg-purple-500/10 text-purple-600 border-purple-500/20' :
|
||||
'bg-green-500/10 text-green-600 border-green-500/20'
|
||||
}`}
|
||||
>
|
||||
{category.name}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-500 hover:text-gray-700">
|
||||
<MoreVertical size={18} />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-3">{post.title}</h3>
|
||||
|
||||
{/* Audio Player */}
|
||||
<div className="bg-gray-50 rounded-lg p-4 border border-gray-200">
|
||||
<div className="flex items-center gap-4 mb-3">
|
||||
<button className="w-10 h-10 bg-[#f4b840] hover:bg-[#e5a930] rounded-full flex items-center justify-center text-[#1a1a1a]">
|
||||
<Play size={16} fill="currentColor" />
|
||||
</button>
|
||||
<div className="flex-1">
|
||||
<div className="h-1.5 bg-gray-300 rounded-full overflow-hidden mb-2">
|
||||
<div
|
||||
className="h-full bg-[#f4b840] rounded-full"
|
||||
style={{ width: `${post.audio.progress}%` }}
|
||||
></div>
|
||||
</div>
|
||||
<div className="flex justify-between text-xs text-gray-600">
|
||||
<span>{post.audio.currentTime}</span>
|
||||
<span>{post.audio.duration}</span>
|
||||
</div>
|
||||
</div>
|
||||
<button className="text-gray-600 hover:text-gray-900">
|
||||
<Volume2 size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Transcription Preview */}
|
||||
{post.transcript && (
|
||||
<div className="mt-4 p-4 bg-gray-50 rounded-lg border border-gray-200">
|
||||
<p className="text-sm text-gray-700 leading-relaxed line-clamp-3">
|
||||
{post.transcript}
|
||||
</p>
|
||||
<button className="text-xs text-[#f4b840] hover:text-[#e5a930] mt-2 font-medium">
|
||||
Read full transcript →
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Post Actions */}
|
||||
<div className="px-6 py-4 border-t border-gray-200 flex items-center gap-6">
|
||||
<button
|
||||
onClick={() => onLike?.(post.id)}
|
||||
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm"
|
||||
>
|
||||
<Heart size={18} />
|
||||
<span>{post.likes}</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onComment?.(post.id)}
|
||||
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm"
|
||||
>
|
||||
<MessageCircle size={18} />
|
||||
<span>{post.comments}</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onShare?.(post.id)}
|
||||
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 text-sm"
|
||||
>
|
||||
<Share2 size={18} />
|
||||
<span>Share</span>
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onBookmark?.(post.id)}
|
||||
className="ml-auto text-gray-600 hover:text-gray-900"
|
||||
>
|
||||
<Bookmark size={18} />
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
37
frontend/src/components/Header.jsx
Normal file
37
frontend/src/components/Header.jsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { Search, User, Volume2 } from 'lucide-react'
|
||||
|
||||
export default function Header() {
|
||||
return (
|
||||
<header className="bg-white border-b border-gray-200 px-4 py-3 flex-shrink-0">
|
||||
<div className="max-w-[1400px] mx-auto flex items-center justify-between gap-6">
|
||||
{/* Left: Logo */}
|
||||
<div className="flex items-center gap-3 flex-shrink-0">
|
||||
<div className="w-8 h-8 bg-[#f4b840] rounded-lg flex items-center justify-center">
|
||||
<Volume2 size={18} className="text-white" />
|
||||
</div>
|
||||
<h1 className="text-lg font-bold text-gray-900">VoiceVault</h1>
|
||||
</div>
|
||||
|
||||
{/* Center: Search Bar */}
|
||||
<div className="flex-1 max-w-2xl">
|
||||
<div className="relative">
|
||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 text-gray-500" size={18} />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search archives, stories, history..."
|
||||
className="w-full bg-white border border-gray-300 rounded-lg pl-10 pr-4 py-2 text-sm text-gray-900 placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right: Login */}
|
||||
<div className="flex items-center gap-3 flex-shrink-0">
|
||||
<button className="bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] px-4 py-2 rounded text-sm font-medium flex items-center gap-2">
|
||||
<User size={16} />
|
||||
Log In
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
48
frontend/src/components/Sidebar.jsx
Normal file
48
frontend/src/components/Sidebar.jsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import { Plus, Home, History, Settings } from 'lucide-react'
|
||||
|
||||
export default function Sidebar({ activeTab, onTabChange }) {
|
||||
const navItems = [
|
||||
{ id: 'create', label: 'Make an Archive Post', icon: Plus },
|
||||
{ id: 'feed', label: 'My Feed', icon: Home },
|
||||
{ id: 'history', label: 'History', icon: History },
|
||||
{ id: 'settings', label: 'Settings', icon: Settings }
|
||||
]
|
||||
|
||||
return (
|
||||
<aside className="w-64 bg-white border-r border-gray-200 p-6 hidden md:block flex-shrink-0 overflow-y-auto">
|
||||
<div className="sticky top-6">
|
||||
|
||||
{/* Profile Image */}
|
||||
<div className="w-32 h-32 bg-gradient-to-br from-[#f4b840] to-[#e5a930] rounded-full flex items-center justify-center text-[#1a1a1a] font-bold text-4xl mx-auto mb-4">
|
||||
JD
|
||||
</div>
|
||||
<div className="text-center mb-6">
|
||||
<h2 className="text-xl font-semibold text-gray-900 mb-1">John Doe</h2>
|
||||
<p className="text-sm text-gray-600">Oral Historian</p>
|
||||
<p className="text-xs text-gray-500 mt-2">San Francisco, CA</p>
|
||||
</div>
|
||||
{/* Navigation */}
|
||||
<nav className="space-y-2">
|
||||
{navItems.map((item) => {
|
||||
const Icon = item.icon
|
||||
const isActive = activeTab === item.id
|
||||
return (
|
||||
<button
|
||||
key={item.id}
|
||||
onClick={() => onTabChange(item.id)}
|
||||
className={`w-full flex items-center gap-3 px-3 py-2 rounded text-sm transition-colors ${
|
||||
isActive
|
||||
? 'text-gray-900 bg-gray-200 font-medium'
|
||||
: 'text-gray-600 hover:bg-gray-100'
|
||||
}`}
|
||||
>
|
||||
<Icon size={18} />
|
||||
<span>{item.label}</span>
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</nav>
|
||||
</div>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
2
frontend/src/index.css
Normal file
2
frontend/src/index.css
Normal file
@@ -0,0 +1,2 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
10
frontend/src/main.jsx
Normal file
10
frontend/src/main.jsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { StrictMode } from 'react'
|
||||
import { createRoot } from 'react-dom/client'
|
||||
import './index.css'
|
||||
import App from './App.jsx'
|
||||
|
||||
createRoot(document.getElementById('root')).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</StrictMode>,
|
||||
)
|
||||
188
frontend/src/pages/CreatePost.jsx
Normal file
188
frontend/src/pages/CreatePost.jsx
Normal file
@@ -0,0 +1,188 @@
|
||||
import { useState } from 'react'
|
||||
import { Mic, Upload, X } from 'lucide-react'
|
||||
|
||||
export default function CreatePost({ onSubmit }) {
|
||||
const [title, setTitle] = useState('')
|
||||
const [selectedCategories, setSelectedCategories] = useState([])
|
||||
const [audioFile, setAudioFile] = useState(null)
|
||||
const [isRecording, setIsRecording] = useState(false)
|
||||
const [isPrivate, setIsPrivate] = useState(false)
|
||||
|
||||
const categories = [
|
||||
{ id: 1, name: 'Historical Events', color: 'yellow' },
|
||||
{ id: 2, name: 'Cultural Traditions', color: 'purple' },
|
||||
{ id: 3, name: 'Personal Stories', color: 'blue' },
|
||||
{ id: 4, name: 'Oral History', color: 'green' },
|
||||
{ id: 5, name: 'Family History', color: 'blue' },
|
||||
]
|
||||
|
||||
const handleCategoryToggle = (categoryId) => {
|
||||
setSelectedCategories(prev =>
|
||||
prev.includes(categoryId)
|
||||
? prev.filter(id => id !== categoryId)
|
||||
: [...prev, categoryId]
|
||||
)
|
||||
}
|
||||
|
||||
const handleFileUpload = (e) => {
|
||||
const file = e.target.files[0]
|
||||
if (file && file.type.startsWith('audio/')) {
|
||||
setAudioFile(file)
|
||||
}
|
||||
}
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault()
|
||||
onSubmit?.({
|
||||
title,
|
||||
categories: selectedCategories,
|
||||
audioFile,
|
||||
isPrivate
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto">
|
||||
<div className="bg-white rounded-lg border border-gray-200 shadow-sm p-6">
|
||||
<h2 className="text-2xl font-bold text-gray-900 mb-6">Create New Archive</h2>
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-6">
|
||||
{/* Title Input */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">
|
||||
Title
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
placeholder="Give your archive a descriptive title..."
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Audio Recording/Upload */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">
|
||||
Audio Recording
|
||||
</label>
|
||||
<div className="space-y-3">
|
||||
{/* Recording Controls */}
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsRecording(!isRecording)}
|
||||
className={`flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border transition-colors ${
|
||||
isRecording
|
||||
? 'bg-red-50 border-red-300 text-red-700'
|
||||
: 'bg-gray-50 border-gray-300 text-gray-700 hover:bg-gray-100'
|
||||
}`}
|
||||
>
|
||||
<Mic size={20} />
|
||||
<span>{isRecording ? 'Recording...' : 'Start Recording'}</span>
|
||||
</button>
|
||||
|
||||
<label className="flex-1 flex items-center justify-center gap-2 px-4 py-3 rounded-lg border border-gray-300 bg-gray-50 text-gray-700 hover:bg-gray-100 cursor-pointer">
|
||||
<Upload size={20} />
|
||||
<span>Upload Audio</span>
|
||||
<input
|
||||
type="file"
|
||||
accept="audio/*"
|
||||
onChange={handleFileUpload}
|
||||
className="hidden"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{/* Audio File Preview */}
|
||||
{audioFile && (
|
||||
<div className="flex items-center justify-between p-3 bg-gray-50 rounded-lg border border-gray-200">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="w-10 h-10 bg-[#f4b840] rounded-lg flex items-center justify-center">
|
||||
<Mic size={18} className="text-white" />
|
||||
</div>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-gray-900">{audioFile.name}</p>
|
||||
<p className="text-xs text-gray-600">{(audioFile.size / 1024 / 1024).toFixed(2)} MB</p>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setAudioFile(null)}
|
||||
className="text-gray-500 hover:text-gray-700"
|
||||
>
|
||||
<X size={20} />
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Categories */}
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">
|
||||
Categories
|
||||
</label>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{categories.map((category) => (
|
||||
<button
|
||||
key={category.id}
|
||||
type="button"
|
||||
onClick={() => handleCategoryToggle(category.id)}
|
||||
className={`px-3 py-1.5 rounded-lg text-sm font-medium transition-colors ${
|
||||
selectedCategories.includes(category.id)
|
||||
? category.color === 'yellow' ? 'bg-[#f4b840] text-[#1a1a1a]' :
|
||||
category.color === 'blue' ? 'bg-blue-500 text-white' :
|
||||
category.color === 'purple' ? 'bg-purple-500 text-white' :
|
||||
'bg-green-500 text-white'
|
||||
: 'bg-gray-100 text-gray-700 hover:bg-gray-200'
|
||||
}`}
|
||||
>
|
||||
{category.name}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Privacy Toggle */}
|
||||
<div className="flex items-center justify-between p-4 bg-gray-50 rounded-lg border border-gray-200">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Private Archive</p>
|
||||
<p className="text-sm text-gray-600">Only you can see this post</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIsPrivate(!isPrivate)}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
isPrivate ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
isPrivate ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Submit Button */}
|
||||
<div className="flex gap-3">
|
||||
<button
|
||||
type="button"
|
||||
className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="flex-1 px-4 py-2 bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Post Archive
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
24
frontend/src/pages/Feed.jsx
Normal file
24
frontend/src/pages/Feed.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import AudioPostCard from '../components/AudioPostCard'
|
||||
|
||||
export default function Feed({ posts, onLike, onComment, onShare, onBookmark }) {
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto space-y-6">
|
||||
{posts?.length > 0 ? (
|
||||
posts.map((post) => (
|
||||
<AudioPostCard
|
||||
key={post.id}
|
||||
post={post}
|
||||
onLike={onLike}
|
||||
onComment={onComment}
|
||||
onShare={onShare}
|
||||
onBookmark={onBookmark}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
<div className="text-center py-12">
|
||||
<p className="text-gray-600">No posts to display</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
87
frontend/src/pages/History.jsx
Normal file
87
frontend/src/pages/History.jsx
Normal file
@@ -0,0 +1,87 @@
|
||||
import { FileText, Filter, Trash2 } from 'lucide-react'
|
||||
|
||||
export default function History({ userPosts, onDelete }) {
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto space-y-6">
|
||||
<div className="flex items-center justify-between">
|
||||
<h2 className="text-2xl font-bold text-gray-900">History</h2>
|
||||
<button className="flex items-center gap-2 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors">
|
||||
<Filter size={18} />
|
||||
<span>Filter</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* My Posted Archives */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-6">
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
|
||||
<FileText size={20} />
|
||||
My Posted Archives
|
||||
</h3>
|
||||
|
||||
{userPosts?.length > 0 ? (
|
||||
<div className="space-y-3">
|
||||
{userPosts.map((post) => (
|
||||
<div key={post.id} className="flex items-start gap-4 p-4 hover:bg-gray-50 rounded-lg border border-gray-200">
|
||||
<div className="flex-1 min-w-0">
|
||||
<h4 className="font-semibold text-gray-900 mb-1">{post.title}</h4>
|
||||
<div className="flex items-center gap-3 text-sm text-gray-600 mb-2">
|
||||
<span>{post.createdAt}</span>
|
||||
<span>•</span>
|
||||
<span>{post.duration}</span>
|
||||
<span>•</span>
|
||||
<span className={post.isPrivate ? 'text-gray-500' : 'text-green-600'}>
|
||||
{post.isPrivate ? 'Private' : 'Public'}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-4 text-sm text-gray-500">
|
||||
<span>👍 {post.likes} likes</span>
|
||||
<span>💬 {post.comments} comments</span>
|
||||
<span>🎧 {post.listens} listens</span>
|
||||
</div>
|
||||
{post.categories && (
|
||||
<div className="flex gap-2 mt-2">
|
||||
{post.categories.map((cat, idx) => (
|
||||
<span key={idx} className="text-xs px-2 py-1 bg-gray-100 text-gray-700 rounded">
|
||||
{cat}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<button
|
||||
onClick={() => onDelete?.(post.id)}
|
||||
className="text-red-500 hover:text-red-700 p-2 hover:bg-red-50 rounded transition-colors"
|
||||
title="Delete post"
|
||||
>
|
||||
<Trash2 size={18} />
|
||||
</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-600 text-center py-8">No posts yet. Create your first archive!</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Stats Summary */}
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-4 text-center">
|
||||
<div className="text-2xl font-bold text-gray-900">{userPosts?.length || 0}</div>
|
||||
<div className="text-sm text-gray-600">Total Posts</div>
|
||||
</div>
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-4 text-center">
|
||||
<div className="text-2xl font-bold text-gray-900">
|
||||
{userPosts?.reduce((sum, post) => sum + post.likes, 0) || 0}
|
||||
</div>
|
||||
<div className="text-sm text-gray-600">Total Likes</div>
|
||||
</div>
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-4 text-center">
|
||||
<div className="text-2xl font-bold text-gray-900">
|
||||
{userPosts?.reduce((sum, post) => sum + post.listens, 0) || 0}
|
||||
</div>
|
||||
<div className="text-sm text-gray-600">Total Listens</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
251
frontend/src/pages/Settings.jsx
Normal file
251
frontend/src/pages/Settings.jsx
Normal file
@@ -0,0 +1,251 @@
|
||||
import { useState } from 'react'
|
||||
import { User, Lock, Bell, Globe, Trash2 } from 'lucide-react'
|
||||
|
||||
export default function Settings({ userSettings, onUpdate }) {
|
||||
const [settings, setSettings] = useState(userSettings || {
|
||||
notifications: {
|
||||
newFollowers: true,
|
||||
comments: true,
|
||||
likes: false,
|
||||
mentions: true,
|
||||
},
|
||||
privacy: {
|
||||
profileVisibility: 'public',
|
||||
showListeningHistory: true,
|
||||
allowComments: true,
|
||||
},
|
||||
account: {
|
||||
email: 'john.doe@email.com',
|
||||
username: 'johndoe',
|
||||
}
|
||||
})
|
||||
|
||||
const handleToggle = (category, setting) => {
|
||||
setSettings(prev => ({
|
||||
...prev,
|
||||
[category]: {
|
||||
...prev[category],
|
||||
[setting]: !prev[category][setting]
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl mx-auto space-y-6">
|
||||
<h2 className="text-2xl font-bold text-gray-900">Settings</h2>
|
||||
|
||||
{/* Account Settings */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-6">
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
|
||||
<User size={20} />
|
||||
Account Information
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">Username</label>
|
||||
<input
|
||||
type="text"
|
||||
value={settings.account.username}
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">Email</label>
|
||||
<input
|
||||
type="email"
|
||||
value={settings.account.email}
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-900 mb-2">Bio</label>
|
||||
<textarea
|
||||
rows={3}
|
||||
placeholder="Tell us about yourself..."
|
||||
className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#f4b840] focus:border-transparent resize-none"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Privacy Settings */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-6">
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
|
||||
<Lock size={20} />
|
||||
Privacy
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Profile Visibility</p>
|
||||
<p className="text-sm text-gray-600">Who can see your profile</p>
|
||||
</div>
|
||||
<select className="px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-[#f4b840]">
|
||||
<option value="public">Public</option>
|
||||
<option value="followers">Followers Only</option>
|
||||
<option value="private">Private</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Show Listening History</p>
|
||||
<p className="text-sm text-gray-600">Allow others to see what you've listened to</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('privacy', 'showListeningHistory')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.privacy.showListeningHistory ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.privacy.showListeningHistory ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Allow Comments</p>
|
||||
<p className="text-sm text-gray-600">Let others comment on your posts</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('privacy', 'allowComments')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.privacy.allowComments ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.privacy.allowComments ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Notification Settings */}
|
||||
<div className="bg-white rounded-lg border border-gray-200 p-6">
|
||||
<h3 className="text-lg font-semibold text-gray-900 mb-4 flex items-center gap-2">
|
||||
<Bell size={20} />
|
||||
Notifications
|
||||
</h3>
|
||||
|
||||
<div className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">New Followers</p>
|
||||
<p className="text-sm text-gray-600">When someone follows you</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('notifications', 'newFollowers')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.notifications.newFollowers ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.notifications.newFollowers ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Comments</p>
|
||||
<p className="text-sm text-gray-600">When someone comments on your post</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('notifications', 'comments')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.notifications.comments ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.notifications.comments ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Likes</p>
|
||||
<p className="text-sm text-gray-600">When someone likes your post</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('notifications', 'likes')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.notifications.likes ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.notifications.likes ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<p className="font-medium text-gray-900">Mentions</p>
|
||||
<p className="text-sm text-gray-600">When someone mentions you</p>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => handleToggle('notifications', 'mentions')}
|
||||
className={`relative w-12 h-6 rounded-full transition-colors ${
|
||||
settings.notifications.mentions ? 'bg-[#f4b840]' : 'bg-gray-300'
|
||||
}`}
|
||||
>
|
||||
<div
|
||||
className={`absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform ${
|
||||
settings.notifications.mentions ? 'translate-x-6' : 'translate-x-0'
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Danger Zone */}
|
||||
<div className="bg-white rounded-lg border border-red-200 p-6">
|
||||
<h3 className="text-lg font-semibold text-red-600 mb-4 flex items-center gap-2">
|
||||
<Trash2 size={20} />
|
||||
Danger Zone
|
||||
</h3>
|
||||
|
||||
<div className="space-y-3">
|
||||
<button className="w-full px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 transition-colors">
|
||||
Export My Data
|
||||
</button>
|
||||
<button className="w-full px-4 py-2 bg-red-500 hover:bg-red-600 text-white rounded-lg transition-colors">
|
||||
Delete Account
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Save Button */}
|
||||
<div className="flex gap-3">
|
||||
<button className="flex-1 px-4 py-2 border border-gray-300 rounded-lg text-gray-700 hover:bg-gray-50 transition-colors">
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
onClick={() => onUpdate?.(settings)}
|
||||
className="flex-1 px-4 py-2 bg-[#f4b840] hover:bg-[#e5a930] text-[#1a1a1a] rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
9
frontend/vite.config.js
Normal file
9
frontend/vite.config.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from '@tailwindcss/vite'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react(),
|
||||
tailwindcss()],
|
||||
})
|
||||
Reference in New Issue
Block a user