File size: 68,113 Bytes
d8b1d97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin Dashboard - WebWizard</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/react@18/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<style>
.sidebar {
transition: all 0.3s;
}
.dashboard-card:hover {
transform: translateY(-3px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
</style>
</head>
<body class="bg-gray-100">
<div id="root"></div>
<script type="text/babel">
const { useState, useEffect } = React;
function AdminDashboard() {
const [activeTab, setActiveTab] = useState('dashboard');
const [sidebarOpen, setSidebarOpen] = useState(true);
const [users, setUsers] = useState([]);
const [products, setProducts] = useState([]);
const [books, setBooks] = useState([]);
const [websites, setWebsites] = useState([]);
const [managers, setManagers] = useState([]);
// Simulate data fetching
useEffect(() => {
// Fake data
setUsers([
{ id: 1, name: 'John Doe', email: 'john@example.com', role: 'user', joined: '2023-01-15' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com', role: 'user', joined: '2023-02-20' },
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com', role: 'user', joined: '2023-03-10' }
]);
setManagers([
{ id: 1, name: 'Admin User', email: 'admin@example.com', role: 'admin', permissions: 'full' },
{ id: 2, name: 'Content Manager', email: 'content@example.com', role: 'manager', permissions: 'content' }
]);
setProducts([
{ id: 1, name: 'Wireless Headphones', price: 199.99, category: 'Electronics', stock: 45, discount: 15 },
{ id: 2, name: 'Mechanical Keyboard', price: 89.99, category: 'Accessories', stock: 32, discount: 0 }
]);
setBooks([
{ id: 1, title: 'Clean Code', author: 'Robert Martin', price: 29.99, category: 'Programming', stock: 20, discount: 10 },
{ id: 2, title: 'Design Patterns', author: 'Erich Gamma', price: 39.99, category: 'Programming', stock: 15, discount: 0 }
]);
setWebsites([
{ id: 1, name: 'React Docs', url: 'https://reactjs.org', category: 'Development', description: 'Official React documentation' },
{ id: 2, name: 'Tailwind CSS', url: 'https://tailwindcss.com', category: 'Development', description: 'Utility-first CSS framework' }
]);
}, []);
const deleteItem = (type, id) => {
// In a real app, you would make an API call here
switch(type) {
case 'user':
setUsers(users.filter(u => u.id !== id));
break;
case 'manager':
setManagers(managers.filter(m => m.id !== id));
break;
case 'product':
setProducts(products.filter(p => p.id !== id));
break;
case 'book':
setBooks(books.filter(b => b.id !== id));
break;
case 'website':
setWebsites(websites.filter(w => w.id !== id));
break;
}
};
return (
<div className="flex h-screen overflow-hidden">
{/* Sidebar */}
<div className={`sidebar bg-blue-800 text-white ${sidebarOpen ? 'w-64' : 'w-20'} transition-all duration-300`}>
<div className="flex items-center justify-between p-4 border-b border-blue-700">
{sidebarOpen ? (
<h1 className="text-xl font-bold">WebWizard Admin</h1>
) : (
<i className="fas fa-hat-wizard text-2xl ml-1"></i>
)}
<button onClick={() => setSidebarOpen(!sidebarOpen)} className="text-white">
<i className={`fas ${sidebarOpen ? 'fa-times' : 'fa-bars'}`}></i>
</button>
</div>
<nav className="p-4">
<ul className="space-y-2">
<li>
<button
onClick={() => setActiveTab('dashboard')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'dashboard' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-tachometer-alt mr-3"></i>
{sidebarOpen && <span>Dashboard</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('users')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'users' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-users mr-3"></i>
{sidebarOpen && <span>Users</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('managers')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'managers' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-user-shield mr-3"></i>
{sidebarOpen && <span>Managers</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('products')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'products' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-shopping-bag mr-3"></i>
{sidebarOpen && <span>Products</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('books')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'books' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-book mr-3"></i>
{sidebarOpen && <span>Books</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('websites')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'websites' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-globe mr-3"></i>
{sidebarOpen && <span>Websites</span>}
</button>
</li>
<li>
<button
onClick={() => setActiveTab('settings')}
className={`w-full text-left flex items-center p-3 rounded-lg ${activeTab === 'settings' ? 'bg-blue-700' : 'hover:bg-blue-700'}`}
>
<i className="fas fa-cog mr-3"></i>
{sidebarOpen && <span>Settings</span>}
</button>
</li>
</ul>
</nav>
</div>
{/* Main Content */}
<div className="flex-1 overflow-y-auto">
{/* Top Navigation */}
<header className="bg-white shadow-sm py-4 px-6 flex items-center justify-between sticky top-0 z-10">
<div className="flex items-center">
<h2 className="text-xl font-semibold text-gray-800 capitalize">
{activeTab === 'dashboard' ? 'Admin Dashboard' : activeTab}
</h2>
</div>
<div className="flex items-center space-x-4">
<div className="relative">
<input
type="text"
placeholder="Search..."
className="py-2 px-4 rounded-full border border-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-300"
/>
</div>
<div className="flex items-center space-x-2">
<div className="w-10 h-10 rounded-full bg-blue-500 flex items-center justify-center text-white">
<i className="fas fa-user"></i>
</div>
<span className="hidden md:inline">Admin</span>
</div>
</div>
</header>
{/* Dashboard Content */}
<main className="p-6">
{activeTab === 'dashboard' && (
<div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
<div className="dashboard-card bg-white rounded-xl p-6 shadow-md border border-gray-100 transition-all duration-300">
<div className="flex justify-between items-center">
<div>
<p className="text-gray-500 text-sm">Total Users</p>
<h3 className="text-2xl font-bold text-gray-800">1,248</h3>
<p className="text-green-500 text-sm mt-1">+12% from last month</p>
</div>
<div className="bg-blue-100 p-3 rounded-full">
<i className="fas fa-users text-blue-500 text-xl"></i>
</div>
</div>
</div>
<div className="dashboard-card bg-white rounded-xl p-6 shadow-md border border-gray-100 transition-all duration-300">
<div className="flex justify-between items-center">
<div>
<p className="text-gray-500 text-sm">Total Products</p>
<h3 className="text-2xl font-bold text-gray-800">356</h3>
<p className="text-green-500 text-sm mt-1">+8% from last month</p>
</div>
<div className="bg-purple-100 p-3 rounded-full">
<i className="fas fa-shopping-bag text-purple-500 text-xl"></i>
</div>
</div>
</div>
<div className="dashboard-card bg-white rounded-xl p-6 shadow-md border border-gray-100 transition-all duration-300">
<div className="flex justify-between items-center">
<div>
<p className="text-gray-500 text-sm">Total Books</p>
<h3 className="text-2xl font-bold text-gray-800">189</h3>
<p className="text-green-500 text-sm mt-1">+5% from last month</p>
</div>
<div className="bg-green-100 p-3 rounded-full">
<i className="fas fa-book text-green-500 text-xl"></i>
</div>
</div>
</div>
<div className="dashboard-card bg-white rounded-xl p-6 shadow-md border border-gray-100 transition-all duration-300">
<div className="flex justify-between items-center">
<div>
<p className="text-gray-500 text-sm">Total Websites</p>
<h3 className="text-2xl font-bold text-gray-800">872</h3>
<p className="text-green-500 text-sm mt-1">+22% from last month</p>
</div>
<div className="bg-yellow-100 p-3 rounded-full">
<i className="fas fa-globe text-yellow-500 text-xl"></i>
</div>
</div>
</div>
</div>
<div className="bg-white rounded-xl p-6 shadow-md border border-gray-100 mb-6">
<div className="flex justify-between items-center mb-6">
<h3 className="text-lg font-semibold text-gray-800">Recent Activity</h3>
<button className="text-blue-500 text-sm">View All</button>
</div>
<div className="space-y-4">
<div className="flex items-start">
<div className="bg-blue-100 p-2 rounded-full mr-3">
<i className="fas fa-user-plus text-blue-500 text-sm"></i>
</div>
<div>
<p className="text-sm text-gray-700"><span className="font-medium">New user</span> registered - johndoe@example.com</p>
<p className="text-xs text-gray-500 mt-1">10 minutes ago</p>
</div>
</div>
<div className="flex items-start">
<div className="bg-purple-100 p-2 rounded-full mr-3">
<i className="fas fa-shopping-cart text-purple-500 text-sm"></i>
</div>
<div>
<p className="text-sm text-gray-700"><span className="font-medium">New product</span> added - Wireless Earbuds</p>
<p className="text-xs text-gray-500 mt-1">1 hour ago</p>
</div>
</div>
<div className="flex items-start">
<div className="bg-green-100 p-2 rounded-full mr-3">
<i className="fas fa-book text-green-500 text-sm"></i>
</div>
<div>
<p className="text-sm text-gray-700"><span className="font-medium">New book</span> added - Clean Architecture</p>
<p className="text-xs text-gray-500 mt-1">2 hours ago</p>
</div>
</div>
</div>
</div>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div className="bg-white rounded-xl p-6 shadow-md border border-gray-100">
<h3 className="text-lg font-semibold text-gray-800 mb-4">Quick Actions</h3>
<div className="grid grid-cols-2 gap-4">
<button className="bg-blue-50 hover:bg-blue-100 text-blue-600 p-4 rounded-lg flex flex-col items-center justify-center">
<i className="fas fa-plus-circle text-xl mb-2"></i>
<span className="text-sm">Add User</span>
</button>
<button className="bg-purple-50 hover:bg-purple-100 text-purple-600 p-4 rounded-lg flex flex-col items-center justify-center">
<i className="fas fa-shopping-bag text-xl mb-2"></i>
<span className="text-sm">Add Product</span>
</button>
<button className="bg-green-50 hover:bg-green-100 text-green-600 p-4 rounded-lg flex flex-col items-center justify-center">
<i className="fas fa-book text-xl mb-2"></i>
<span className="text-sm">Add Book</span>
</button>
<button className="bg-yellow-50 hover:bg-yellow-100 text-yellow-600 p-4 rounded-lg flex flex-col items-center justify-center">
<i className="fas fa-globe text-xl mb-2"></i>
<span className="text-sm">Add Website</span>
</button>
</div>
</div>
<div className="bg-white rounded-xl p-6 shadow-md border border-gray-100">
<h3 className="text-lg font-semibold text-gray-800 mb-4">System Status</h3>
<div className="space-y-3">
<div>
<div className="flex justify-between mb-1">
<span className="text-sm font-medium text-gray-700">Storage</span>
<span className="text-sm text-gray-500">45% used</span>
</div>
<div className="w-full bg-gray-200 rounded-full h-2.5">
<div className="bg-blue-600 h-2.5 rounded-full" style={{width: '45%'}}></div>
</div>
</div>
<div>
<div className="flex justify-between mb-1">
<span className="text-sm font-medium text-gray-700">Memory</span>
<span className="text-sm text-gray-500">78% used</span>
</div>
<div className="w-full bg-gray-200 rounded-full h-2.5">
<div className="bg-purple-600 h-2.5 rounded-full" style={{width: '78%'}}></div>
</div>
</div>
<div>
<div className="flex justify-between mb-1">
<span className="text-sm font-medium text-gray-700">CPU</span>
<span className="text-sm text-gray-500">32% used</span>
</div>
<div className="w-full bg-gray-200 rounded-full h-2.5">
<div className="bg-green-600 h-2.5 rounded-full" style={{width: '32%'}}></div>
</div>
</div>
</div>
</div>
</div>
</div>
)}
{activeTab === 'users' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden">
<div className="p-6 flex justify-between items-center border-b border-gray-200">
<h3 className="text-lg font-semibold text-gray-800">User Management</h3>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium">
<i className="fas fa-plus mr-2"></i> Add User
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Joined</th>
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{users.map((user) => (
<tr key={user.id}>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-500">
<i className="fas fa-user"></i>
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">{user.name}</div>
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{user.email}</td>
<td className="px-6 py-4 whitespace-nowrap">
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">{user.role}</span>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{user.joined}</td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button className="text-blue-500 hover:text-blue-700 mr-3">
<i className="fas fa-edit"></i>
</button>
<button
onClick={() => deleteItem('user', user.id)}
className="text-red-500 hover:text-red-700"
>
<i className="fas fa-trash"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between">
<div className="text-sm text-gray-500">
Showing <span className="font-medium">1</span> to <span className="font-medium">10</span> of <span className="font-medium">20</span> results
</div>
<div className="flex space-x-2">
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Previous</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600">1</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">2</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">3</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Next</button>
</div>
</div>
</div>
)}
{activeTab === 'managers' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden">
<div className="p-6 flex justify-between items-center border-b border-gray-200">
<h3 className="text-lg font-semibold text-gray-800">Manager Management</h3>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium">
<i className="fas fa-plus mr-2"></i> Add Manager
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Permissions</th>
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{managers.map((manager) => (
<tr key={manager.id}>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="flex-shrink-0 h-10 w-10 rounded-full bg-purple-100 flex items-center justify-center text-purple-500">
<i className="fas fa-user-shield"></i>
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">{manager.name}</div>
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{manager.email}</td>
<td className="px-6 py-4 whitespace-nowrap">
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-purple-100 text-purple-800">{manager.role}</span>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 capitalize">{manager.permissions}</td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button className="text-blue-500 hover:text-blue-700 mr-3">
<i className="fas fa-edit"></i>
</button>
<button
onClick={() => deleteItem('manager', manager.id)}
className="text-red-500 hover:text-red-700"
>
<i className="fas fa-trash"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between">
<div className="text-sm text-gray-500">
Showing <span className="font-medium">1</span> to <span className="font-medium">10</span> of <span className="font-medium">20</span> results
</div>
<div className="flex space-x-2">
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Previous</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600">1</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">2</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">3</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Next</button>
</div>
</div>
</div>
)}
{activeTab === 'products' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden">
<div className="p-6 flex justify-between items-center border-b border-gray-200">
<h3 className="text-lg font-semibold text-gray-800">Product Management</h3>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium">
<i className="fas fa-plus mr-2"></i> Add Product
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Product</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Price</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stock</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Discount</th>
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{products.map((product) => (
<tr key={product.id}>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="flex-shrink-0 h-10 w-10">
<img className="h-10 w-10 rounded-full" src={`http://static.photos/products/200x200/${product.id}`} alt="" />
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">{product.name}</div>
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${product.price.toFixed(2)}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 capitalize">{product.category}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{product.stock}</td>
<td className="px-6 py-4 whitespace-nowrap">
{product.discount > 0 ? (
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">{product.discount}% off</span>
) : (
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">None</span>
)}
</td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button className="text-blue-500 hover:text-blue-700 mr-3">
<i className="fas fa-edit"></i>
</button>
<button
onClick={() => deleteItem('product', product.id)}
className="text-red-500 hover:text-red-700"
>
<i className="fas fa-trash"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between">
<div className="text-sm text-gray-500">
Showing <span className="font-medium">1</span> to <span className="font-medium">10</span> of <span className="font-medium">20</span> results
</div>
<div className="flex space-x-2">
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Previous</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600">1</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">2</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">3</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Next</button>
</div>
</div>
</div>
)}
{activeTab === 'books' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden">
<div className="p-6 flex justify-between items-center border-b border-gray-200">
<h3 className="text-lg font-semibold text-gray-800">Book Management</h3>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium">
<i className="fas fa-plus mr-2"></i> Add Book
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Book</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Author</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Price</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Stock</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Discount</th>
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{books.map((book) => (
<tr key={book.id}>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="flex-shrink-0 h-10 w-10">
<img className="h-10 w-10 rounded" src={`http://static.photos/books/200x200/${book.id}`} alt="" />
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">{book.title}</div>
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{book.author}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${book.price.toFixed(2)}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 capitalize">{book.category}</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{book.stock}</td>
<td className="px-6 py-4 whitespace-nowrap">
{book.discount > 0 ? (
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">{book.discount}% off</span>
) : (
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-gray-100 text-gray-800">None</span>
)}
</td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button className="text-blue-500 hover:text-blue-700 mr-3">
<i className="fas fa-edit"></i>
</button>
<button
onClick={() => deleteItem('book', book.id)}
className="text-red-500 hover:text-red-700"
>
<i className="fas fa-trash"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between">
<div className="text-sm text-gray-500">
Showing <span className="font-medium">1</span> to <span className="font-medium">10</span> of <span className="font-medium">20</span> results
</div>
<div className="flex space-x-2">
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Previous</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600">1</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">2</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">3</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Next</button>
</div>
</div>
</div>
)}
{activeTab === 'websites' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 overflow-hidden">
<div className="p-6 flex justify-between items-center border-b border-gray-200">
<h3 className="text-lg font-semibold text-gray-800">Website Management</h3>
<button className="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg text-sm font-medium">
<i className="fas fa-plus mr-2"></i> Add Website
</button>
</div>
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="bg-gray-50">
<tr>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">URL</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Category</th>
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Description</th>
<th scope="col" className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody className="bg-white divide-y divide-gray-200">
{websites.map((website) => (
<tr key={website.id}>
<td className="px-6 py-4 whitespace-nowrap">
<div className="flex items-center">
<div className="flex-shrink-0 h-10 w-10 rounded-full bg-blue-100 flex items-center justify-center text-blue-500">
<i className="fas fa-globe"></i>
</div>
<div className="ml-4">
<div className="text-sm font-medium text-gray-900">{website.name}</div>
</div>
</div>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-blue-500">
<a href={website.url} target="_blank" rel="noopener noreferrer">{website.url}</a>
</td>
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500 capitalize">{website.category}</td>
<td className="px-6 py-4 text-sm text-gray-500">{website.description}</td>
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<button className="text-blue-500 hover:text-blue-700 mr-3">
<i className="fas fa-edit"></i>
</button>
<button
onClick={() => deleteItem('website', website.id)}
className="text-red-500 hover:text-red-700"
>
<i className="fas fa-trash"></i>
</button>
</td>
</tr>
))}
</tbody>
</table>
</div>
<div className="px-6 py-4 border-t border-gray-200 flex items-center justify-between">
<div className="text-sm text-gray-500">
Showing <span className="font-medium">1</span> to <span className="font-medium">10</span> of <span className="font-medium">20</span> results
</div>
<div className="flex space-x-2">
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Previous</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600">1</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">2</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">3</button>
<button className="px-3 py-1 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50">Next</button>
</div>
</div>
</div>
)}
{activeTab === 'settings' && (
<div className="bg-white rounded-xl shadow-md border border-gray-100 p-6">
<h3 className="text-lg font-semibold text-gray-800 mb-6">Settings</h3>
<div className="space-y-8">
<div>
<h4 className="text-md font-medium text-gray-800 mb-4">General Settings</h4>
<div className="space-y-4">
<div className="flex items-center justify-between">
<div>
<label htmlFor="site-name" className="block text-sm font-medium text-gray-700 mb-1">Site Name</label>
<p className="text-xs text-gray-500">The name of your application</p>
</div>
<input
type="text"
id="site-name"
defaultValue="WebWizard"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
/>
</div>
<div className="flex items-center justify-between">
<div>
<label htmlFor="site-url" className="block text-sm font-medium text-gray-700 mb-1">Site URL</label>
<p className="text-xs text-gray-500">The base URL of your application</p>
</div>
<input
type="text"
id="site-url"
defaultValue="https://webwizard.app"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
/>
</div>
<div className="flex items-center justify-between">
<div>
<label htmlFor="timezone" className="block text-sm font-medium text-gray-700 mb-1">Timezone</label>
<p className="text-xs text-gray-500">The default timezone for your application</p>
</div>
<select
id="timezone"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
>
<option>(UTC-12:00) International Date Line West</option>
<option>(UTC-08:00) Pacific Time (US & Canada)</option>
<option selected>(UTC+00:00) Coordinated Universal Time</option>
</select>
</div>
</div>
</div>
<div>
<h4 className="text-md font-medium text-gray-800 mb-4">Security Settings</h4>
<div className="space-y-4">
<div className="flex items-center justify-between">
<div>
<label htmlFor="password-policy" className="block text-sm font-medium text-gray-700 mb-1">Password Policy</label>
<p className="text-xs text-gray-500">Minimum requirements for user passwords</p>
</div>
<select
id="password-policy"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
>
<option>Low (6 characters minimum)</option>
<option selected>Medium (8 characters, 1 number)</option>
<option>Strong (10 characters, 1 number, 1 special)</option>
</select>
</div>
<div className="flex items-center justify-between">
<div>
<label htmlFor="login-attempts" className="block text-sm font-medium text-gray-700 mb-1">Failed Login Attempts</label>
<p className="text-xs text-gray-500">Number of attempts before lockout</p>
</div>
<select
id="login-attempts"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
>
<option>3 attempts</option>
<option selected>5 attempts</option>
<option>10 attempts</option>
</select>
</div>
<div className="flex items-center justify-between">
<div>
<label htmlFor="lockout-duration" className="block text-sm font-medium text-gray-700 mb-1">Lockout Duration</label>
<p className="text-xs text-gray-500">How long to lock accounts after failed attempts</p>
</div>
<select
id="lockout-duration"
className="w-64 px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-300"
>
<option>5 minutes</option>
<option selected>15 minutes</option>
<option>30 minutes</option>
<option>1 hour</option>
</select>
</div>
</div>
</div>
<div className="flex justify-end">
<button className="bg-blue-500 hover:bg-blue-600 text-white px-6 py-2 rounded-lg">
Save Settings
</button>
</div>
</div>
</div>
)}
</main>
</div>
</div>
);
}
ReactDOM.render(<AdminDashboard />, document.getElementById('root'));
</script>
</body>
</html> |