diff --git a/app/Http/Controllers/Juil/PlanningController.php b/app/Http/Controllers/Juil/PlanningController.php index 153dbec1..cba356ba 100644 --- a/app/Http/Controllers/Juil/PlanningController.php +++ b/app/Http/Controllers/Juil/PlanningController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers\Juil; use App\Http\Controllers\Controller; +use App\Services\WeatherService; +use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\View\View; @@ -44,4 +46,11 @@ public function constructionPmis(Request $request): View|Response return view('juil.construction-pmis'); } + + public function pmisWeather(WeatherService $weatherService): JsonResponse + { + $forecasts = $weatherService->getWeeklyForecast(); + + return response()->json(['forecasts' => array_slice($forecasts, 0, 2)]); + } } diff --git a/resources/views/juil/construction-pmis.blade.php b/resources/views/juil/construction-pmis.blade.php index fe99b7de..ae3d5057 100644 --- a/resources/views/juil/construction-pmis.blade.php +++ b/resources/views/juil/construction-pmis.blade.php @@ -407,59 +407,126 @@ function FlowSafety() { 대시보드 위젯 ════════════════════════════════════════════════ */ -/* ─── 날씨 위젯 ─── */ +/* ─── 날씨 아이콘 (WeatherService 아이콘명 매핑) ─── */ +function WeatherIcon({ icon, size = 40 }) { + const s = size; + if (icon === 'sun') return ( + + ); + if (icon === 'cloud-sun') return ( + + ); + if (icon === 'rain') return ( + + ); + if (icon === 'snow') return ( + + ); + if (icon === 'sleet') return ( + + ); + // cloud (default) + return ( + + ); +} + +/* ─── 날씨 위젯 (WeatherService API 연동) ─── */ function WeatherWidget() { + const [forecasts, setForecasts] = useState(null); + const [loading, setLoading] = useState(true); + const today = new Date(); const dateStr = `${today.getFullYear()}.${String(today.getMonth()+1).padStart(2,'0')}.${String(today.getDate()).padStart(2,'0')}`; const dayNames = ['일','월','화','수','목','금','토']; const dayStr = dayNames[today.getDay()]; + React.useEffect(() => { + fetch('/juil/construction-pmis/weather', { headers: { 'Accept': 'application/json' } }) + .then(r => r.json()) + .then(data => { setForecasts(data.forecasts || []); setLoading(false); }) + .catch(() => setLoading(false)); + }, []); + + const labels = ['오늘', '내일']; + return (