{% extends 'base.html' %}
{% block title %}用户中心{% endblock %}
{% block content %}
<div class="row">
  <div class="col-md-6">
    <h4 class="mb-3">资料维护</h4>
    <form method="post">
      {% csrf_token %}
      <div class="mb-3">
        <label class="form-label">显示名称</label>
        {{ form.display_name }}
      </div>
      <div class="mb-3">
        <label class="form-label">联系电话</label>
        {{ form.contact_phone }}
      </div>
      <button class="btn btn-primary" type="submit">保存</button>
      <a class="btn btn-outline-info ms-2" href="{% url 'accounts:password_change' %}">修改密码</a>
      <a class="btn btn-outline-secondary ms-2" href="{% url 'accounts:login_history' %}">登录历史</a>
    </form>
  </div>
  <div class="col-md-6">
    <h4 class="mb-3">最近登录记录</h4>
    <table class="table table-sm">
      <thead><tr><th>时间</th><th>IP</th><th>User-Agent</th></tr></thead>
      <tbody>
        {% for r in records %}
        <tr>
          <td>{{ r.created_at }}</td>
          <td>{{ r.ip_address|default:"-" }}</td>
          <td>{{ r.user_agent }}</td>
        </tr>
        {% empty %}
        <tr><td colspan="3" class="text-muted">暂无登录记录</td></tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
</div>
{% endblock %}