105 lines
4.6 KiB
PHP

@extends('admin.layouts.app')
@section('title', '관리자 계정 관리')
@section('content_class', 'a-content--full')
@section('content')
<div class="a-panel">
<div style="display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap;">
<div>
<div style="font-weight:900; font-size:16px;">관리자 계정 관리</div>
<div class="a-muted" style="font-size:12px; margin-top:4px;">계정/2FA/최근로그인/역할 정보를 관리합니다.</div>
</div>
<div style="display:flex; gap:8px; flex-wrap:wrap; align-items:center;">
<a class="a-btn a-btn--ghost a-btn--sm"
href="{{ route('admin.admins.create', request()->only(['q','status','page'])) }}"
style="width:auto; padding:12px 14px;">
관리자 등록
</a>
<form method="GET" action="{{ route('admin.admins.index') }}" style="display:flex; gap:8px; flex-wrap:wrap;">
<input class="a-input" name="q" value="{{ $filters['q'] ?? '' }}" placeholder="이메일/성명/닉네임 검색" style="width:240px;">
<select class="a-input" name="status" style="width:160px;">
<option value="">상태(전체)</option>
<option value="active" {{ (($filters['status'] ?? '')==='active')?'selected':'' }}>활성 관리자</option>
<option value="blocked" {{ (($filters['status'] ?? '')==='blocked')?'selected':'' }}>비활성 관리자</option>
</select>
<button class="a-btn a-btn--primary" type="submit" style="width:auto; padding:12px 14px;">검색</button>
</form>
</div>
</div>
</div>
<div style="height:12px;"></div>
<table class="a-table a-table--admins">
<thead>
<tr>
<th style="width:80px;">ID</th>
<th>닉네임</th>
<th>성명</th>
<th>이메일</th>
<th style="width:120px;">상태</th>
<th style="width:120px;">잠금</th>
<th style="width:120px;">2FA 모드</th>
<th style="width:110px;">TOTP</th>
<th>역할</th>
<th style="width:170px;">최근 로그인</th>
<th style="width:90px;">관리</th>
</tr>
</thead>
<tbody>
@forelse($page as $u)
@php
$uid = (int)$u->id;
$roles = $roleMap[$uid] ?? [];
$pc = $permCnt[$uid] ?? 0;
@endphp
<tr class="{{ (($u->status ?? '') === 'blocked') ? 'is-disabled' : '' }}">
<td class="a-td--muted">{{ $uid }}</td>
<td>{{ $u->nickname ?? '-' }}</td>
<td>{{ $u->name ?? '-' }}</td>
<td>{{ $u->email ?? '-' }}</td>
@php
$st = (string)($u->status ?? '');
$stLabel = $st === 'active' ? '활성' : ($st === 'blocked' ? '비활성' : ($st ?: '-'));
@endphp
<td class="a-td--status {{ $st === 'blocked' ? 'is-bad' : '' }}">
{{ $stLabel }}
</td>
@php
$isLocked = !empty($u->locked_until);
@endphp
<td style="font-weight:800;">
@if($isLocked)
<span style="color:#ff4d4f;">계정잠금</span>
@else
<span style="color:rgba(255,255,255,.80);">계정정상</span>
@endif
</td>
<td>{{ $u->two_factor_mode ?? 'sms' }}</td>
<td>{{ (int)($u->totp_enabled ?? 0) === 1 ? 'On' : 'Off' }}</td>
<td>
@forelse($roles as $r)
<span class="a-chip">{{ $r['name'] ?? $r['code'] }}</span>
@empty
<span class="a-muted">-</span>
@endforelse
</td>
<td>{{ $u->last_login_at ?? '-' }}</td>
<td>
<a class="a-btn a-btn--ghost a-btn--sm" style="width:auto; padding:8px 10px;"
href="{{ route('admin.admins.edit', ['id'=>$uid]) }}">보기</a>
</td>
</tr>
@empty
<tr><td colspan="11" class="a-muted" style="padding:18px;">데이터가 없습니다.</td></tr>
@endforelse
</tbody>
</table>
<div style="margin-top:14px;">
{{ $page->links() }}
</div>
@endsection