import React from 'react';
import { useAuth } from '@/client/home/hooks/AuthProvider';
import { useNavigate } from 'react-router-dom';

const HomePage: React.FC = () => {
  const { user } = useAuth();
  const navigate = useNavigate();

  return (
    <div className="min-h-screen bg-gray-50 flex flex-col">
      {/* 顶部导航 */}
      <header className="bg-blue-600 text-white shadow-md fixed w-full z-10">
        <div className="container mx-auto px-4 py-3 flex justify-between items-center">
          <h1 className="text-xl font-bold">网站首页</h1>
          {user ? (
            <div className="flex items-center space-x-4">
              <div className="flex items-center cursor-pointer" onClick={() => navigate(`/member`)}>
                <div className="w-8 h-8 rounded-full bg-white text-blue-600 flex items-center justify-center mr-2">
                  <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                    <path fillRule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clipRule="evenodd" />
                  </svg>
                </div>
                <span className="hidden md:inline">{user.username}</span>
              </div>
            </div>
          ) : (
            <div className="flex space-x-2">
              <button
                onClick={() => navigate('/login')}
                className="px-4 py-2 rounded text-sm bg-white text-blue-600 hover:bg-blue-50 transition-colors duration-200"
              >
                登录
              </button>
              <button
                onClick={() => navigate('/register')}
                className="px-4 py-2 rounded text-sm bg-blue-500 text-white hover:bg-blue-600 transition-colors duration-200"
              >
                免费试用
              </button>
            </div>
          )}
        </div>
      </header>
      
      {/* 主内容区 */}
      <main className="flex-grow container mx-auto px-4 pt-24 pb-12">
        <div className="bg-white rounded-lg shadow-sm p-6 md:p-8">
          <h2 className="text-3xl font-bold text-gray-900 mb-4">智能客户关系管理系统</h2>
          <p className="text-gray-600 mb-6 text-lg">
            一站式客户管理解决方案，帮助您高效管理客户资源、跟踪销售机会，
            提升转化率和客户满意度。
          </p>
          <div className="mb-8">
            <a
              href="/admin"
              className="inline-flex items-center px-5 py-2.5 rounded-md text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 transition-colors duration-200 shadow-sm"
            >
              <svg xmlns="http://www.w3.org/2000/svg" className="h-4 w-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 7a4 4 0 11-8 0 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
              </svg>
              管理后台入口
            </a>
          </div>
          
          <div className="grid grid-cols-1 md:grid-cols-3 gap-6 mt-8">
            <div className="bg-blue-50 p-6 rounded-lg text-center shadow-sm transition-all duration-300 hover:shadow-md hover:-translate-y-1">
              <div className="w-14 h-14 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-7 w-7 text-blue-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z" />
                </svg>
              </div>
              <h3 className="font-semibold text-lg mb-2 text-blue-700">客户管理</h3>
              <p className="text-gray-600 text-sm">集中管理客户信息，建立完整客户档案，提升客户关系维护效率</p>
            </div>
            
            <div className="bg-green-50 p-6 rounded-lg text-center shadow-sm transition-all duration-300 hover:shadow-md hover:-translate-y-1">
              <div className="w-14 h-14 bg-green-100 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-7 w-7 text-green-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" />
                </svg>
              </div>
              <h3 className="font-semibold text-lg mb-2 text-green-700">销售机会跟踪</h3>
              <p className="text-gray-600 text-sm">全流程销售机会管理，从初步接触到成交转化的完整跟踪体系</p>
            </div>
            
            <div className="bg-purple-50 p-6 rounded-lg text-center shadow-sm transition-all duration-300 hover:shadow-md hover:-translate-y-1">
              <div className="w-14 h-14 bg-purple-100 rounded-full flex items-center justify-center mx-auto mb-4">
                <svg xmlns="http://www.w3.org/2000/svg" className="h-7 w-7 text-purple-600" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                  <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
                </svg>
              </div>
              <h3 className="font-semibold text-lg mb-2 text-purple-700">数据分析报表</h3>
              <p className="text-gray-600 text-sm">直观的数据可视化报表，帮助您深入了解业务状况和销售趋势</p>
            </div>
          </div>
        </div>
      </main>
      
      {/* 页脚 */}
      <footer className="bg-white border-t border-gray-200 py-4">
        <div className="container mx-auto px-4 text-center text-gray-500 text-sm">
          网站模板 ©{new Date().getFullYear()} Created with React & Tailwind CSS
          <div className="mt-2 space-x-4">
            <a href="/ui" className="text-blue-600 hover:underline">Api</a>
          </div>
        </div>
      </footer>
    </div>
  );
};

export default HomePage;