File size: 41,371 Bytes
64bbb5e 14c93c8 | 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 | <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Angular Subscription & Data Hub</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/feather-icons"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css"/>
<base href="/">
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
}
.gradient-bg {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.plan-card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.premium-glow {
box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
}
.print-area {
display: none;
}
@media print {
body * {
visibility: hidden;
}
.print-area, .print-area * {
visibility: visible;
}
.print-area {
position: absolute;
left: 0;
top: 0;
width: 100%;
display: block;
}
.no-print {
display: none !important;
}
}
</style>
</head>
<body class="bg-gray-50 min-h-screen">
<app-root></app-root>
<!-- Angular scripts will be loaded here in actual project -->
<script>
feather.replace();
// This would be in your Angular components in the real implementation
document.addEventListener('DOMContentLoaded', () => {
// Mock Angular-like behavior for this demo
const appRoot = document.querySelector('app-root');
// Navigation
appRoot.innerHTML = `
<div class="flex flex-col min-h-screen">
<!-- Header -->
<header class="gradient-bg text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex justify-between items-center">
<h1 class="text-2xl font-bold flex items-center">
<i data-feather="zap" class="mr-2"></i>
AngularHub
</h1>
<nav class="hidden md:flex space-x-6">
<button onclick="showModule('plans')" class="px-3 py-2 rounded-lg hover:bg-white hover:bg-opacity-10 transition flex items-center">
<i data-feather="credit-card" class="mr-2"></i>
Subscription Plans
</button>
<button onclick="showModule('data')" class="px-3 py-2 rounded-lg hover:bg-white hover:bg-opacity-10 transition flex items-center">
<i data-feather="database" class="mr-2"></i>
API Data Table
</button>
</nav>
<button class="md:hidden" onclick="toggleMobileMenu()">
<i data-feather="menu"></i>
</button>
</div>
<!-- Mobile menu -->
<div id="mobileMenu" class="hidden md:hidden mt-4 space-y-2">
<button onclick="showModule('plans')" class="w-full text-left px-3 py-2 rounded-lg hover:bg-white hover:bg-opacity-10 transition flex items-center">
<i data-feather="credit-card" class="mr-2"></i>
Subscription Plans
</button>
<button onclick="showModule('data')" class="w-full text-left px-3 py-2 rounded-lg hover:bg-white hover:bg-opacity-10 transition flex items-center">
<i data-feather="database" class="mr-2"></i>
API Data Table
</button>
</div>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow container mx-auto px-4 py-8">
<div id="plansModule">
<!-- Subscription Plans Module -->
<h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">Choose Your Plan</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8 mb-12">
<!-- Minimum Plan -->
<div class="plan-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300">
<div class="p-6">
<div class="flex justify-between items-start">
<h3 class="text-xl font-bold text-gray-800">Minimum</h3>
<span class="bg-blue-100 text-blue-800 text-xs px-2 py-1 rounded-full">Basic</span>
</div>
<p class="text-gray-600 text-sm mt-1">Essentials for Startups</p>
</div>
<div class="px-6 pb-4">
<p class="text-3xl font-bold text-gray-800">100 <span class="text-lg">BDT</span></p>
<p class="text-gray-600 text-sm mt-1">10 Days Unlimited</p>
</div>
<div class="border-t border-gray-100 px-6 py-4">
<ul class="space-y-2">
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">10 Days Unlimited</span>
</li>
<li class="flex items-center">
<i data-feather="x" class="text-red-400 mr-2"></i>
<span class="text-gray-600">SMS: OFF</span>
</li>
</ul>
</div>
<div class="px-6 py-4 bg-gray-50">
<button onclick="selectPlan('minimum')" class="w-full py-2 px-4 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition">
Select Plan
</button>
</div>
</div>
<!-- Regular Plan -->
<div class="plan-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300">
<div class="p-6">
<div class="flex justify-between items-start">
<h3 class="text-xl font-bold text-gray-800">Regular</h3>
<span class="bg-purple-100 text-purple-800 text-xs px-2 py-1 rounded-full">Standard</span>
</div>
<p class="text-gray-600 text-sm mt-1">Balanced and Optimized</p>
</div>
<div class="px-6 pb-4">
<p class="text-3xl font-bold text-gray-800">300 <span class="text-lg">BDT</span></p>
<p class="text-gray-600 text-sm mt-1">15 Days Unlimited</p>
</div>
<div class="border-t border-gray-100 px-6 py-4">
<ul class="space-y-2">
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">15 Days Unlimited</span>
</li>
<li class="flex items-center">
<i data-feather="x" class="text-red-400 mr-2"></i>
<span class="text-gray-600">SMS: OFF</span>
</li>
</ul>
</div>
<div class="px-6 py-4 bg-gray-50">
<button onclick="selectPlan('regular')" class="w-full py-2 px-4 bg-purple-600 hover:bg-purple-700 text-white rounded-lg transition">
Select Plan
</button>
</div>
</div>
<!-- Popular Plan -->
<div class="plan-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300 border-2 border-yellow-400">
<div class="absolute -top-2 -right-2 bg-yellow-400 text-yellow-800 text-xs font-bold px-2 py-1 rounded-full animate-pulse">
POPULAR
</div>
<div class="p-6">
<div class="flex justify-between items-start">
<h3 class="text-xl font-bold text-gray-800">Popular</h3>
<span class="bg-yellow-100 text-yellow-800 text-xs px-2 py-1 rounded-full">Best Value</span>
</div>
<p class="text-gray-600 text-sm mt-1">The Smart Choice for Success!</p>
</div>
<div class="px-6 pb-4">
<p class="text-3xl font-bold text-gray-800">500 <span class="text-lg">BDT</span></p>
<p class="text-gray-600 text-sm mt-1">30 Days Unlimited</p>
</div>
<div class="border-t border-gray-100 px-6 py-4">
<ul class="space-y-2">
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">30 Days Unlimited</span>
</li>
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">415 Free SMS</span>
</li>
</ul>
</div>
<div class="px-6 py-4 bg-gray-50">
<button onclick="selectPlan('popular')" class="w-full py-2 px-4 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg transition">
Select Plan
</button>
</div>
</div>
<!-- Enterprise Monthly -->
<div class="plan-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300">
<div class="p-6">
<div class="flex justify-between items-start">
<h3 class="text-xl font-bold text-gray-800">Enterprise (Monthly)</h3>
<span class="bg-green-100 text-green-800 text-xs px-2 py-1 rounded-full">Premium</span>
</div>
<p class="text-gray-600 text-sm mt-1">Premium Solution</p>
</div>
<div class="px-6 pb-4">
<p class="text-3xl font-bold text-gray-800">1000 <span class="text-lg">BDT</span></p>
<p class="text-gray-600 text-sm mt-1">30 Days Unlimited</p>
</div>
<div class="border-t border-gray-100 px-6 py-4">
<ul class="space-y-2">
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">30 Days Unlimited</span>
</li>
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">850 Free SMS</span>
</li>
</ul>
</div>
<div class="px-6 py-4 bg-gray-50">
<button onclick="selectPlan('enterprise-monthly')" class="w-full py-2 px-4 bg-green-600 hover:bg-green-700 text-white rounded-lg transition">
Select Plan
</button>
</div>
</div>
<!-- Enterprise Yearly -->
<div class="plan-card bg-white rounded-xl shadow-md overflow-hidden transition duration-300 premium-glow">
<div class="absolute -top-2 -right-2 bg-gradient-to-r from-purple-500 to-pink-500 text-white text-xs font-bold px-2 py-1 rounded-full">
PREMIUM
</div>
<div class="p-6">
<div class="flex justify-between items-start">
<h3 class="text-xl font-bold text-gray-800">Enterprise (Yearly)</h3>
<span class="bg-pink-100 text-pink-800 text-xs px-2 py-1 rounded-full">Best Offer</span>
</div>
<p class="text-gray-600 text-sm mt-1">Best Value for Long-Term</p>
</div>
<div class="px-6 pb-4">
<p class="text-3xl font-bold text-gray-800">5000 <span class="text-lg">BDT</span></p>
<p class="text-gray-600 text-sm mt-1">1 Year Unlimited</p>
</div>
<div class="border-t border-gray-100 px-6 py-4">
<ul class="space-y-2">
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">1 Year Unlimited</span>
</li>
<li class="flex items-center">
<i data-feather="check" class="text-green-500 mr-2"></i>
<span class="text-gray-600">5000 Free SMS</span>
</li>
</ul>
</div>
<div class="px-6 py-4 bg-gray-50">
<button onclick="selectPlan('enterprise-yearly')" class="w-full py-2 px-4 bg-gradient-to-r from-purple-500 to-pink-500 hover:from-purple-600 hover:to-pink-600 text-white rounded-lg transition">
Select Plan
</button>
</div>
</div>
</div>
<!-- Checkout Section (hidden by default) -->
<div id="checkoutSection" class="hidden bg-white rounded-xl shadow-md p-6 max-w-2xl mx-auto">
<h2 class="text-2xl font-bold text-gray-800 mb-6">Checkout</h2>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-2">Selected Plan</h3>
<div id="selectedPlanInfo" class="bg-gray-50 p-4 rounded-lg">
<!-- Plan info will be inserted here -->
</div>
</div>
<div>
<h3 class="text-lg font-semibold text-gray-700 mb-2">SMS Options</h3>
<div class="bg-gray-50 p-4 rounded-lg">
<div class="flex items-center justify-between mb-4">
<div>
<label class="font-medium text-gray-700">SMS Service</label>
<p class="text-sm text-gray-500">Purchase additional SMS</p>
</div>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="smsToggle" class="sr-only peer" onchange="toggleSms()">
<div class="w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-blue-600"></div>
</label>
</div>
<div id="smsOptions" class="hidden">
<label class="block text-sm font-medium text-gray-700 mb-1">Additional SMS (0.60 BDT per SMS)</label>
<input type="number" id="smsQuantity" min="100" step="100" value="500" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500" oninput="calculateTotal()">
</div>
</div>
</div>
</div>
<div class="mt-6 bg-blue-50 p-4 rounded-lg">
<h3 class="text-lg font-semibold text-gray-700 mb-2">Order Summary</h3>
<div class="flex justify-between items-center mb-2">
<span class="text-gray-600">Plan Price</span>
<span id="planPrice" class="font-medium">0 BDT</span>
</div>
<div id="smsCostContainer" class="hidden flex justify-between items-center mb-2">
<span class="text-gray-600">Additional SMS Cost</span>
<span id="smsCost" class="font-medium">0 BDT</span>
</div>
<div class="border-t border-gray-200 pt-2 mt-2">
<div class="flex justify-between items-center">
<span class="font-semibold">Total</span>
<span id="totalPrice" class="font-bold text-lg">0 BDT</span>
</div>
</div>
</div>
<div class="mt-6 flex justify-end space-x-3">
<button onclick="cancelCheckout()" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition">
Cancel
</button>
<button onclick="processPayment()" class="px-6 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition flex items-center">
<i data-feather="credit-card" class="mr-2"></i>
Buy Now
</button>
</div>
</div>
</div>
<div id="dataModule" class="hidden">
<!-- API Data Table Module -->
<div class="flex justify-between items-center mb-6">
<h2 class="text-3xl font-bold text-gray-800">User Data from API</h2>
<button onclick="printTable()" class="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition flex items-center">
<i data-feather="printer" class="mr-2"></i>
Print Table
</button>
</div>
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<div class="p-4 border-b border-gray-200 flex justify-between items-center">
<div class="flex items-center">
<input type="text" id="searchInput" placeholder="Search..." class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<button onclick="filterTable()" class="ml-2 px-3 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition">
<i data-feather="search"></i>
</button>
</div>
<div class="flex items-center">
<span class="text-sm text-gray-600 mr-2">Sort by:</span>
<select id="sortSelect" onchange="sortTable()" class="px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
<option value="name">Name</option>
<option value="email">Email</option>
<option value="city">City</option>
</select>
</div>
</div>
<div class="print-area">
<table id="dataTable" class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Name</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Email</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">City</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Company</th>
</tr>
</thead>
<tbody id="tableBody" class="bg-white divide-y divide-gray-200">
<!-- Data will be loaded here -->
</tbody>
</table>
</div>
<div class="p-4 border-t border-gray-200 flex justify-between items-center">
<div class="text-sm text-gray-600">
Showing <span id="startRow">1</span> to <span id="endRow">10</span> of <span id="totalRows">50</span> entries
</div>
<div class="flex space-x-2">
<button onclick="prevPage()" class="px-3 py-1 border border-gray-300 rounded-md hover:bg-gray-50 transition">
<i data-feather="chevron-left"></i>
</button>
<button onclick="nextPage()" class="px-3 py-1 border border-gray-300 rounded-md hover:bg-gray-50 transition">
<i data-feather="chevron-right"></i>
</button>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="gradient-bg text-white py-8">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<h2 class="text-xl font-bold flex items-center">
<i data-feather="zap" class="mr-2"></i>
AngularHub
</h2>
<p class="text-sm mt-1">Subscription & Data Management Solution</p>
</div>
<div class="flex space-x-4">
<a href="#" class="hover:text-blue-200 transition">
<i data-feather="github"></i>
</a>
<a href="#" class="hover:text-blue-200 transition">
<i data-feather="twitter"></i>
</a>
<a href="#" class="hover:text-blue-200 transition">
<i data-feather="linkedin"></i>
</a>
</div>
</div>
<div class="border-t border-blue-400 mt-6 pt-6 text-center text-sm">
<p>© 2023 AngularHub. All rights reserved.</p>
</div>
</div>
</footer>
</div>
`;
// Initialize Feather Icons
feather.replace();
// Show plans module by default
showModule('plans');
// Load sample data for the table (in a real Angular app, this would be an API call)
loadSampleData();
});
// Mock functions that would be in Angular components/services
function showModule(moduleName) {
document.getElementById('plansModule').classList.add('hidden');
document.getElementById('dataModule').classList.add('hidden');
if (moduleName === 'plans') {
document.getElementById('plansModule').classList.remove('hidden');
} else {
document.getElementById('dataModule').classList.remove('hidden');
}
// Close mobile menu if open
document.getElementById('mobileMenu').classList.add('hidden');
}
function toggleMobileMenu() {
const menu = document.getElementById('mobileMenu');
if (menu.classList.contains('hidden')) {
menu.classList.remove('hidden');
} else {
menu.classList.add('hidden');
}
}
// Subscription Plans Module Functions
const plans = {
'minimum': {
name: 'Minimum',
price: 100,
duration: '10 Days Unlimited',
sms: 'OFF',
tagline: 'Essentials for Startups - Simple, Affordable, and Effective.'
},
'regular': {
name: 'Regular',
price: 300,
duration: '15 Days Unlimited',
sms: 'OFF',
tagline: 'Balanced and Optimized - Perfect for Growing Businesses.'
},
'popular': {
name: 'Popular',
price: 500,
duration: '30 Days Unlimited',
sms: '415 Free SMS',
tagline: 'The Smart Choice for Success! Our Most Popular Plan.'
},
'enterprise-monthly': {
name: 'Enterprise (Monthly)',
price: 1000,
duration: '30 Days Unlimited',
sms: '850 Free SMS',
tagline: 'Premium Solution for Enterprises.'
},
'enterprise-yearly': {
name: 'Enterprise (Yearly)',
price: 5000,
duration: '1 Year Unlimited',
sms: '5000 Free SMS',
tagline: 'Best Value for Long-Term Growth.'
}
};
let selectedPlan = null;
let smsEnabled = false;
let smsQuantity = 500;
function selectPlan(planId) {
selectedPlan = plans[planId];
// Update selected plan info
const planInfoDiv = document.getElementById('selectedPlanInfo');
planInfoDiv.innerHTML = `
<h4 class="font-bold text-lg">${selectedPlan.name}</h4>
<p class="text-gray-600">${selectedPlan.tagline}</p>
<div class="mt-2 flex justify-between">
<span class="text-gray-700">Price:</span>
<span class="font-medium">${selectedPlan.price} BDT</span>
</div>
<div class="flex justify-between">
<span class="text-gray-700">Duration:</span>
<span class="font-medium">${selectedPlan.duration}</span>
</div>
<div class="flex justify-between">
<span class="text-gray-700">SMS:</span>
<span class="font-medium">${selectedPlan.sms}</span>
</div>
`;
// Show checkout section
document.getElementById('checkoutSection').classList.remove('hidden');
// Update prices
calculateTotal();
// Scroll to checkout
document.getElementById('checkoutSection').scrollIntoView({ behavior: 'smooth' });
}
function toggleSms() {
smsEnabled = !smsEnabled;
const smsOptions = document.getElementById('smsOptions');
const smsCostContainer = document.getElementById('smsCostContainer');
if (smsEnabled) {
smsOptions.classList.remove('hidden');
smsCostContainer.classList.remove('hidden');
} else {
smsOptions.classList.add('hidden');
smsCostContainer.classList.add('hidden');
}
calculateTotal();
}
function calculateTotal() {
if (!selectedPlan) return;
const planPrice = selectedPlan.price;
let total = planPrice;
document.getElementById('planPrice').textContent = `${planPrice} BDT`;
if (smsEnabled) {
smsQuantity = parseInt(document.getElementById('smsQuantity').value) || 500;
const smsCost = Math.floor(smsQuantity * 0.6);
document.getElementById('smsCost').textContent = `${smsCost} BDT`;
total += smsCost;
}
document.getElementById('totalPrice').textContent = `${total} BDT`;
}
function cancelCheckout() {
document.getElementById('checkoutSection').classList.add('hidden');
selectedPlan = null;
}
function processPayment() {
alert('Payment processing would happen here in a real application!');
// Reset after "payment"
document.getElementById('checkoutSection').classList.add('hidden');
selectedPlan = null;
}
// Data Table Module Functions
let currentPage = 1;
const rowsPerPage = 10;
let allData = [];
let filteredData = [];
let sortField = 'name';
let sortDirection = 'asc';
function loadSampleData() {
// In a real Angular app, this would be an HTTP GET request to the API
// Mock data for demonstration
allData = [
{ id: 1, name: 'Leanne Graham', email: 'leanne@example.com', city: 'Gwenborough', company: 'Romaguera-Crona' },
{ id: 2, name: 'Ervin Howell', email: 'ervin@example.com', city: 'Wisokyburgh', company: 'Deckow-Crist' },
{ id: 3, name: 'Clementine Bauch', email: 'clementine@example.com', city: 'McKenziehaven', company: 'Romaguera-Jacobson' },
{ id: 4, name: 'Patricia Lebsack', email: 'patricia@example.com', city: 'South Elvis', company: 'Robel-Corkery' },
{ id: 5, name: 'Chelsey Dietrich', email: 'chelsey@example.com', city: 'Roscoeview', company: 'Keebler LLC' },
{ id: 6, name: 'Mrs. Dennis Schulist', email: 'dennis@example.com', city: 'South Christy', company: 'Considine-Lockman' },
{ id: 7, name: 'Kurtis Weissnat', email: 'kurtis@example.com', city: 'Howemouth', company: 'Johns Group' },
{ id: 8, name: 'Nicholas Runolfsdottir V', email: 'nicholas@example.com', city: 'Aliyaview', company: 'Abernathy Group' },
{ id: 9, name: 'Glenna Reichert', email: 'glenna@example.com', city: 'Bartholomebury', company: 'Yost and Sons' },
{ id: 10, name: 'Clementina DuBuque', email: 'clementina@example.com', city: 'Lebsackbury', company: 'Hoeger LLC' },
{ id: 11, name: 'John Doe', email: 'john@example.com', city: 'New York', company: 'ABC Corp' },
{ id: 12, name: 'Jane Smith', email: 'jane@example.com', city: 'Los Angeles', company: 'XYZ Inc' }
];
filteredData = [...allData];
renderTable();
}
function renderTable() {
const tableBody = document.getElementById('tableBody');
tableBody.innerHTML = '';
// Sort data
filteredData.sort((a, b) => {
if (a[sortField] < b[sortField]) return sortDirection === 'asc' ? -1 : 1;
if (a[sortField] > b[sortField]) return sortDirection === 'asc' ? 1 : -1;
return 0;
});
// Pagination
const startIdx = (currentPage - 1) * rowsPerPage;
const endIdx = Math.min(startIdx + rowsPerPage, filteredData.length);
const pageData = filteredData.slice(startIdx, endIdx);
// Update pagination info
document.getElementById('startRow').textContent = startIdx + 1;
document.getElementById('endRow').textContent = endIdx;
document.getElementById('totalRows').textContent = filteredData.length;
// Render rows
pageData.forEach(item => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${item.id}</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm font-medium text-gray-900">${item.name}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">${item.email}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">${item.city}</div>
</td>
<td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm text-gray-900">${item.company}</div>
</td>
`;
tableBody.appendChild(row);
});
feather.replace();
}
function filterTable() {
const searchTerm = document.getElementById('searchInput').value.toLowerCase();
if (!searchTerm) {
filteredData = [...allData];
} else {
filteredData = allData.filter(item =>
item.name.toLowerCase().includes(searchTerm) ||
item.email.toLowerCase().includes(searchTerm) ||
item.city.toLowerCase().includes(searchTerm) ||
item.company.toLowerCase().includes(searchTerm)
);
}
currentPage = 1;
renderTable();
}
function sortTable() {
const sortSelect = document.getElementById('sortSelect');
sortField = sortSelect.value;
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
renderTable();
}
function prevPage() {
if (currentPage > 1) {
currentPage--;
renderTable();
}
}
function nextPage() {
const totalPages = Math.ceil(filteredData.length / rowsPerPage);
if (currentPage < totalPages) {
currentPage++;
renderTable();
}
}
function printTable() {
window.print();
}
</script>
</body>
</html>
|