// ๐Ÿ› ๏ธ ์‹œ์Šคํ…œ ๊ด€๋ฆฌ์ž ๋Œ€์‹œ๋ณด๋“œ. ์ถœ์„ DB ์ „์ฒด ์ดˆ๊ธฐํ™” ๊ธฐ๋Šฅ๋งŒ ๋‹ด๋‹นํ•œ๋‹ค. import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import '../config.dart'; import 'login_screen.dart'; // ========================================== // ๐Ÿ› ๏ธ 5. ๊ด€๋ฆฌ์ž ๋Œ€์‹œ๋ณด๋“œ (DB ์ดˆ๊ธฐํ™” ์•”ํ˜ธ ํŒŒ๋ผ๋ฏธํ„ฐ ๋ณด์ • ์™„๋ฃŒ) // ========================================== class AdminDashboard extends StatefulWidget { const AdminDashboard({super.key}); @override State createState() => _AdminDashboardState(); } class _AdminDashboardState extends State { bool _isLoading = false; Future resetDatabase() async { setState(() => _isLoading = true); // ๐Ÿ†• ๋ฐฑ์—”๋“œ ๋ณด์•ˆ ๊ทœ์น™์— ๋งž์ถ”์–ด ์ดˆ๊ธฐํ™” ํ† ํฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ํŒŒ๋ผ๋ฏธํ„ฐ(?password=...)๋ฅผ ์—ฐ๋™ ์ฃผ์†Œ์— ๋งค์นญํ–ˆ์Šต๋‹ˆ๋‹ค. final url = Uri.parse('$baseUrl/reset-db?password=adminreset2010'); try { final response = await http.get(url); if (response.statusCode == 200) { if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( const SnackBar( content: Text('๐Ÿ’ฅ DB๊ฐ€ ๊น”๋”ํ•˜๊ฒŒ ์ดˆ๊ธฐํ™”๋˜์—ˆ์Šต๋‹ˆ๋‹ค! (์ถœ์„ ๋ฒˆํ˜ธ 1๋ฒˆ๋ถ€ํ„ฐ ์‹œ์ž‘)'), ), ); } else { if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text('โŒ ์ดˆ๊ธฐํ™” ์‹คํŒจ: ์„œ๋ฒ„ ๊ถŒํ•œ ์˜ค๋ฅ˜ (${response.statusCode})'), ), ); } } catch (e) { if (!mounted) return; ScaffoldMessenger.of(context).showSnackBar( const SnackBar(content: Text('โŒ ๋„คํŠธ์›Œํฌ ์—๋Ÿฌ: ์„œ๋ฒ„์™€ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')), ); } finally { if (mounted) setState(() => _isLoading = false); } } void _showResetConfirmDialog() { showDialog( context: context, builder: (BuildContext dialogContext) { return AlertDialog( title: const Text( 'โš ๏ธ DB ์ดˆ๊ธฐํ™” ๊ฒฝ๊ณ ', style: TextStyle(color: Colors.red, fontWeight: FontWeight.bold), ), content: const Text( '๋ชจ๋“  ํ•™์ƒ์˜ ์ถœ์„ ๋ฐ ํœด๋Œ€ํฐ ์ œ์ถœ ๋ฐ์ดํ„ฐ๊ฐ€ ์˜๊ตฌ์ ์œผ๋กœ ์‚ญ์ œ๋ฉ๋‹ˆ๋‹ค.\n\n์ •๋ง ์ดˆ๊ธฐํ™”ํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?', ), actions: [ TextButton( onPressed: () => Navigator.pop(dialogContext), child: const Text('์ทจ์†Œ', style: TextStyle(color: Colors.grey)), ), ElevatedButton( style: ElevatedButton.styleFrom(backgroundColor: Colors.red), onPressed: () { Navigator.pop(dialogContext); resetDatabase(); }, child: const Text( '์ดˆ๊ธฐํ™” ์‹คํ–‰', style: TextStyle(color: Colors.white), ), ), ], ); }, ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('๐Ÿ› ๏ธ ๊ด€๋ฆฌ์ž ์‹œ์Šคํ…œ'), backgroundColor: Colors.orange, foregroundColor: Colors.white, actions: [ IconButton( icon: const Icon(Icons.logout), onPressed: () => Navigator.pushReplacement( context, MaterialPageRoute(builder: (context) => const LoginScreen()), ), ), ], ), body: Center( child: Padding( padding: const EdgeInsets.all(24.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ const Icon( Icons.admin_panel_settings, size: 100, color: Colors.orange, ), const SizedBox(height: 20), const Text( '๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ฆฌ', style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold), ), const SizedBox(height: 40), _isLoading ? const CircularProgressIndicator(color: Colors.red) : SizedBox( width: double.infinity, height: 60, child: ElevatedButton.icon( style: ElevatedButton.styleFrom( backgroundColor: Colors.red[50], foregroundColor: Colors.red, side: const BorderSide(color: Colors.red, width: 2), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(12), ), ), icon: const Icon(Icons.delete_forever, size: 28), label: const Text( '๋ชจ๋“  ์ถœ์„ ๋ฐ์ดํ„ฐ ์ดˆ๊ธฐํ™”', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), onPressed: _showResetConfirmDialog, ), ), ], ), ), ), ); } }