import React, { useState, useEffect } from 'react'; import { Link } from 'react-router-dom'; import axios from 'axios'; import { ArrowRight, Truck, Shield, Headphones, Wrench, Laptop, Smartphone, Watch } from 'lucide-react'; import { Button } from '../components/ui/button'; import { Badge } from '../components/ui/badge'; import ProductCard from '../components/cards/ProductCard'; import ServiceCard from '../components/cards/ServiceCard'; const API = `${process.env.REACT_APP_BACKEND_URL}/api`; const Home = () => { const [featuredProducts, setFeaturedProducts] = useState([]); const [featuredServices, setFeaturedServices] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { const fetchData = async () => { try { // Seed data first await axios.post(`${API}/seed`); const [productsRes, servicesRes] = await Promise.all([ axios.get(`${API}/products`), axios.get(`${API}/services`) ]); setFeaturedProducts(productsRes.data.slice(0, 4)); setFeaturedServices(servicesRes.data.slice(0, 3)); } catch (error) { console.error('Failed to fetch data:', error); } finally { setLoading(false); } }; fetchData(); }, []); const features = [ { icon: Truck, title: 'Free Shipping', desc: 'On orders over $100' }, { icon: Shield, title: 'Warranty', desc: '1 Year manufacturer warranty' }, { icon: Headphones, title: '24/7 Support', desc: 'Expert assistance anytime' }, { icon: Wrench, title: 'Expert Repair', desc: 'Certified technicians' }, ]; const categories = [ { icon: Smartphone, name: 'Phones', link: '/products?category=phones' }, { icon: Laptop, name: 'Laptops', link: '/products?category=laptops' }, { icon: Watch, name: 'Wearables', link: '/products?category=wearables' }, ]; return (
Discover the latest electronics and get professional repair services. Quality products, trusted solutions for all your tech needs.
Starting from
$99.99
{feature.title}
{feature.desc}
Browse our wide selection of premium electronics
Handpicked selection of our best-selling items
Professional tech support and repair services
Our certified technicians are ready to help you with any tech problem. From repairs to upgrades, we've got you covered.