067f5a5
| 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 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cosmetic Management System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
colors: {
primary: {
50: '#fef2f2',
100: '#fee2e2',
200: '#fecaca',
300: '#fca5a5',
400: '#f87171',
500: '#ef4444',
600: '#dc2626',
700: '#b91c1c',
800: '#991b1b',
900: '#7f1d1d',
}
}
}
}
}
</script>
<style>
* {
box-sizing: border-box;
}
html, body {
margin: 0;
padding: 0;
height: 100%;
overflow-x: hidden;
}
body {
font-family: 'Inter', sans-serif;
background: #f8fafc;
}
.glass-panel {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.2);
}
.gradient-bg {
background: linear-gradient(135deg, #fef2f2 0%, #fff 50%, #f0fdf4 100%);
}
.animate-fade-in {
animation: fadeIn 0.3s ease-out;
}
.animate-slide-up {
animation: slideUp 0.4s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
.hover-lift {
transition: transform 0.2s, box-shadow 0.2s;
}
.hover-lift:hover {
transform: translateY(-2px);
box-shadow: 0 10px 40px -10px rgba(0,0,0,0.1);
}
.status-badge {
@apply px-3 py-1 rounded-full text-xs font-medium;
}
.status-draft { @apply bg-gray-100 text-gray-700; }
.status-pending { @apply bg-yellow-100 text-yellow-700; }
.status-approved { @apply bg-green-100 text-green-700; }
.status-rejected { @apply bg-red-100 text-red-700; }
.sidebar-item {
@apply flex items-center gap-3 px-4 py-3 rounded-lg transition-all cursor-pointer;
}
.sidebar-item:hover {
@apply bg-primary-50 text-primary-700;
}
.sidebar-item.active {
@apply bg-primary-600 text-white;
}
.form-input {
@apply w-full px-4 py-3 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent transition-all;
}
.btn-primary {
@apply px-6 py-3 bg-primary-600 text-white rounded-lg font-medium hover:bg-primary-700 transition-all flex items-center gap-2;
}
.btn-secondary {
@apply px-6 py-3 bg-gray-100 text-gray-700 rounded-lg font-medium hover:bg-gray-200 transition-all flex items-center gap-2;
}
.card {
@apply bg-white rounded-xl shadow-sm border border-gray-100 p-6 hover-lift;
}
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
.loading-spinner {
@apply animate-spin rounded-full h-5 w-5 border-2 border-white border-t-transparent;
}
.modal-overlay {
@apply fixed inset-0 bg-black/50 backdrop-blur-sm z-50 flex items-center justify-center p-4;
}
.modal-content {
@apply bg-white rounded-2xl shadow-2xl max-w-2xl w-full max-h-[90vh] overflow-hidden animate-slide-up;
}
</style>
</head>
<body class="gradient-bg">
<div id="app" class="min-h-screen">
</div>
<script>
// ============================================
// COSMETIC MANAGEMENT SYSTEM - MAIN APPLICATION
// ============================================
// State Management
const AppState = {
currentUser: null,
currentView: 'login',
companies: [
{
id: 'comp-001',
name: 'Luxe Beauty International',
brandNames: ['LuxeBeauty', 'PureGlow'],
legalEntity: 'Luxe Beauty Holdings Ltd',
country: 'United Kingdom',
responsiblePerson: 'Dr. Sarah Mitchell',
contactEmail: 'compliance@luxebeauty.com',
contactPhone: '+44 20 7946 0958',
logo: null,
createdAt: '2023-01-15'
},
{
id: 'comp-002',
name: 'Natura Organics GmbH',
brandNames: ['NaturaBio', 'EcoSkin'],
legalEntity: 'Natura Organics GmbH',
country: 'Germany',
responsiblePerson: 'Hans Weber',
contactEmail: 'regulatory@natura-organics.de',
contactPhone: '+49 30 2758 4920',
logo: null,
createdAt: '2023-03-22'
}
],
users: [
{
id: 'user-001',
email: 'admin@cms.com',
password: 'admin123',
name: 'System Administrator',
role: 'admin',
companyId: null,
isActive: true,
lastLogin: null
},
{
id: 'user-002',
email: 'sarah.mitchell@luxebeauty.com',
password: 'manager123',
name: 'Dr. Sarah Mitchell',
role: 'manager',
companyId: 'comp-001',
isActive: true,
lastLogin: '2024-01-15T09:30:00Z'
},
{
id: 'user-003',
email: 'editor@luxebeauty.com',
password: 'editor123',
name: 'Emma Thompson',
role: 'editor',
companyId: 'comp-001',
isActive: true,
lastLogin: '2024-01-14T16:45:00Z'
},
{
id: 'user-004',
email: 'viewer@luxebeauty.com',
password: 'viewer123',
name: 'James Wilson',
role: 'viewer',
companyId: 'comp-001',
isActive: true,
lastLogin: '2024-01-13T11:20:00Z'
},
{
id: 'user-005',
email: 'confirmer@cms.com',
password: 'confirm123',
name: 'Maria Rodriguez',
role: 'confirmer',
companyId: null,
isActive: true,
lastLogin: '2024-01-15T08:00:00Z'
},
{
id: 'user-006',
email: 'hans.weber@natura-organics.de',
password: 'manager123',
name: 'Hans Weber',
role: 'manager',
companyId: 'comp-002',
isActive: true,
lastLogin: '2024-01-14T14:30:00Z'
}
],
products: [
{
id: 'prod-001',
companyId: 'comp-001',
name: 'HydraGlow Vitamin C Serum',
brand: 'LuxeBeauty',
series: 'HydraGlow',
category: 'Skincare',
subcategory: 'Serums',
skinType: 'All Skin Types',
claims: ['Brightening', 'Anti-aging', 'Hydration'],
ingredients: 'Aqua, Ascorbic Acid, Hyaluronic Acid, Glycerin, Niacinamide, Tocopherol, Phenoxyethanol',
usageInstructions: 'Apply 2-3 drops to clean face morning and evening. Follow with moisturizer.',
warnings: 'For external use only. Patch test recommended. Discontinue if irritation occurs.',
productionDate: '2023-11-15',
expiryDate: '2025-11-15',
pao: '12M',
barcode: '5060123456789',
images: [],
cppnNumber: 'CPNP-2023-456789',
responsiblePerson: 'Dr. Sarah Mitchell',
status: 'approved',
submittedBy: 'user-003',
submittedAt: '2023-12-01T10:00:00Z',
confirmedBy: 'user-005',
confirmedAt: '2023-12-05T14:30:00Z',
confirmationNotes: 'All regulatory requirements met. Approved for EU market.',
createdAt: '2023-12-01T10:00:00Z',
updatedAt: '2023-12-05T14:30:00Z'
},
{
id: 'prod-002',
companyId: 'comp-001',
name: 'PureGlow Night Repair Cream',
brand: 'PureGlow',
series: 'Night Repair',
category: 'Skincare',
subcategory: 'Moisturizers',
skinType: 'Dry, Mature',
claims: ['Deep hydration', 'Wrinkle reduction', 'Skin renewal'],
ingredients: 'Aqua, Shea Butter, Retinol, Peptides, Ceramides, Squalane, Panthenol',
usageInstructions: 'Apply to face and neck every evening after cleansing.',
warnings: 'Contains retinol. Use SPF during day. Not suitable for pregnant women.',
productionDate: '2023-10-20',
expiryDate: '2025-10-20',
pao: '6M',
barcode: '5060123456790',
images: [],
cppnNumber: 'CPNP-2023-456790',
responsiblePerson: 'Dr. Sarah Mitchell',
status: 'pending',
submittedBy: 'user-003',
submittedAt: '2024-01-10T09:15:00Z',
confirmedBy: null,
confirmedAt: null,
confirmationNotes: null,
createdAt: '2024-01-10T09:15:00Z',
updatedAt: '2024-01-10T09:15:00Z'
},
{
id: 'prod-003',
companyId: 'comp-002',
name: 'NaturaBio Soothing Aloe Gel',
brand: 'NaturaBio',
series: 'Soothing Care',
category: 'Skincare',
subcategory: 'Gels',
skinType: 'Sensitive, Irritated',
claims: ['Soothing', 'Cooling', 'Natural hydration'],
ingredients: 'Aloe Barbadensis Leaf Juice, Glycerin, Chamomilla Recutita Extract, Allantoin',
usageInstructions: 'Apply liberally to affected areas as needed.',
warnings: 'For external use only.',
productionDate: '2023-12-01',
expiryDate: '2025-12-01',
pao: '12M',
barcode: '4260123456789',
images: [],
cppnNumber: 'CPNP-2023-567891',
responsiblePerson: 'Hans Weber',
status: 'draft',
submittedBy: null,
submittedAt: null,
confirmedBy: null,
confirmedAt: null,
confirmationNotes: null,
createdAt: '2024-01-12T11:00:00Z',
updatedAt: '2024-01-12T11:00:00Z'
},
{
id: 'prod-004',
companyId: 'comp-001',
name: 'LuxeBeauty SPF 50 Sunscreen',
brand: 'LuxeBeauty',
series: 'Sun Protection',
category: 'Suncare',
subcategory: 'Sunscreen',
skinType: 'All Skin Types',
claims: ['Broad spectrum', 'Water resistant', 'Non-greasy'],
ingredients: 'Aqua, Zinc Oxide, Titanium Dioxide, Coco-Caprylate, Glycerin',
usageInstructions: 'Apply 15 minutes before sun exposure. Reapply every 2 hours.',
warnings: 'Avoid contact with eyes. Keep babies and young children out of direct sunlight.',
productionDate: '2024-01-05',
expiryDate: '2026-01-05',
pao: '12M',
barcode: '5060123456791',
images: [],
cppnNumber: 'CPNP-2024-000001',
responsiblePerson: 'Dr. Sarah Mitchell',
status: 'rejected',
submittedBy: 'user-003',
submittedAt: '2024-01-08T14:00:00Z',
confirmedBy: 'user-005',
confirmedAt: '2024-01-09T10:30:00Z',
confirmationNotes: 'CPNP number format incorrect. Please resubmit with valid notification number.',
createdAt: '2024-01-08T14:00:00Z',
updatedAt: '2024-01-09T10:30:00Z'
}
],
certificates: [],
auditLog: [],
selectedProduct: null,
filters: {
status: 'all',
search: ''
}
};
// Role Definitions
const ROLES = {
admin: {
name: 'Administrator',
permissions: ['all'],
description: 'Full system access'
},
viewer: {
name: 'Viewer',
permissions: ['view_products', 'view_certificates', 'view_company'],
description: 'View-only access'
},
editor: {
name: 'Editor',
permissions: ['view_products', 'view_certificates', 'view_company', 'create_product', 'edit_product', 'upload_documents'],
description: 'Can add and edit products'
},
manager: {
name: 'Manager',
permissions: ['view_products', 'view_certificates', 'view_company', 'create_product', 'edit_product', 'delete_product', 'upload_documents', 'manage_users', 'submit_for_approval'],
description: 'Full company management'
},
confirmer: {
name: 'Product Confirmer',
permissions: ['view_products', 'view_certificates', 'approve_product', 'reject_product'],
description: 'Review and approve products'
}
};
// Utility Functions
const Utils = {
generateId: () => Math.random().toString(36).substr(2, 9),
formatDate: (date) => {
if (!date) return '-';
return new Date(date).toLocaleDateString('en-GB', {
day: '2-digit',
month: 'short',
year: 'numeric'
});
},
formatDateTime: (date) => {
if (!date) return '-';
return new Date(date).toLocaleString('en-GB', {
day: '2-digit',
month: 'short',
year: 'numeric',
hour: '2-digit',
minute: '2-digit'
});
},
hasPermission: (user, permission) => {
if (!user) return false;
if (user.role === 'admin') return true;
const role = ROLES[user.role];
return role && role.permissions.includes(permission);
},
getCompanyProducts: (companyId) => {
return AppState.products.filter(p => p.companyId === companyId);
},
getPendingProducts: () => {
return AppState.products.filter(p => p.status === 'pending');
},
logAudit: (action, entityType, entityId, details) => {
AppState.auditLog.unshift({
id: Utils.generateId(),
userId: AppState.currentUser?.id,
userName: AppState.currentUser?.name,
action,
entityType,
entityId,
details,
timestamp: new Date().toISOString()
});
}
};
// AI Integration Simulation
const AI = {
generateDescription: async (productName, category, claims) => {
await new Promise(r => setTimeout(r, 1500));
const descriptions = {
'Serums': `Experience transformative skincare with ${productName}. This advanced serum delivers ${claims.join(', ').toLowerCase()} benefits through a potent blend of active ingredients. Clinically proven to improve skin appearance within 4 weeks.`,
'Moisturizers': `${productName} provides intensive hydration while addressing ${claims.join(' and ').toLowerCase()}. Formulated with premium ingredients for visible results.`,
'default': `Discover ${productName} - your solution for ${claims.join(', ').toLowerCase()}. This ${category.toLowerCase()} product combines cutting-edge science with luxurious textures for exceptional results.`
};
return descriptions[category] || descriptions.default;
},
generateSEO: (productName, brand) => {
return {
title: `${productName} | ${brand} | Official Store`,
slug: `${brand.toLowerCase()}-${productName.toLowerCase().replace(/\s+/g, '-')}`,
keywords: [brand, productName, 'skincare', 'beauty', 'cosmetics']
};
},
validateIngredients: (ingredients) => {
const warnings = [];
const restricted = ['hydroquinone', 'mercury', 'lead'];
const restrictedFound = ingredients.toLowerCase().split(',').filter(i =>
restricted.some(r => i.trim().includes(r))
);
if (restrictedFound.length > 0) {
warnings.push(`Warning: Potentially restricted ingredients detected: ${restrictedFound.join(', ')}`);
}
return warnings;
}
};
// ============================================
// UI COMPONENTS
// ============================================
const Components = {
// Header with Built with anycoder
Header: () => `
<header class="glass-panel sticky top-0 z-40 border-b border-gray-200">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16">
<div class="flex items-center gap-3">
<div class="w-10 h-10 bg-primary-600 rounded-xl flex items-center justify-center">
<i class="fas fa-spa text-white text-lg"></i>
</div>
<div>
<h1 class="font-bold text-gray-900 text-lg">CMS</h1>
<p class="text-xs text-gray-500">Cosmetic Management</p>
</div>
</div>
<a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank"
class="text-sm text-primary-600 hover:text-primary-700 font-medium flex items-center gap-2 px-3 py-1.5 rounded-lg hover:bg-primary-50 transition-all">
<i class="fas fa-code"></i>
Built with anycoder
</a>
</div>
</div>
</header>
`,
// Login Page
LoginPage: () => `
<div class="min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-md">
${Components.Header()}
<div class="mt-8 animate-slide-up">
<div class="card">
<div class="text-center mb-8">
<div class="w-16 h-16 bg-primary-100 rounded-2xl flex items-center justify-center mx-auto mb-4">
<i class="fas fa-spa text-primary-600 text-2xl"></i>
</div>
<h2 class="text-2xl font-bold text-gray-900">Welcome Back</h2>
<p class="text-gray-500 mt-2">Sign in to manage your cosmetic products</p>
</div>
<form id="loginForm" class="space-y-5">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email Address</label>
<div class="relative">
<i class="fas fa-envelope absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
<input type="email" id="loginEmail" class="form-input pl-11" placeholder="your@email.com" required>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Password</label>
<div class="relative">
<i class="fas fa-lock absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
<input type="password" id="loginPassword" class="form-input pl-11" placeholder="••••••••" required>
</div>
</div>
<div class="flex items-center justify-between">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" class="w-4 h-4 text-primary-600 rounded border-gray-300">
<span class="text-sm text-gray-600">Remember me</span>
</label>
<a href="#" onclick="App.showForgotPassword()" class="text-sm text-primary-600 hover:text-primary-700 font-medium">
Forgot password?
</a>
</div>
<button type="submit" class="btn-primary w-full justify-center">
<span id="loginText">Sign In</span>
<div id="loginSpinner" class="loading-spinner hidden"></div>
</button>
</form>
<div class="mt-6 p-4 bg-gray-50 rounded-lg">
<p class="text-xs text-gray-500 font-medium mb-2">Demo Credentials:</p>
<div class="space-y-1 text-xs text-gray-600">
<p><span class="font-medium">Admin:</span> admin@cms.com / admin123</p>
<p><span class="font-medium">Manager:</span> sarah.mitchell@luxebeauty.com / manager123</p>
<p><span class="font-medium">Editor:</span> editor@luxebeauty.com / editor123</p>
<p><span class="font-medium">Viewer:</span> viewer@luxebeauty.com / viewer123</p>
<p><span class="font-medium">Confirmer:</span> confirmer@cms.com / confirm123</p>
</div>
</div>
</div>
</div>
</div>
</div>
`,
// Forgot Password Page
ForgotPasswordPage: () => `
<div class="min-h-screen flex items-center justify-center p-4">
<div class="w-full max-w-md">
${Components.Header()}
<div class="mt-8 animate-slide-up">
<div class="card">
<div class="text-center mb-8">
<div class="w-16 h-16 bg-primary-100 rounded-2xl flex items-center justify-center mx-auto mb-4">
<i class="fas fa-key text-primary-600 text-2xl"></i>
</div>
<h2 class="text-2xl font-bold text-gray-900">Reset Password</h2>
<p class="text-gray-500 mt-2">Enter your email to receive reset instructions</p>
</div>
<form id="forgotForm" class="space-y-5">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Email Address</label>
<div class="relative">
<i class="fas fa-envelope absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
<input type="email" class="form-input pl-11" placeholder="your@email.com" required>
</div>
</div>
<button type="submit" class="btn-primary w-full justify-center">
Send Reset Link
</button>
<button type="button" onclick="App.showLogin()" class="btn-secondary w-full justify-center">
<i class="fas fa-arrow-left"></i>
Back to Login
</button>
</form>
</div>
</div>
</div>
</div>
`,
// Sidebar Navigation
Sidebar: () => {
const user = AppState.currentUser;
const isAdmin = user.role === 'admin';
const isConfirmer = user.role === 'confirmer';
const menuItems = [];
// Dashboard for all
menuItems.push({ id: 'dashboard', icon: 'fa-chart-pie', label: 'Dashboard' });
// Products for all except confirmer uses confirmation panel
if (!isConfirmer) {
menuItems.push({ id: 'products', icon: 'fa-pump-soap', label: 'Products' });
}
// Confirmation panel for confirmer and admin
if (isConfirmer || isAdmin) {
const pendingCount = Utils.getPendingProducts().length;
menuItems.push({
id: 'confirmation',
icon: 'fa-clipboard-check',
label: 'Confirmation',
badge: pendingCount > 0 ? pendingCount : null
});
}
// Company profile
if (!isConfirmer) {
menuItems.push({ id: 'company', icon: 'fa-building', label: 'Company Profile' });
}
// User management for manager and admin
if (user.role === 'manager' || isAdmin) {
menuItems.push({ id: 'users', icon: 'fa-users', label: 'User Management' });
}
// Certificates
menuItems.push({ id: 'certificates', icon: 'fa-certificate', label: 'Certificates' });
// Audit log for admin
if (isAdmin) {
menuItems.push({ id: 'audit', icon: 'fa-history', label: 'Audit Log' });
}
return `
<aside class="w-64 bg-white border-r border-gray-200 min-h-screen flex flex-col">
<div class="p-6 border-b border-gray-100">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-primary-600 rounded-xl flex items-center justify-center">
<i class="fas fa-spa text-white text-xl"></i>
</div>
<div>
<h1 class="font-bold text-gray-900">CMS</h1>
<p class="text-xs text-gray-500">Cosmetic Management</p>
</div>
</div>
</div>
<nav class="flex-1 p-4 space-y-1">
${menuItems.map(item => `
<div class="sidebar-item ${AppState.currentView === item.id ? 'active' : ''}"
onclick="App.navigate('${item.id}')">
<i class="fas ${item.icon} w-5"></i>
<span class="flex-1">${item.label}</span>
${item.badge ? `<span class="bg-primary-500 text-white text-xs px-2 py-0.5 rounded-full">${item.badge}</span>` : ''}
</div>
`).join('')}
</nav>
<div class="p-4 border-t border-gray-100">
<div class="flex items-center gap-3 p-3 rounded-lg bg-gray-50">
<div class="w-10 h-10 bg-primary-100 rounded-full flex items-center justify-center">
<i class="fas fa-user text-primary-600"></i>
</div>
<div class="flex-1 min-w-0">
<p class="font-medium text-gray-900 truncate">${user.name}</p>
<p class="text-xs text-gray-500 truncate capitalize">${ROLES[user.role].name}</p>
</div>
</div>
<button onclick="App.logout()" class="w-full mt-3 flex items-center gap-2 px-4 py-2 text-red-600 hover:bg-red-50 rounded-lg transition-all">
<i class="fas fa-sign-out-alt"></i>
<span>Sign Out</span>
</button>
</div>
</aside>
`;
},
// Dashboard
Dashboard: () => {
const user = AppState.currentUser;
const isAdmin = user.role === 'admin';
const isConfirmer = user.role === 'confirmer';
let products, company;
if (isAdmin) {
products = AppState.products;
} else if (isConfirmer) {
products = AppState.products;
} else {
products = Utils.getCompanyProducts(user.companyId);
company = AppState.companies.find(c => c.id === user.companyId);
}
const stats = {
total: products.length,
draft: products.filter(p => p.status === 'draft').length,
pending: products.filter(p => p.status === 'pending').length,
approved: products.filter(p => p.status === 'approved').length,
rejected: products.filter(p => p.status === 'rejected').length
};
const recentProducts = [...products].sort((a, b) =>
new Date(b.updatedAt) - new Date(a.updatedAt)
).slice(0, 5);
return `
<div class="space-y-6">
<div class="flex items-center justify-between">
<div>
<h2 class="text-2xl font-bold text-gray-900">Dashboard</h2>
<p class="text-gray-500">Welcome back, ${user.name}</p>
</div>
${company ? `
<div class="flex items-center gap-2 text-sm text-gray-600">
<i class="fas fa-building text-primary-600"></i>
<span>${company.name}</span>
</div>
` : ''}
</div>
<div class="grid grid-cols-2 lg:grid-cols-5 gap-4">
<div class="card p-5">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-blue-100 rounded-xl flex items-center justify-center">
<i class="fas fa-box text-blue-600 text-xl"></i>
</div>
<div>
<p class="text-2xl font-bold text-gray-900">${stats.total}</p>
<p class="text-sm text-gray-500">Total Products</p>
</div>
</div>
</div>
<div class="card p-5">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-gray-100 rounded-xl flex items-center justify-center">
<i class="fas fa-pencil-alt text-gray-600 text-xl"></i>
</div>
<div>
<p class="text-2xl font-bold text-gray-900">${stats.draft}</p>
<p class="text-sm text-gray-500">Drafts</p>
</div>
</div>
</div>
<div class="card p-5">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-yellow-100 rounded-xl flex items-center justify-center">
<i class="fas fa-clock text-yellow-600 text-xl"></i>
</div>
<div>
<p class="text-2xl font-bold text-gray-900">${stats.pending}</p>
<p class="text-sm text-gray-500">Pending</p>
</div>
</div>
</div>
<div class="card p-5">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-green-100 rounded-xl flex items-center justify-center">
<i class="fas fa-check-circle text-green-600 text-xl"></i>
</div>
<div>
<p class="text-2xl font-bold text-gray-900">${stats.approved}</p>
<p class="text-sm text-gray-500">Approved</p>
</div>
</div>
</div>
<div class="card p-5">
<div class="flex items-center gap-3">
<div class="w-12 h-12 bg-red-100 rounded-xl flex items-center justify-center">
<i class="fas fa-times-circle text-red-600 text-xl"></i>
</div>
<div>
<p class="text-2xl font-bold text-gray-900">${stats.rejected}</p>
<p class="text-sm text-gray-500">Rejected</p>
</div>
</div>
</div>
</div>
<div class="grid lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 card">
<div class="flex items-center justify-between mb-4">
<h3 class="font-bold text-gray-900">Recent Products</h3>
<button onclick="App.navigate('products')" class="text-primary-600 hover:text-primary-700 text-sm font-medium">
View All
</button>
</div>
<div class="space-y-3">
${recentProducts.length > 0 ? recentProducts.map(p => `
<div class="flex items-center gap-4 p-3 rounded-lg hover:bg-gray-50 transition-all cursor-pointer"
onclick="App.viewProduct('${p.id}')">
<div class="w-12 h-12 bg-gradient-to-br from-primary-100 to-primary-200 rounded-lg flex items-center justify-center">
<i class="fas fa-pump-soap text-primary-600"></i>
</div>
<div class="flex-1">
<p class="font-medium text-gray-900">${p.name}</p>
<p class="text-sm text-gray-500">${p.brand} • ${p.category}</p>
</div>
<span class="status-badge status-${p.status}">${p.status}</span>
</div>
`).join('') : `
<p class="text-gray-500 text-center py-8">No products yet</p>
`}
</div>
</div>
<div class="card">
<h3 class="font-bold text-gray-900 mb-4">Quick Actions</h3>
<div class="space-y-3">
${Utils.hasPermission(user, 'create_product') ? `
<button onclick="App.showProductForm()" class="w-full flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:border-primary-300 hover:bg-primary-50 transition-all">
<div class="w-10 h-10 bg-primary-100 rounded-lg flex items-center justify-center">
<i class="fas fa-plus text-primary-600"></i>
</div>
<span class="font-medium text-gray-700">Add New Product</span>
</button>
` : ''}
${isConfirmer ? `
<button onclick="App.navigate('confirmation')" class="w-full flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:border-yellow-300 hover:bg-yellow-50 transition-all">
<div class="w-10 h-10 bg-yellow-100 rounded-lg flex items-center justify-center">
<i class="fas fa-clipboard-check text-yellow-600"></i>
</div>
<div class="flex-1">
<span class="font-medium text-gray-700">Review Pending</span>
${stats.pending > 0 ? `<span class="ml-2 bg-yellow-500 text-white text-xs px-2 py-0.5 rounded-full">${stats.pending}</span>` : ''}
</div>
</button>
` : ''}
<button onclick="App.navigate('certificates')" class="w-full flex items-center gap-3 p-3 rounded-lg border border-gray-200 hover:border-green-300 hover:bg-green-50 transition-all">
<div class="w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center">
<i class="fas fa-certificate text-green-600"></i>
</div>
<span class="font-medium text-gray-700">Manage Certificates</span>
</button>
</div>
</div>
</div>
</div>
`;
},
// Products List
ProductsList: () => {
const user = AppState.currentUser;
let products = user.role === 'admin'
? AppState.products
: Utils.getCompanyProducts(user.companyId);
// Apply filters
if (AppState.filters.status !== 'all') {
products = products.filter(p => p.status === AppState.filters.status);
}
if (AppState.filters.search) {
const search = AppState.filters.search.toLowerCase();
products = products.filter(p =>
p.name.toLowerCase().includes(search) ||
p.brand.toLowerCase().includes(search) ||
p.barcode.includes(search)
);
}
return `
<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div>
<h2 class="text-2xl font-bold text-gray-900">Products</h2>
<p class="text-gray-500">Manage your cosmetic products</p>
</div>
${Utils.hasPermission(user, 'create_product') ? `
<button onclick="App.showProductForm()" class="btn-primary">
<i class="fas fa-plus"></i>
Add Product
</button>
` : ''}
</div>
<div class="card p-4">
<div class="flex flex-col sm:flex-row gap-4">
<div class="flex-1 relative">
<i class="fas fa-search absolute left-4 top-1/2 -translate-y-1/2 text-gray-400"></i>
<input type="text" id="productSearch" class="form-input pl-11"
placeholder="Search products..."
value="${AppState.filters.search}"
oninput="App.updateFilter('search', this.value)">
</div>
<select class="form-input sm:w-48" onchange="App.updateFilter('status', this.value)">
<option value="all" ${AppState.filters.status === 'all' ? 'selected' : ''}>All Status</option>
<option value="draft" ${AppState.filters.status === 'draft' ? 'selected' : ''}>Draft</option>
<option value="pending" ${AppState.filters.status === 'pending' ? 'selected' : ''}>Pending</option>
<option value="approved" ${AppState.filters.status === 'approved' ? 'selected' : ''}>Approved</option>
<option value="rejected" ${AppState.filters.status === 'rejected' ? 'selected' : ''}>Rejected</option>
</select>
</div>
</div>
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
${products.map(p => `
<div class="card group cursor-pointer" onclick="App.viewProduct('${p.id}')">
<div class="flex items-start justify-between mb-4">
<div class="w-16 h-16 bg-gradient-to-br from-primary-100 to-primary-200 rounded-xl flex items-center justify-center">
<i class="fas fa-pump-soap text-primary-600 text-2xl"></i>
</div>
<span class="status-badge status-${p.status}">${p.status}</span>
</div>
<h3 class="font-bold text-gray-900 mb-1 group-hover:text-primary-600 transition-colors">${p.name}</h3>
<p class="text-sm text-gray-500 mb-3">${p.brand} • ${p.category}</p>
<div class="space-y-2 text-sm">
<div class="flex justify-between">
<span class="text-gray-500">Barcode:</span>
<span class="font-mono text-gray-700">${p.barcode}</span>
</div>
<div class="flex justify-between">
<span class="text-gray-500">Expiry:</span>
<span class="text-gray-700">${Utils.formatDate(p.expiryDate)}</span>
</div>
<div class="flex justify-between">
<span class="text-gray-500">CPNP:</span>
<span class="text-gray-700 text-xs">${p.cppnNumber}</span>
</div>
</div>
${p.status === 'approved' ? `
<div class="mt-4 pt-4 border-t border-gray-100 flex items-center gap-2 text-green-600 text-sm">
<i class="fas fa-check-circle"></i>
<span>Confirmed by ${p.confirmedBy ? AppState.users.find(u => u.id === p.confirmedBy)?.name : 'Unknown'}</span>
</div>
` : p.status === 'rejected' ? `
<div class="mt-4 pt-4 border-t border-gray-100 flex items-center gap-2 text-red-600 text-sm">
<i class="fas fa-times-circle"></i>
<span>Rejected</span>
</div>
` : ''}
</div>
`).join('')}
</div>
${products.length === 0 ? `
<div class="text-center py-16">
<div class="w-24 h-24 bg-gray-100 rounded-full flex items-center justify-center mx-auto mb-4">
<i class="fas fa-box-open text-gray-400 text-3xl"></i>
</div>
<h3 class="text-lg font-medium text-gray-900 mb-2">No products found</h3>
<p class="text-gray-500">Try adjusting your filters or add a new product</p>
</div>
` : ''}
</div>
`;
},
// Product Form Modal
ProductForm: (product = null) => {
const isEdit = !!product;
const user = AppState.currentUser;
const company = AppState.companies.find(c => c.id === user.companyId);
return `
<div class="modal-overlay" onclick="if(event.target === this) App.closeModal()">
<div class="modal-content max-w-4xl">
<div class="p-6 border-b border-gray-100 flex items-center justify-between">
<div>
<h2 class="text-xl font-bold text-gray-900">${isEdit ? 'Edit Product' : 'Add New Product'}</h2>
<p class="text-sm text-gray-500">${company?.name || 'All Companies'}</p>
</div>
<button onclick="App.closeModal()" class="w-10 h-10 rounded-lg hover:bg-gray-100 flex items-center justify-center transition-all">
<i class="fas fa-times text-gray-500"></i>
</button>
</div>
<div class="p-6 overflow-y-auto max-h-[60vh]">
<form id="productForm" class="space-y-6">
<input type="hidden" id="productId" value="${product?.id || ''}">
<div class="grid md:grid |