web: migrate health notifications to js_interop; add browser hook
- Replace dart:js with package:js in health_check_service_web.dart\n- Implement showHealthCheckNotification in web/index.html\n- Pin js dependency to ^0.6.7 for flutter_secure_storage_web compatibility auth: harden AuthInterceptor + tests - Allow overrideAuthRepository injection for testing\n- Normalize imports to package: paths\n- Add unit test covering token attach, 401→refresh→retry, and failure path\n- Add integration test skeleton gated by env vars ui/data: map User.companyName to list column - Add companyName to domain User\n- Map UserDto.company?.name\n- Render companyName in user_list cleanup: remove legacy equipment table + unused code; minor warnings - Remove _buildFlexibleTable and unused helpers\n- Remove unused zipcode details and cache retry constant\n- Fix null-aware and non-null assertions\n- Address child-last warnings in administrator dialog docs: update AGENTS.md session context
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:superport/screens/user/controllers/user_form_controller.dart';
|
||||
import 'package:superport/utils/formatters/korean_phone_formatter.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_dropdown.dart';
|
||||
import 'package:superport/screens/common/templates/form_layout_template.dart';
|
||||
|
||||
// 사용자 등록/수정 화면 (UI만 담당, 상태/로직 분리)
|
||||
class UserFormScreen extends StatefulWidget {
|
||||
@@ -39,17 +40,37 @@ class _UserFormScreenState extends State<UserFormScreen> {
|
||||
},
|
||||
child: Consumer<UserFormController>(
|
||||
builder: (context, controller, child) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(controller.isEditMode ? '사용자 수정' : '사용자 등록'),
|
||||
),
|
||||
body: controller.isLoading
|
||||
// Phase 10: FormLayoutTemplate 적용
|
||||
return FormLayoutTemplate(
|
||||
title: controller.isEditMode ? '사용자 수정' : '사용자 등록',
|
||||
isLoading: controller.isLoading,
|
||||
onSave: () async {
|
||||
// 폼 검증
|
||||
if (!controller.formKey.currentState!.validate()) {
|
||||
return;
|
||||
}
|
||||
controller.formKey.currentState!.save();
|
||||
|
||||
// 사용자 저장
|
||||
bool success = false;
|
||||
await controller.saveUser((error) {
|
||||
if (error == null) {
|
||||
success = true;
|
||||
} else {
|
||||
// 에러 처리는 controller에서 관리
|
||||
}
|
||||
});
|
||||
|
||||
if (success && mounted) {
|
||||
Navigator.of(context).pop(true);
|
||||
}
|
||||
},
|
||||
onCancel: () => Navigator.of(context).pop(),
|
||||
child: controller.isLoading
|
||||
? const Center(child: ShadProgress())
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Form(
|
||||
key: controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
: Form(
|
||||
key: controller.formKey,
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
@@ -85,32 +106,35 @@ class _UserFormScreenState extends State<UserFormScreen> {
|
||||
// 회사 선택 (*필수)
|
||||
_buildCompanyDropdown(controller),
|
||||
|
||||
const SizedBox(height: 24),
|
||||
|
||||
// 중복 검사 상태 메시지 영역 (고정 높이)
|
||||
SizedBox(
|
||||
height: 40,
|
||||
child: Center(
|
||||
child: controller.isCheckingEmailDuplicate
|
||||
? const Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadProgress(),
|
||||
SizedBox(width: 8),
|
||||
Text('중복 검사 중...'),
|
||||
],
|
||||
)
|
||||
: controller.emailDuplicateMessage != null
|
||||
? Text(
|
||||
controller.emailDuplicateMessage!,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
// 중복 검사 상태 메시지 영역
|
||||
if (controller.isCheckingEmailDuplicate)
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ShadProgress(),
|
||||
SizedBox(width: 8),
|
||||
Text('중복 검사 중...'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
if (controller.emailDuplicateMessage != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16),
|
||||
child: Center(
|
||||
child: Text(
|
||||
controller.emailDuplicateMessage!,
|
||||
style: const TextStyle(
|
||||
color: Colors.red,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// 오류 메시지 표시
|
||||
if (controller.error != null)
|
||||
@@ -121,22 +145,10 @@ class _UserFormScreenState extends State<UserFormScreen> {
|
||||
description: Text(controller.error!),
|
||||
),
|
||||
),
|
||||
// 저장 버튼
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
child: ShadButton(
|
||||
onPressed: controller.isLoading || controller.isCheckingEmailDuplicate
|
||||
? null
|
||||
: () => _onSaveUser(controller),
|
||||
size: ShadButtonSize.lg,
|
||||
child: Text(controller.isEditMode ? '수정하기' : '등록하기'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -153,7 +165,6 @@ class _UserFormScreenState extends State<UserFormScreen> {
|
||||
String? Function(String?)? validator,
|
||||
void Function(String?)? onSaved,
|
||||
void Function(String)? onChanged,
|
||||
Widget? suffixIcon,
|
||||
}) {
|
||||
final controller = TextEditingController(text: initialValue.isNotEmpty ? initialValue : '');
|
||||
return Padding(
|
||||
@@ -247,45 +258,4 @@ class _UserFormScreenState extends State<UserFormScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// 저장 버튼 클릭 시 사용자 저장
|
||||
void _onSaveUser(UserFormController controller) async {
|
||||
// 먼저 폼 유효성 검사
|
||||
if (controller.formKey.currentState?.validate() != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 폼 데이터 저장
|
||||
controller.formKey.currentState?.save();
|
||||
|
||||
// 이메일 중복 검사 (저장 시점)
|
||||
final emailIsUnique = await controller.checkDuplicateEmail(controller.email);
|
||||
|
||||
if (!emailIsUnique) {
|
||||
// 중복이 발견되면 저장하지 않음
|
||||
return;
|
||||
}
|
||||
|
||||
// 이메일 중복이 없으면 저장 진행
|
||||
await controller.saveUser((error) {
|
||||
if (error != null) {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast.destructive(
|
||||
title: const Text('오류'),
|
||||
description: Text(error),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
ShadToaster.of(context).show(
|
||||
ShadToast(
|
||||
title: const Text('성공'),
|
||||
description: Text(
|
||||
controller.isEditMode ? '사용자 정보가 수정되었습니다' : '사용자가 등록되었습니다',
|
||||
),
|
||||
),
|
||||
);
|
||||
Navigator.pop(context, true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import 'package:superport/models/user_model.dart';
|
||||
import 'package:superport/screens/common/theme_shadcn.dart';
|
||||
import 'package:superport/screens/common/components/shadcn_components.dart';
|
||||
import 'package:superport/screens/common/layouts/base_list_screen.dart';
|
||||
import 'package:superport/screens/common/widgets/standard_action_bar.dart';
|
||||
import 'package:superport/screens/common/widgets/pagination.dart';
|
||||
@@ -55,24 +54,28 @@ class _UserListState extends State<UserList> {
|
||||
/// 사용자 권한 표시 배지
|
||||
Widget _buildUserRoleBadge(UserRole role) {
|
||||
final roleName = role.displayName;
|
||||
ShadcnBadgeVariant variant;
|
||||
Color backgroundColor;
|
||||
Color foregroundColor;
|
||||
|
||||
switch (role) {
|
||||
case UserRole.admin:
|
||||
variant = ShadcnBadgeVariant.destructive;
|
||||
backgroundColor = ShadcnTheme.alertCritical7.withValues(alpha: 0.1);
|
||||
foregroundColor = ShadcnTheme.alertCritical7;
|
||||
break;
|
||||
case UserRole.manager:
|
||||
variant = ShadcnBadgeVariant.primary;
|
||||
backgroundColor = ShadcnTheme.companyHeadquarters.withValues(alpha: 0.1);
|
||||
foregroundColor = ShadcnTheme.companyHeadquarters;
|
||||
break;
|
||||
case UserRole.staff:
|
||||
variant = ShadcnBadgeVariant.secondary;
|
||||
backgroundColor = ShadcnTheme.equipmentDisposal.withValues(alpha: 0.1);
|
||||
foregroundColor = ShadcnTheme.equipmentDisposal;
|
||||
break;
|
||||
}
|
||||
|
||||
return ShadcnBadge(
|
||||
text: roleName,
|
||||
variant: variant,
|
||||
size: ShadcnBadgeSize.small,
|
||||
return ShadBadge(
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
child: Text(roleName),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -202,21 +205,21 @@ class _UserListState extends State<UserList> {
|
||||
'전체 사용자',
|
||||
_controller.total.toString(),
|
||||
Icons.people,
|
||||
ShadcnTheme.primary,
|
||||
ShadcnTheme.companyHeadquarters,
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing4),
|
||||
_buildStatCard(
|
||||
'활성 사용자',
|
||||
_controller.users.where((u) => u.isActive).length.toString(),
|
||||
Icons.check_circle,
|
||||
ShadcnTheme.success,
|
||||
ShadcnTheme.equipmentIn,
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing4),
|
||||
_buildStatCard(
|
||||
'비활성 사용자',
|
||||
_controller.users.where((u) => !u.isActive).length.toString(),
|
||||
Icons.person_off,
|
||||
ShadcnTheme.mutedForeground,
|
||||
ShadcnTheme.equipmentDisposal,
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -265,203 +268,92 @@ class _UserListState extends State<UserList> {
|
||||
Widget _buildDataTable() {
|
||||
final users = _controller.users;
|
||||
|
||||
if (users.isEmpty) {
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.people_outlined,
|
||||
size: 64,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'등록된 사용자가 없습니다',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
border: Border.all(color: ShadcnTheme.border),
|
||||
borderRadius: BorderRadius.circular(ShadcnTheme.radiusMd),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
// 고정 헤더
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
color: ShadcnTheme.muted.withValues(alpha: 0.3),
|
||||
border: Border(bottom: BorderSide(color: Colors.black)),
|
||||
),
|
||||
child: Row(children: _buildHeaderCells()),
|
||||
),
|
||||
// 스크롤 바디
|
||||
Expanded(
|
||||
child: users.isEmpty
|
||||
? Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.people_outlined,
|
||||
size: 64,
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'등록된 사용자가 없습니다',
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
color: ShadcnTheme.mutedForeground,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
: ListView.builder(
|
||||
itemCount: users.length,
|
||||
itemBuilder: (context, index) => _buildTableRow(users[index], index),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: ShadTable.list(
|
||||
header: const [
|
||||
ShadTableCell.header(child: Text('번호')),
|
||||
ShadTableCell.header(child: Text('이름')),
|
||||
ShadTableCell.header(child: Text('이메일')),
|
||||
ShadTableCell.header(child: Text('회사')),
|
||||
ShadTableCell.header(child: Text('권한')),
|
||||
ShadTableCell.header(child: Text('상태')),
|
||||
ShadTableCell.header(child: Text('작업')),
|
||||
],
|
||||
children: [
|
||||
for (int index = 0; index < users.length; index++)
|
||||
[
|
||||
// 번호
|
||||
ShadTableCell(child: Text(((_controller.currentPage - 1) * _controller.pageSize + index + 1).toString(), style: ShadcnTheme.bodySmall)),
|
||||
// 이름
|
||||
ShadTableCell(child: Text(users[index].name, overflow: TextOverflow.ellipsis)),
|
||||
// 이메일
|
||||
ShadTableCell(child: Text(users[index].email ?? '-', overflow: TextOverflow.ellipsis, style: ShadcnTheme.bodySmall)),
|
||||
// 회사
|
||||
ShadTableCell(child: Text(users[index].companyName ?? '-', overflow: TextOverflow.ellipsis)),
|
||||
// 권한
|
||||
ShadTableCell(child: _buildUserRoleBadge(users[index].role)),
|
||||
// 상태
|
||||
ShadTableCell(child: _buildStatusChip(users[index].isActive)),
|
||||
// 작업
|
||||
ShadTableCell(
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _navigateToEdit(users[index].id!) : null,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showStatusChangeDialog(users[index]),
|
||||
child: Icon(users[index].isActive ? Icons.person_off : Icons.person, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: users[index].id != null ? () => _showDeleteDialog(users[index].id!, users[index].name) : null,
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildHeaderCells() {
|
||||
return [
|
||||
_buildHeaderCell('번호', flex: 0, useExpanded: false, minWidth: 50),
|
||||
_buildHeaderCell('이름', flex: 2, useExpanded: true, minWidth: 80),
|
||||
_buildHeaderCell('이메일', flex: 3, useExpanded: true, minWidth: 120),
|
||||
_buildHeaderCell('회사', flex: 2, useExpanded: true, minWidth: 80),
|
||||
_buildHeaderCell('권한', flex: 0, useExpanded: false, minWidth: 80),
|
||||
_buildHeaderCell('상태', flex: 0, useExpanded: false, minWidth: 80),
|
||||
_buildHeaderCell('작업', flex: 0, useExpanded: false, minWidth: 120),
|
||||
];
|
||||
}
|
||||
|
||||
Widget _buildHeaderCell(
|
||||
String text, {
|
||||
required int flex,
|
||||
required bool useExpanded,
|
||||
required double minWidth,
|
||||
}) {
|
||||
final child = Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
text,
|
||||
style: ShadcnTheme.bodyMedium.copyWith(fontWeight: FontWeight.w500),
|
||||
),
|
||||
);
|
||||
|
||||
if (useExpanded) {
|
||||
return Expanded(flex: flex, child: child);
|
||||
} else {
|
||||
return SizedBox(width: minWidth, child: child);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildDataCell(
|
||||
Widget child, {
|
||||
required int flex,
|
||||
required bool useExpanded,
|
||||
required double minWidth,
|
||||
}) {
|
||||
final container = Container(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: child,
|
||||
);
|
||||
|
||||
if (useExpanded) {
|
||||
return Expanded(flex: flex, child: container);
|
||||
} else {
|
||||
return SizedBox(width: minWidth, child: container);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildTableRow(User user, int index) {
|
||||
final rowNumber = (_controller.currentPage - 1) * _controller.pageSize + index + 1;
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: index.isEven
|
||||
? ShadcnTheme.muted.withValues(alpha: 0.1)
|
||||
: null,
|
||||
border: const Border(
|
||||
bottom: BorderSide(color: Colors.black),
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildDataCell(
|
||||
Text(
|
||||
rowNumber.toString(),
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 50,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
user.name,
|
||||
style: ShadcnTheme.bodyMedium.copyWith(
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
flex: 2,
|
||||
useExpanded: true,
|
||||
minWidth: 80,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
user.email ?? '',
|
||||
style: ShadcnTheme.bodyMedium,
|
||||
),
|
||||
flex: 3,
|
||||
useExpanded: true,
|
||||
minWidth: 120,
|
||||
),
|
||||
_buildDataCell(
|
||||
Text(
|
||||
'-', // Company name not available in current model
|
||||
style: ShadcnTheme.bodySmall,
|
||||
),
|
||||
flex: 2,
|
||||
useExpanded: true,
|
||||
minWidth: 80,
|
||||
),
|
||||
_buildDataCell(
|
||||
_buildUserRoleBadge(user.role),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 80,
|
||||
),
|
||||
_buildDataCell(
|
||||
_buildStatusChip(user.isActive),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 80,
|
||||
),
|
||||
_buildDataCell(
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ShadButton.ghost(
|
||||
onPressed: user.id != null ? () => _navigateToEdit(user.id!) : null,
|
||||
child: const Icon(Icons.edit, size: 16),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: () => _showStatusChangeDialog(user),
|
||||
child: Icon(
|
||||
user.isActive ? Icons.person_off : Icons.person,
|
||||
size: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: ShadcnTheme.spacing1),
|
||||
ShadButton.ghost(
|
||||
onPressed: user.id != null ? () => _showDeleteDialog(user.id!, user.name) : null,
|
||||
child: const Icon(Icons.delete, size: 16),
|
||||
),
|
||||
],
|
||||
),
|
||||
flex: 0,
|
||||
useExpanded: false,
|
||||
minWidth: 120,
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// (Deprecated) 기존 커스텀 테이블 빌더 유틸들은 ShadTable 전환으로 제거되었습니다.
|
||||
|
||||
Widget _buildPagination() {
|
||||
if (_controller.totalPages <= 1) return const SizedBox();
|
||||
|
||||
@@ -524,11 +416,15 @@ class _UserListState extends State<UserList> {
|
||||
|
||||
Widget _buildStatusChip(bool isActive) {
|
||||
if (isActive) {
|
||||
return ShadBadge.secondary(
|
||||
return ShadBadge(
|
||||
backgroundColor: ShadcnTheme.equipmentIn.withValues(alpha: 0.1),
|
||||
foregroundColor: ShadcnTheme.equipmentIn,
|
||||
child: const Text('활성'),
|
||||
);
|
||||
} else {
|
||||
return ShadBadge.destructive(
|
||||
return ShadBadge(
|
||||
backgroundColor: ShadcnTheme.equipmentDisposal.withValues(alpha: 0.1),
|
||||
foregroundColor: ShadcnTheme.equipmentDisposal,
|
||||
child: const Text('비활성'),
|
||||
);
|
||||
}
|
||||
@@ -536,4 +432,3 @@ class _UserListState extends State<UserList> {
|
||||
|
||||
// StandardDataRow 임시 정의
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user