@extends('theme::layout')

@section('content')
    <div class="panel article-body">
        <h1 class="page-title">个人资料</h1>
        @if ($errors->any())
            <ul class="flash">
                @foreach($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        @endif
        <p class="meta">用户名：{{ $user->username ?: $user->name }}</p>
        @if(!empty($membership))
            <div class="panel" style="margin: 1rem 0; padding: 0.75rem 1rem; background: #eef7f6;">
                @if($membership['active'] ?? false)
                    <p>{{ __('frontend.membership.active', ['plan' => $membership['plan_name'] ?? '—']) }}</p>
                    @if(!empty($membership['expires_at']))
                        <p class="meta">{{ __('frontend.membership.expires', ['date' => $membership['expires_at']]) }}</p>
                    @else
                        <p class="meta">{{ __('frontend.membership.lifetime') }}</p>
                    @endif
                @else
                    <p>{{ __('frontend.membership.inactive') }}</p>
                @endif
                <p class="meta"><a href="{{ url('/plugins/membership') }}">{{ __('frontend.membership.manage') }}</a></p>
            </div>
        @endif
        <form class="stack" method="post" action="{{ url('/post.php') }}">
            @csrf
            <input type="hidden" name="action" value="modpro">
            <label>邮箱</label>
            <input type="email" name="email" value="{{ old('email', $user->email) }}">
            <label>网站</label>
            <input type="url" name="url" value="{{ old('url', $user->url) }}">
            <label>新密码（留空不改）</label>
            <input type="password" name="password">
            <label>确认新密码</label>
            <input type="password" name="password_confirmation">
            <button type="submit">保存</button>
        </form>
        <form class="stack" method="post" action="{{ url('/post.php') }}">
            @csrf
            <input type="hidden" name="action" value="logout">
            <button type="submit">退出登录</button>
        </form>
    </div>
@endsection
