update point

This commit is contained in:
Phuoc Nguyen
2025-12-04 11:43:27 +07:00
parent d4de557662
commit b9b6d91a87
6 changed files with 1724 additions and 430 deletions

View File

@@ -8,78 +8,6 @@
<link rel="stylesheet" href="assets/css/style.css"> <link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head> </head>
<style>
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0,0,0,0.5);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.modal-content {
background: white;
border-radius: 12px;
width: 100%;
max-width: 500px;
animation: slideUp 0.3s ease;
}
@keyframes slideUp {
from { transform: translateY(20px); opacity: 0; }
to { transform: translateY(0); opacity: 1; }
}
.modal-header {
padding: 20px;
border-bottom: 1px solid #e5e7eb;
display: flex;
justify-content: space-between;
align-items: center;
}
.modal-body {
padding: 20px;
}
.modal-footer {
padding: 20px;
border-top: 1px solid #e5e7eb;
display: flex;
gap: 12px;
}
.modal-close {
background: none;
border: none;
font-size: 20px;
color: #6b7280;
cursor: pointer;
}
@media (max-width: 768px) {
.document-card {
flex-direction: column;
align-items: stretch;
}
.download-btn {
width: 100%;
justify-content: center;
}
}
.tab-item.active {
background: var(--primary-blue);
color: var(--white);
}
</style>
<body> <body>
<div class="page-wrapper"> <div class="page-wrapper">
<!-- Header --> <!-- Header -->
@@ -88,15 +16,12 @@
<i class="fas fa-arrow-left"></i> <i class="fas fa-arrow-left"></i>
</a> </a>
<h1 class="header-title">Lịch sử điểm</h1> <h1 class="header-title">Lịch sử điểm</h1>
<!--<div style="width: 32px;"></div>--> <div style="width: 32px;"></div>
<button class="back-button" onclick="openInfoModal()">
<i class="fas fa-info-circle"></i>
</button>
</div> </div>
<div class="container"> <div class="container">
<!-- Filter Section --> <!-- Filter Section -->
<!--<div class="card mb-3"> <div class="card mb-3">
<div class="d-flex justify-between align-center"> <div class="d-flex justify-between align-center">
<h3 class="card-title">Bộ lọc</h3> <h3 class="card-title">Bộ lọc</h3>
<i class="fas fa-filter" style="color: var(--primary-blue);"></i> <i class="fas fa-filter" style="color: var(--primary-blue);"></i>
@@ -104,184 +29,221 @@
<p class="text-muted" style="font-size: 12px; margin-top: 8px;"> <p class="text-muted" style="font-size: 12px; margin-top: 8px;">
Thời gian hiệu lực: 01/01/2023 - 31/12/2023 Thời gian hiệu lực: 01/01/2023 - 31/12/2023
</p> </p>
</div>--> </div>
<!-- Points History List --> <!-- Points History List -->
<div class="points-history-list"> <div class="points-history-list">
<!-- Transaction Item 1 --> <!-- Transaction Card 1 -->
<div class="card mb-3"> <div class="transaction-card">
<div class="d-flex justify-between align-start mb-2"> <div class="card-header">
<div style="flex: 1;"> <span class="transaction-code">GD-00083</span>
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;"> <span class="transaction-date">28/09/2023</span>
Giao dịch mua hàng 00083 </div>
</h4> <div class="card-content">
<p class="text-muted" style="font-size: 12px;"> <div class="transaction-desc">
Thời gian: 28/09/2023 17:23:18 <div style="font-weight: 600; color: #333; margin-bottom: 4px;">Giao dịch mua hàng</div>
</p> <div style="font-size: 13px; color: #999;">Mã tham chiếu: #HD-2023-00083</div>
<p class="text-muted" style="font-size: 12px;"> </div>
Giao dịch: 100.000.000 VND <div class="transaction-points positive">
</p> +3 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>604 điểm</strong></span>
</div> </div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div> </div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> <!-- Transaction Card 2 -->
<div style="text-align: right;"> <div class="transaction-card">
<div style="color: var(--success-color); font-weight: 500;">+3</div> <div class="card-header">
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div> <span class="transaction-code">GD-00081</span>
<span class="transaction-date">27/09/2023</span>
</div>
<div class="card-content">
<div class="transaction-desc">
<div style="font-weight: 600; color: #333; margin-bottom: 4px;">Giao dịch mua hàng</div>
<div style="font-size: 13px; color: #999;">Mã tham chiếu: #HD-2023-00081</div>
</div>
<div class="transaction-points neutral">
0 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>601 điểm</strong></span>
</div>
</div>
<!-- Transaction Card 3 -->
<div class="transaction-card">
<div class="card-header">
<span class="transaction-code">EXP-2023-001</span>
<span class="transaction-date">20/09/2023</span>
</div>
<div class="card-content">
<div class="transaction-desc">
<div style="font-weight: 600; color: #333; margin-bottom: 4px;">Điểm thưởng hết hạn</div>
<div style="font-size: 13px; color: #999;">Hết hạn sử dụng</div>
</div>
<div class="transaction-points negative">
-5 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>601 điểm</strong></span>
</div>
</div>
<!-- Transaction Card 4 -->
<div class="transaction-card">
<div class="card-header">
<span class="transaction-code">RDM-2023-042</span>
<span class="transaction-date">19/09/2023</span>
</div>
<div class="card-content">
<div class="transaction-desc">
<div style="font-weight: 600; color: #333; margin-bottom: 4px;">Đổi Voucher giảm giá</div>
<div style="font-size: 13px; color: #999;">Voucher 5.000.000đ - HSG</div>
</div>
<div class="transaction-points negative">
-500 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>606 điểm</strong></span>
</div>
</div>
<!-- Transaction Card 5 -->
<div class="transaction-card">
<div class="card-header">
<span class="transaction-code">REF-2023-128</span>
<span class="transaction-date">10/09/2023</span>
</div>
<div class="card-content">
<div class="transaction-desc">
<div style="font-weight: 600; color: #333; margin-bottom: 4px;">Giới thiệu thành công</div>
<div style="font-size: 13px; color: #999;">Giới thiệu: Nguyễn Văn A</div>
</div>
<div class="transaction-points positive">
+5 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>1.106 điểm</strong></span>
</div>
</div>
<!-- Transaction Card 6 -->
<div class="transaction-card">
<div class="card-header">
<span class="transaction-code">RDM-2023-038</span>
<span class="transaction-date">05/09/2023</span>
</div>
<div class="card-content">
<div class="transaction-desc">
<div style="font-weight: 600; color: #333; margin-bottom: 4px;">Đổi quà tặng</div>
<div style="font-size: 13px; color: #999;">Tai nghe Bluetooth Sony WH-1000XM4</div>
</div>
<div class="transaction-points negative">
-200 điểm
</div>
</div>
<div class="card-footer">
<span class="balance-after">Số dư sau: <strong>1.101 điểm</strong></span>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
<!-- Transaction Item 2 --> <style>
<div class="card mb-3"> /* Modern Transaction Card Styles */
<div class="d-flex justify-between align-start mb-2"> .transaction-card {
<div style="flex: 1;"> background: white;
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;"> border-radius: 12px;
Giao dịch mua hàng 00081 box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
</h4> margin-bottom: 12px;
<p class="text-muted" style="font-size: 12px;"> overflow: hidden;
Thời gian: 27/09/2023 17:23:18 transition: all 0.2s;
</p> }
<p class="text-muted" style="font-size: 12px;">
Giao dịch: 200.000.000 VND
</p>
</div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> .transaction-card:hover {
<div style="text-align: right;"> box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
<div style="color: var(--text-dark); font-weight: 500;">0</div> transform: translateY(-2px);
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div> }
</div>
</div>
</div>
<!-- Transaction Item 3 --> .transaction-card .card-header {
<div class="card mb-3"> display: flex;
<div class="d-flex justify-between align-start mb-2"> justify-content: space-between;
<div style="flex: 1;"> align-items: center;
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;"> padding: 12px 16px;
Điểm thưởng hết hạn background: #f9fafb;
</h4> border-bottom: 1px solid #e5e7eb;
<p class="text-muted" style="font-size: 12px;"> }
Thời gian: 20/09/2023 17:23:18
</p>
</div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> .transaction-code {
<div style="text-align: right;"> font-weight: 700;
<div style="color: var(--danger-color); font-weight: 500;">-5</div> font-size: 14px;
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div> color: #005B9A;
</div> }
</div>
</div>
<!-- Transaction Item 4 --> .transaction-date {
<div class="card mb-3"> font-size: 12px;
<div class="d-flex justify-between align-start mb-2"> color: #9ca3af;
<div style="flex: 1;"> }
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;">
Đổi Voucher HSG
</h4>
<p class="text-muted" style="font-size: 12px;">
Thời gian: 19/09/2023 17:23:18
</p>
</div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> .transaction-card .card-content {
<div style="text-align: right;"> display: flex;
<div style="color: var(--danger-color); font-weight: 500;">-500</div> justify-content: space-between;
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div> align-items: center;
</div> padding: 16px;
</div> }
</div>
<!-- Transaction Item 5 --> .transaction-desc {
<div class="card mb-3"> flex: 1;
<div class="d-flex justify-between align-start mb-2"> }
<div style="flex: 1;">
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;">
Giới thiệu người dùng
</h4>
<p class="text-muted" style="font-size: 12px;">
Thời gian: 10/09/2023 17:23:18
</p>
</div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> .transaction-points {
<div style="text-align: right;"> font-size: 24px;
<div style="color: var(--success-color); font-weight: 500;">+5</div> font-weight: 700;
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div> text-align: right;
</div> margin-left: 16px;
</div> }
</div>
<!-- Transaction Item 6 --> .transaction-points.positive {
<div class="card mb-3"> color: #059669;
<div class="d-flex justify-between align-start mb-2"> }
<div style="flex: 1;">
<h4 style="color: var(--primary-blue); font-weight: 500; margin-bottom: 4px;">
Đổi quà
</h4>
<p class="text-muted" style="font-size: 12px;">
Thời gian: 19/09/2023 17:23:18
</p>
</div>
<button class="btn-complaint" onclick="openComplaint(this)">
Khiếu nại
</button>
</div>
<div class="d-flex justify-end align-center" style="margin-top: 12px;"> .transaction-points.negative {
<div style="text-align: right;"> color: #dc2626;
<div style="color: var(--danger-color); font-weight: 500;">-200</div> }
<div style="color: var(--primary-blue); font-size: 12px;">Điểm mới: 604</div>
</div> .transaction-points.neutral {
</div> color: #6b7280;
</div> }
</div>
</div> .transaction-card .card-footer {
<!-- Info Modal --> padding: 10px 16px;
<div id="infoModal" class="modal-overlay" style="display: none;"> background: #fafafa;
<div class="modal-content info-modal"> border-top: 1px solid #f0f0f0;
<div class="modal-header"> }
<h3 class="modal-title" style="font-weight: bold;">Hướng dẫn sử dụng</h3>
<button class="modal-close" onclick="closeInfoModal()"> .balance-after {
<i class="fas fa-times"></i> font-size: 13px;
</button> color: #666;
</div> }
<div class="modal-body">
<p>Đây là nội dung hướng dẫn sử dụng cho tính năng Lịch sử điểm:</p> .balance-after strong {
<ul class="list-disc ml-6 mt-3"> color: #005B9A;
<li>Đây là sao kê chi tiết tất cả các giao dịch cộng/trừ điểm của bạn.</li> font-weight: 600;
<li>Bạn có thể kiểm tra điểm được cộng từ đơn hàng, từ việc đăng ký công trình, hoặc điểm bị trừ khi đổi quà.</li> }
<li>Nếu phát hiện giao dịch bị sai sót, hãy bấm nút "Khiếu nại" trên dòng giao dịch đó để gửi yêu cầu hỗ trợ.</li>
</ul> @media (max-width: 480px) {
</div> .transaction-points {
<div class="modal-footer"> font-size: 20px;
<button class="btn btn-primary" onclick="closeInfoModal()">Đóng</button> }
</div> }
</div> </style>
</div>
</div>
<script> <script>
function openComplaint(buttonElement) { function openComplaint(buttonElement) {
@@ -302,21 +264,6 @@
window.location.href = `point-complaint.html?${params.toString()}`; window.location.href = `point-complaint.html?${params.toString()}`;
} }
function openInfoModal() {
document.getElementById('infoModal').style.display = 'flex';
}
function closeInfoModal() {
document.getElementById('infoModal').style.display = 'none';
}
// Close modal when clicking outside
document.addEventListener('click', function(e) {
if (e.target.classList.contains('modal-overlay')) {
e.target.style.display = 'none';
}
});
</script> </script>
</body> </body>
</html> </html>

View File

@@ -319,7 +319,124 @@
color: #0369a1; color: #0369a1;
} }
.product-row {
background: #f8f9fa;
border: 2px solid var(--border-color);
border-radius: 12px;
padding: 16px;
margin-bottom: 12px;
position: relative;
}
.product-row-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px dashed #ddd;
}
.product-row-title {
font-size: 14px;
font-weight: 600;
color: var(--primary-color);
}
.btn-remove-product {
background: #fee2e2;
color: #dc2626;
border: none;
padding: 6px 12px;
border-radius: 6px;
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
font-weight: 500;
}
.btn-remove-product:hover {
background: #fecaca;
}
.product-input-group {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 12px;
}
.product-input-full {
grid-column: 1 / -1;
}
.product-label {
font-size: 13px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 6px;
display: block;
}
.product-label.required::after {
content: " *";
color: var(--danger-color);
}
.product-subtotal {
background: #eff6ff;
border: 2px dashed #005B9A;
border-radius: 8px;
padding: 12px;
text-align: center;
}
.product-subtotal-label {
font-size: 12px;
color: #666;
margin-bottom: 4px;
}
.product-subtotal-value {
font-size: 18px;
font-weight: 700;
color: #005B9A;
}
.btn-add-product {
width: 100%;
background: white;
border: 2px dashed var(--primary-color);
color: var(--primary-color);
padding: 14px;
border-radius: 12px;
font-size: 15px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
}
.btn-add-product:hover {
background: #eff6ff;
border-color: var(--primary-dark);
}
.summary-card {
background: linear-gradient(135deg, #eff6ff, #dbeafe);
border: 2px solid #005B9A;
border-radius: 12px;
padding: 20px;
margin-bottom: 16px;
}
@media (max-width: 480px) { @media (max-width: 480px) {
.product-input-group {
grid-template-columns: 1fr;
}
.content { .content {
padding: 0.75rem; padding: 0.75rem;
} }
@@ -403,44 +520,9 @@
placeholder="Nhập số hóa đơn (nếu có)" placeholder="Nhập số hóa đơn (nếu có)"
onchange="validateForm()"> onchange="validateForm()">
</div> </div>
<!-- Total Amount -->
<div class="form-group">
<label class="form-label required">Tổng giá trị đơn hàng (VNĐ)</label>
<input type="number"
class="form-input"
id="totalAmount"
placeholder="0"
min="0"
step="1000"
required
oninput="calculatePoints(); validateForm()">
</div>
<!-- Points Estimate -->
<!--<div class="points-estimate" id="pointsEstimate">
<div class="estimate-title">Điểm dự kiến nhận được</div>
<div class="estimate-text" id="estimateText">0 điểm</div>
</div>-->
<!-- Products Purchased -->
<!--<div class="form-group">
<label class="form-label">Sản phẩm đã mua</label>
<textarea class="form-input form-textarea"
id="products"
placeholder="Mô tả các sản phẩm đã mua (tùy chọn)"
rows="3"></textarea>
</div>-->
<!-- Points Estimate -->
<div class="points-estimate" id="pointsEstimate">
<div class="estimate-title">Điểm dự kiến nhận được</div>
<div class="estimate-text" id="estimateText">0 điểm</div>
</div>
<!-- Company Information --> <!-- Company Information -->
<div class="form-group"> <div class="form-group">
<label class="form-label">Tên công ty</label> <label class="form-label">Tên đơn vị mua hàng</label>
<input type="text" <input type="text"
class="form-input" class="form-input"
id="companyName" id="companyName"
@@ -454,26 +536,41 @@
id="taxCode" id="taxCode"
placeholder="Nhập mã số thuế (nếu có)"> placeholder="Nhập mã số thuế (nếu có)">
</div> </div>
<!-- Dynamic Product List -->
<div class="form-group"> <div class="form-group">
<label class="form-label">Số lượng (m²) đã mua</label> <label class="form-label required">Danh sách sản phẩm</label>
<input type="number" <div id="productsList">
class="form-input" <!-- Product rows will be added here dynamically -->
id="squareMeters" </div>
placeholder="0" <button type="button" onclick="addProductRow()" class="btn-add-product">
min="0" <i class="fas fa-plus-circle"></i>
step="0.01"> Thêm sản phẩm
</button>
</div> </div>
<!-- Products Purchased --> <!-- Order Summary (Auto-calculated) -->
<div class="form-group"> <div class="summary-card">
<label class="form-label">Sản phẩm đã mua</label> <h3 style="font-size: 16px; font-weight: 600; color: #333; margin-bottom: 16px;">
<textarea class="form-input form-textarea" <i class="fas fa-calculator" style="color: #005B9A; margin-right: 8px;"></i>
id="products" Tổng kết đơn hàng
placeholder="Mô tả các sản phẩm đã mua (tùy chọn)" </h3>
rows="3"></textarea> <div style="display: flex; flex-direction: column; gap: 12px;">
<div style="display: flex; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px dashed #e5e7eb;">
<span style="color: #666; font-size: 15px;">Tổng số lượng:</span>
<span id="totalSquareMeters" style="color: #333; font-weight: 600; font-size: 15px;">0 m²</span>
</div>
<div style="display: flex; justify-content: space-between;">
<span style="color: #666; font-size: 15px;">Tổng giá trị đơn hàng:</span>
<span id="totalAmount" style="color: #005B9A; font-weight: 700; font-size: 18px;">0 đ</span>
</div>
</div>
</div> </div>
<!-- Points Estimate -->
<div class="points-estimate" id="pointsEstimate">
<div class="estimate-title">Điểm dự kiến nhận được</div>
<div class="estimate-text" id="estimateText">0 điểm</div>
</div>
<!-- Invoice Images --> <!-- Invoice Images -->
<div class="form-group"> <div class="form-group">
@@ -504,13 +601,13 @@
</div> </div>
<!-- Additional Notes --> <!-- Additional Notes -->
<div class="form-group"> <!--<div class="form-group">
<label class="form-label">Ghi chú thêm</label> <label class="form-label">Ghi chú thêm</label>
<textarea class="form-input form-textarea" <textarea class="form-input form-textarea"
id="notes" id="notes"
placeholder="Ghi chú thêm về đơn hàng (tùy chọn)" placeholder="Ghi chú thêm về đơn hàng (tùy chọn)"
rows="3"></textarea> rows="3"></textarea>
</div> </div>-->
<!-- Submit Button --> <!-- Submit Button -->
<button type="submit" class="submit-button" id="submitButton" disabled> <button type="submit" class="submit-button" id="submitButton" disabled>
@@ -523,26 +620,153 @@
<script> <script>
let selectedFiles = []; let selectedFiles = [];
let productCounter = 0;
let products = [];
// Set max date to today // Set max date to today
document.getElementById('purchaseDate').max = new Date().toISOString().split('T')[0]; document.getElementById('purchaseDate').max = new Date().toISOString().split('T')[0];
// Add first product row on page load
window.addEventListener('DOMContentLoaded', function() {
addProductRow();
});
function goBack() { function goBack() {
window.history.back(); window.history.back();
} }
function addProductRow() {
productCounter++;
const productsList = document.getElementById('productsList');
const productRow = document.createElement('div');
productRow.className = 'product-row';
productRow.id = `product-${productCounter}`;
productRow.innerHTML = `
<div class="product-row-header">
<span class="product-row-title">
<i class="fas fa-box"></i> Sản phẩm #${productCounter}
</span>
<button type="button" onclick="removeProductRow(${productCounter})" class="btn-remove-product">
<i class="fas fa-trash"></i> Xóa
</button>
</div>
<div class="product-input-full">
<label class="product-label required">Tên sản phẩm</label>
<input type="text"
class="form-input"
id="productName-${productCounter}"
placeholder="Ví dụ: Gạch Granite 60x60"
required
onchange="updateCalculations()">
</div>
<div class="product-input-group">
<div>
<label class="product-label required">Số lượng (m²)</label>
<input type="number"
class="form-input"
id="productQty-${productCounter}"
placeholder="0"
min="0"
step="0.01"
required
oninput="updateCalculations()">
</div>
<div>
<label class="product-label required">Đơn giá (VNĐ/m²)</label>
<input type="number"
class="form-input"
id="productPrice-${productCounter}"
placeholder="0"
min="0"
step="1000"
required
oninput="updateCalculations()">
</div>
</div>
<div class="product-subtotal">
<div class="product-subtotal-label">Thành tiền</div>
<div class="product-subtotal-value" id="productSubtotal-${productCounter}">0 đ</div>
</div>
`;
productsList.appendChild(productRow);
products.push(productCounter);
updateCalculations();
}
function removeProductRow(id) {
if (products.length <= 1) {
alert('Cần ít nhất một sản phẩm!');
return;
}
const row = document.getElementById(`product-${id}`);
if (row) {
row.remove();
products = products.filter(p => p !== id);
updateCalculations();
}
}
function updateCalculations() {
let totalQty = 0;
let totalValue = 0;
products.forEach(id => {
const qtyInput = document.getElementById(`productQty-${id}`);
const priceInput = document.getElementById(`productPrice-${id}`);
const subtotalEl = document.getElementById(`productSubtotal-${id}`);
if (qtyInput && priceInput && subtotalEl) {
const qty = parseFloat(qtyInput.value) || 0;
const price = parseFloat(priceInput.value) || 0;
const subtotal = qty * price;
totalQty += qty;
totalValue += subtotal;
subtotalEl.textContent = formatCurrency(subtotal);
}
});
// Update summary
document.getElementById('totalSquareMeters').textContent = totalQty.toFixed(2) + ' m²';
document.getElementById('totalAmount').textContent = formatCurrency(totalValue);
// Calculate points
calculatePoints(totalValue);
validateForm();
}
function formatCurrency(value) {
return new Intl.NumberFormat('vi-VN', {
style: 'currency',
currency: 'VND',
minimumFractionDigits: 0
}).format(value);
}
function validateForm() { function validateForm() {
const purchaseDate = document.getElementById('purchaseDate').value; const purchaseDate = document.getElementById('purchaseDate').value;
const storeLocation = document.getElementById('storeLocation').value;
const totalAmount = document.getElementById('totalAmount').value;
const hasFiles = selectedFiles.length > 0; const hasFiles = selectedFiles.length > 0;
const isValid = purchaseDate && storeLocation && totalAmount && hasFiles; // Check if at least one product is filled
let hasValidProduct = false;
products.forEach(id => {
const name = document.getElementById(`productName-${id}`).value;
const qty = document.getElementById(`productQty-${id}`).value;
const price = document.getElementById(`productPrice-${id}`).value;
if (name && qty && price) {
hasValidProduct = true;
}
});
const isValid = purchaseDate && hasValidProduct && hasFiles;
document.getElementById('submitButton').disabled = !isValid; document.getElementById('submitButton').disabled = !isValid;
} }
function calculatePoints() { function calculatePoints(totalAmount) {
const totalAmount = document.getElementById('totalAmount').value;
const pointsEstimate = document.getElementById('pointsEstimate'); const pointsEstimate = document.getElementById('pointsEstimate');
const estimateText = document.getElementById('estimateText'); const estimateText = document.getElementById('estimateText');

View File

@@ -28,6 +28,7 @@ import 'package:worker/features/chat/presentation/pages/chat_list_page.dart';
import 'package:worker/features/favorites/presentation/pages/favorites_page.dart'; import 'package:worker/features/favorites/presentation/pages/favorites_page.dart';
import 'package:worker/features/loyalty/presentation/pages/loyalty_page.dart'; import 'package:worker/features/loyalty/presentation/pages/loyalty_page.dart';
import 'package:worker/features/loyalty/presentation/pages/points_history_page.dart'; import 'package:worker/features/loyalty/presentation/pages/points_history_page.dart';
import 'package:worker/features/loyalty/presentation/pages/points_record_create_page.dart';
import 'package:worker/features/loyalty/presentation/pages/points_records_page.dart'; import 'package:worker/features/loyalty/presentation/pages/points_records_page.dart';
import 'package:worker/features/loyalty/presentation/pages/rewards_page.dart'; import 'package:worker/features/loyalty/presentation/pages/rewards_page.dart';
import 'package:worker/features/main/presentation/pages/main_scaffold.dart'; import 'package:worker/features/main/presentation/pages/main_scaffold.dart';
@@ -323,6 +324,14 @@ final routerProvider = Provider<GoRouter>((ref) {
MaterialPage(key: state.pageKey, child: const PointsRecordsPage()), MaterialPage(key: state.pageKey, child: const PointsRecordsPage()),
), ),
// Points Record Create Route
GoRoute(
path: RouteNames.pointsRecordCreate,
name: 'loyalty_points_record_create',
pageBuilder: (context, state) =>
MaterialPage(key: state.pageKey, child: const PointsRecordCreatePage()),
),
// Orders Route // Orders Route
GoRoute( GoRoute(
path: RouteNames.orders, path: RouteNames.orders,
@@ -651,6 +660,7 @@ class RouteNames {
static const String rewards = '$loyalty/rewards'; static const String rewards = '$loyalty/rewards';
static const String pointsHistory = '$loyalty/points-history'; static const String pointsHistory = '$loyalty/points-history';
static const String pointsRecords = '$loyalty/points-records'; static const String pointsRecords = '$loyalty/points-records';
static const String pointsRecordCreate = '$loyalty/points-records/create';
static const String myGifts = '$loyalty/gifts'; static const String myGifts = '$loyalty/gifts';
static const String referral = '$loyalty/referral'; static const String referral = '$loyalty/referral';

View File

@@ -8,11 +8,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:worker/core/widgets/loading_indicator.dart';
import 'package:worker/core/constants/ui_constants.dart'; import 'package:worker/core/constants/ui_constants.dart';
import 'package:worker/core/database/models/enums.dart';
import 'package:worker/core/theme/colors.dart'; import 'package:worker/core/theme/colors.dart';
import 'package:worker/features/loyalty/data/datasources/points_history_local_datasource.dart'; import 'package:worker/core/widgets/loading_indicator.dart';
import 'package:worker/features/loyalty/data/models/loyalty_point_entry_model.dart'; import 'package:worker/features/loyalty/data/models/loyalty_point_entry_model.dart';
import 'package:worker/features/loyalty/presentation/providers/points_history_provider.dart'; import 'package:worker/features/loyalty/presentation/providers/points_history_provider.dart';
@@ -20,9 +18,8 @@ import 'package:worker/features/loyalty/presentation/providers/points_history_pr
/// ///
/// Features: /// Features:
/// - Filter section with date range /// - Filter section with date range
/// - List of transaction cards /// - List of transaction cards with new design
/// - Each card shows: description, date, amount, points change, new balance /// - Each card shows: code, date, description, reference, points change, balance after
/// - Complaint button for each transaction
class PointsHistoryPage extends ConsumerWidget { class PointsHistoryPage extends ConsumerWidget {
const PointsHistoryPage({super.key}); const PointsHistoryPage({super.key});
@@ -57,10 +54,8 @@ class PointsHistoryPage extends ConsumerWidget {
return _buildEmptyState(colorScheme); return _buildEmptyState(colorScheme);
} }
return SingleChildScrollView( return ListView(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Filter Section // Filter Section
_buildFilterSection(colorScheme), _buildFilterSection(colorScheme),
@@ -69,10 +64,9 @@ class PointsHistoryPage extends ConsumerWidget {
// Transaction List // Transaction List
...entries.map( ...entries.map(
(entry) => _buildTransactionCard(context, ref, entry, colorScheme), (entry) => _buildTransactionCard(context, entry, colorScheme),
), ),
], ],
),
); );
}, },
loading: () => const CustomLoadingIndicator(), loading: () => const CustomLoadingIndicator(),
@@ -89,12 +83,12 @@ class PointsHistoryPage extends ConsumerWidget {
margin: EdgeInsets.zero, margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding( child: Padding(
padding: const EdgeInsets.all(20), padding: const EdgeInsets.all(16),
child: Column( child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
'Bộ lọc', 'Bộ lọc',
@@ -104,160 +98,163 @@ class PointsHistoryPage extends ConsumerWidget {
color: colorScheme.onSurface, color: colorScheme.onSurface,
), ),
), ),
FaIcon(FontAwesomeIcons.sliders, color: colorScheme.primary, size: 18), const SizedBox(height: 4),
],
),
const SizedBox(height: 8),
Text( Text(
'Thời gian hiệu lực: 01/01/2023 - 31/12/2023', 'Thời gian hiệu lực: 01/01/2023 - 31/12/2023',
style: TextStyle(fontSize: 12, color: colorScheme.onSurfaceVariant), style: TextStyle(fontSize: 12, color: colorScheme.onSurfaceVariant),
), ),
], ],
), ),
FaIcon(FontAwesomeIcons.filter, color: colorScheme.primary, size: 18),
],
),
), ),
); );
} }
/// Build transaction card /// Build transaction card with new design
Widget _buildTransactionCard( Widget _buildTransactionCard(
BuildContext context, BuildContext context,
WidgetRef ref,
LoyaltyPointEntryModel entry, LoyaltyPointEntryModel entry,
ColorScheme colorScheme, ColorScheme colorScheme,
) { ) {
final dateFormatter = DateFormat('dd/MM/yyyy HH:mm:ss'); final dateFormatter = DateFormat('dd/MM/yyyy');
final currencyFormatter = NumberFormat.currency(
locale: 'vi_VN',
symbol: 'VND',
decimalDigits: 0,
);
// Get transaction amount if it's a purchase // Determine points color
final datasource = ref.read(pointsHistoryLocalDataSourceProvider); Color pointsColor;
final transactionAmount = datasource.getTransactionAmount( String pointsPrefix;
entry.description, if (entry.points > 0) {
); pointsColor = AppColors.success;
pointsPrefix = '+';
} else if (entry.points < 0) {
pointsColor = AppColors.danger;
pointsPrefix = '';
} else {
pointsColor = colorScheme.onSurfaceVariant;
pointsPrefix = '';
}
return Card( return Card(
elevation: 1, elevation: 1,
margin: const EdgeInsets.only(bottom: 12), margin: const EdgeInsets.only(bottom: 12),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding( clipBehavior: Clip.antiAlias,
padding: const EdgeInsets.all(16),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Top row: Description and Complaint button // Header: Code and Date
Row( Container(
crossAxisAlignment: CrossAxisAlignment.start, padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
decoration: BoxDecoration(
color: colorScheme.surfaceContainerHighest.withValues(alpha: 0.5),
border: Border(
bottom: BorderSide(
color: colorScheme.outlineVariant,
width: 1,
),
),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Text(
entry.entryId,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w700,
color: colorScheme.primary,
),
),
Text(
dateFormatter.format(entry.timestamp),
style: TextStyle(
fontSize: 12,
color: colorScheme.onSurfaceVariant,
),
),
],
),
),
// Content: Description and Points
Padding(
padding: const EdgeInsets.all(16),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
// Description
Expanded( Expanded(
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
// Description
Text( Text(
entry.description, entry.description,
style: TextStyle( style: TextStyle(
fontSize: 15, fontSize: 14,
fontWeight: FontWeight.w500, fontWeight: FontWeight.w600,
color: colorScheme.primary, color: colorScheme.onSurface,
), ),
), ),
const SizedBox(height: 4), const SizedBox(height: 4),
// Timestamp
Text( Text(
'Thời gian: ${dateFormatter.format(entry.timestamp)}', 'Mã tham chiếu: #${entry.entryId}',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 13,
color: colorScheme.onSurfaceVariant,
),
),
// Transaction amount (if purchase)
if (transactionAmount != null) ...[
const SizedBox(height: 2),
Text(
'Giao dịch: ${currencyFormatter.format(transactionAmount)}',
style: TextStyle(
fontSize: 12,
color: colorScheme.onSurfaceVariant, color: colorScheme.onSurfaceVariant,
), ),
), ),
], ],
),
),
const SizedBox(width: 16),
// Points
Text(
'$pointsPrefix${entry.points} điểm',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w700,
color: pointsColor,
),
),
], ],
), ),
), ),
const SizedBox(width: 12), // Footer: Balance After
Container(
// Complaint button padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
OutlinedButton( decoration: BoxDecoration(
onPressed: () { color: colorScheme.surfaceContainerLowest,
ScaffoldMessenger.of(context).showSnackBar( border: Border(
const SnackBar( top: BorderSide(
content: Text('Chức năng khiếu nại đang phát triển'), color: colorScheme.outlineVariant.withValues(alpha: 0.5),
), width: 1,
);
},
style: OutlinedButton.styleFrom(
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 6,
),
side: BorderSide(color: colorScheme.onSurfaceVariant),
foregroundColor: colorScheme.onSurface,
textStyle: const TextStyle(fontSize: 12),
minimumSize: const Size(0, 32),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(6),
), ),
), ),
child: const Text('Khiếu nại'),
), ),
], child: Row(
),
const SizedBox(height: 12),
// Bottom row: Points change and new balance
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
// Points change
Text( Text(
entry.points > 0 ? '+${entry.points}' : '${entry.points}', 'Số dư sau: ',
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 13,
fontWeight: FontWeight.w500, color: colorScheme.onSurfaceVariant,
color: entry.points > 0
? AppColors.success
: entry.points < 0
? AppColors.danger
: colorScheme.onSurface,
), ),
), ),
const SizedBox(height: 2),
// New balance
Text( Text(
'Điểm mới: ${entry.balanceAfter}', '${entry.balanceAfter} điểm',
style: TextStyle( style: TextStyle(
fontSize: 12, fontSize: 13,
fontWeight: FontWeight.w600,
color: colorScheme.primary, color: colorScheme.primary,
), ),
), ),
], ],
), ),
],
), ),
], ],
), ),
),
); );
} }
@@ -293,7 +290,6 @@ class PointsHistoryPage extends ConsumerWidget {
/// Build error state /// Build error state
Widget _buildErrorState(Object error, ColorScheme colorScheme) { Widget _buildErrorState(Object error, ColorScheme colorScheme) {
print(error.toString());
return Center( return Center(
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

File diff suppressed because it is too large Load Diff

View File

@@ -8,9 +8,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:go_router/go_router.dart'; import 'package:go_router/go_router.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:worker/core/widgets/loading_indicator.dart';
import 'package:worker/core/constants/ui_constants.dart'; import 'package:worker/core/constants/ui_constants.dart';
import 'package:worker/core/router/app_router.dart';
import 'package:worker/core/theme/colors.dart'; import 'package:worker/core/theme/colors.dart';
import 'package:worker/core/widgets/loading_indicator.dart';
import 'package:worker/features/loyalty/domain/entities/points_record.dart'; import 'package:worker/features/loyalty/domain/entities/points_record.dart';
import 'package:worker/features/loyalty/presentation/providers/points_records_provider.dart'; import 'package:worker/features/loyalty/presentation/providers/points_records_provider.dart';
@@ -47,13 +48,12 @@ class PointsRecordsPage extends ConsumerWidget {
color: colorScheme.onSurface, color: colorScheme.onSurface,
size: 20, size: 20,
), ),
onPressed: () { onPressed: () async {
// TODO: Navigate to points record create page final result = await context.push<bool>(RouteNames.pointsRecordCreate);
ScaffoldMessenger.of(context).showSnackBar( if (result == true) {
const SnackBar( // Refresh list after successful creation
content: Text('Tính năng tạo ghi nhận điểm sẽ được cập nhật'), ref.invalidate(allPointsRecordsProvider);
), }
);
}, },
), ),
const SizedBox(width: AppSpacing.sm), const SizedBox(width: AppSpacing.sm),