diff --git a/userfront/lib/core/services/auth_proxy_service.dart b/userfront/lib/core/services/auth_proxy_service.dart index 534813b2..57d1e723 100644 --- a/userfront/lib/core/services/auth_proxy_service.dart +++ b/userfront/lib/core/services/auth_proxy_service.dart @@ -893,7 +893,10 @@ class AuthProxyService { return false; } - static Future> checkLoginIDAvailability(String loginId, {String? companyCode}) async { + static Future> checkLoginIDAvailability( + String loginId, { + String? companyCode, + }) async { final url = Uri.parse('$_baseUrl/api/v1/auth/signup/check-login-id'); final bodyData = {'loginId': loginId}; if (companyCode != null && companyCode.isNotEmpty) { @@ -907,10 +910,16 @@ class AuthProxyService { if (response.statusCode == 200) { final data = jsonDecode(response.body); - return {'available': data['available'] ?? false, 'message': data['message']}; + return { + 'available': data['available'] ?? false, + 'message': data['message'], + }; } else { final data = jsonDecode(response.body); - return {'available': false, 'message': data['message'] ?? 'Failed to check ID'}; + return { + 'available': false, + 'message': data['message'] ?? 'Failed to check ID', + }; } } diff --git a/userfront/lib/features/auth/presentation/login_screen.dart b/userfront/lib/features/auth/presentation/login_screen.dart index 86f08faf..3d3fc2ad 100644 --- a/userfront/lib/features/auth/presentation/login_screen.dart +++ b/userfront/lib/features/auth/presentation/login_screen.dart @@ -1470,9 +1470,11 @@ class _LoginScreenState extends ConsumerState ), controller: _passwordLoginIdController, decoration: InputDecoration( - labelText: _loginIdLabel ?? tr( - 'ui.userfront.login.field.login_id', - ), + labelText: + _loginIdLabel ?? + tr( + 'ui.userfront.login.field.login_id', + ), border: const OutlineInputBorder(), prefixIcon: const Icon( Icons.person_outline, diff --git a/userfront/lib/features/auth/presentation/signup_screen.dart b/userfront/lib/features/auth/presentation/signup_screen.dart index 330a8f12..e6fffa74 100644 --- a/userfront/lib/features/auth/presentation/signup_screen.dart +++ b/userfront/lib/features/auth/presentation/signup_screen.dart @@ -1446,42 +1446,68 @@ class _SignupScreenState extends State { border: const OutlineInputBorder(), errorText: _loginIdError, suffixIcon: TextButton( - onPressed: _isLoading ? null : () async { - final loginId = _loginIdController.text.trim(); - if (loginId.isEmpty) { - setState(() => _loginIdError = 'ID를 입력해주세요.'); - return; - } - setState(() { - _isLoading = true; - _loginIdError = null; - _loginIdSuccess = null; - }); - try { - final result = await AuthProxyService.checkLoginIDAvailability(loginId, companyCode: _affiliationType == 'AFFILIATE' ? _companyCode : null); - setState(() { - if (result['available'] == true) { - _loginIdSuccess = '사용 가능한 ID입니다.'; - } else { - _loginIdError = result['message'] ?? '사용할 수 없는 ID입니다.'; - } - }); - } catch (e) { - setState(() => _loginIdError = e.toString().replaceAll('Exception: ', '')); - } finally { - if (mounted) setState(() => _isLoading = false); - } - }, + onPressed: _isLoading + ? null + : () async { + final loginId = _loginIdController.text + .trim(); + if (loginId.isEmpty) { + setState( + () => _loginIdError = 'ID를 입력해주세요.', + ); + return; + } + setState(() { + _isLoading = true; + _loginIdError = null; + _loginIdSuccess = null; + }); + try { + final result = + await AuthProxyService.checkLoginIDAvailability( + loginId, + companyCode: + _affiliationType == + 'AFFILIATE' + ? _companyCode + : null, + ); + setState(() { + if (result['available'] == true) { + _loginIdSuccess = '사용 가능한 ID입니다.'; + } else { + _loginIdError = + result['message'] ?? + '사용할 수 없는 ID입니다.'; + } + }); + } catch (e) { + setState( + () => _loginIdError = e + .toString() + .replaceAll('Exception: ', ''), + ); + } finally { + if (mounted) + setState(() => _isLoading = false); + } + }, child: const Text('중복 확인'), ), ), ), if (_loginIdSuccess != null) Padding( - padding: const EdgeInsets.only(top: 8.0, left: 12.0), + padding: const EdgeInsets.only( + top: 8.0, + left: 12.0, + ), child: Text( _loginIdSuccess!, - style: const TextStyle(color: Colors.green, fontSize: 12), + style: const TextStyle( + color: Colors.green, + fontSize: 12, + ), ), ), ],