<?php
session_start();

// Check if user is logged in
if (!isset($_SESSION['user'])) {
    header('Location: signin.php');
    exit();
}

$user = $_SESSION['user'];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Home - Urban Halal</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #f8f9fa;
        }
        .home-container {
            max-width: 800px;
            margin: 50px auto;
            padding: 20px;
            background: white;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .user-info {
            margin-bottom: 20px;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 5px;
        }
        .token-box {
            margin: 20px 0;
            padding: 15px;
            background: #e9ecef;
            border-radius: 5px;
            word-break: break-all;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="home-container">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <h2>Welcome, <?php echo htmlspecialchars($user['full_name']); ?>!</h2>
                <a href="signout.php" class="btn btn-danger">Sign Out</a>
            </div>
            
            <div class="user-info">
                <h4>User Information</h4>
                <p><strong>Username:</strong> <?php echo htmlspecialchars($user['username']); ?></p>
                <p><strong>Email:</strong> <?php echo htmlspecialchars($user['email']); ?></p>
                <p><strong>Full Name:</strong> <?php echo htmlspecialchars($user['full_name']); ?></p>
            </div>
            
            <div class="token-box">
                <h4>Your Token</h4>
                <p><strong>User ID:</strong> <?php echo htmlspecialchars($user['num']); ?></p>
                <p><strong>JWT Token:</strong> <span id="jwt-token">Loading...</span></p>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Show JWT token from localStorage
        document.addEventListener('DOMContentLoaded', function() {
            var token = localStorage.getItem('jwt_token');
            document.getElementById('jwt-token').textContent = token ? token : 'Not found';
        });
    </script>
</body>
</html> 