# account/points

> Điểm thưởng và lịch sử tích/tiêu điểm.

Điểm thưởng và lịch sử tích/tiêu điểm.

- **Tệp giao diện:** `account/points.html`
- **Đường dẫn:** `/tai-khoan/diem-thuong`
- **Controller:** `App\Modules\Account\AccountController::pointsPage`

Ngoài những biến dưới đây, slot này còn nhận toàn bộ [biến toàn cục](/docs/bien-toan-cuc/index.md).

## Biến của trang

| Biến | Kiểu | Mô tả | Từ phiên bản |
|---|---|---|---|
| `balance` | `integer` | Số điểm hiện có. | 1.0 |
| `ledger` | [`PointEntry[]`](/docs/doi-tuong/pointentry/index.md) | Lịch sử biến động điểm. | 1.0 |
| `has_more` | `boolean` | Còn trang tiếp theo hay không. | 1.0 |
| `next_cursor` | `string` \| `null` | Con trỏ để tải trang kế; null khi đã hết. | 1.0 |

## Mã đầy đủ

Toàn bộ tệp `account/points.html` của bộ giao diện mặc định. Chép về `templates/<bộ giao diện của bạn>/account/points.html` rồi sửa theo ý muốn.

```liquid
<div class="container page-content">
  <h1 class="page-title">Điểm thưởng</h1>
  <div class="account-layout">
    {% assign active_page = 'points' %}
    {% include 'account/_sidebar' %}
    <div class="account-main">
      <div class="points-balance">
        <span class="points-balance__value">{{ balance | escape }}</span>
        <span class="points-balance__label">điểm</span>
      </div>

      {% if ledger %}
        <h2 class="account-section__title">Lịch sử điểm</h2>
        <table class="data-table">
          <thead>
            <tr><th>Loại</th><th>Thay đổi</th><th>Số dư sau</th><th>Ghi chú</th><th>Ngày</th></tr>
          </thead>
          <tbody>
            {% for entry in ledger %}
              <tr>
                <td>{{ entry.event_type | escape }}</td>
                <td class="{% if entry.delta > 0 %}text--green{% else %}text--red{% endif %}">
                  {% if entry.delta > 0 %}+{% endif %}{{ entry.delta | escape }}
                </td>
                <td>{{ entry.balance_after | escape }}</td>
                <td>{{ entry.note | default: '—' | escape }}</td>
                <td>{{ entry.created_at | date: '%d/%m/%Y' }}</td>
              </tr>
            {% endfor %}
          </tbody>
        </table>
        {% if has_more %}
          <a href="/tai-khoan/diem-thuong?cursor={{ next_cursor | escape }}" class="btn btn--outline">Xem thêm</a>
        {% endif %}
      {% else %}
        <p class="empty-state">Chưa có giao dịch điểm nào.</p>
      {% endif %}
    </div>
  </div>
</div>
```
