'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { ROOM_THEMES } from '@/entities/room'; import { GOAL_CHIPS, SOUND_PRESETS, TIMER_PRESETS, TODAY_ONE_LINER, useThoughtInbox, type GoalChip, } from '@/entities/session'; import { MOCK_VIEWER } from '@/entities/user'; import { type CustomEntrySelection } from '@/features/custom-entry-modal'; import { useRoomSelection } from '@/features/room-select'; import { DEFAULT_APP_HUB_VISUAL_MODE, type AppHubVisualMode, } from '@/shared/config/appHubVisualMode'; import { cn } from '@/shared/lib/cn'; import { useToast } from '@/shared/ui'; import { AppUtilityRailWidget, type AppUtilityPanelId, } from '@/widgets/app-utility-rail'; import { AppTopBar } from '@/widgets/app-top-bar/ui/AppTopBar'; import { CustomEntryWidget } from '@/widgets/custom-entry-widget/ui/CustomEntryWidget'; import { RoomsGalleryWidget } from '@/widgets/rooms-gallery-widget/ui/RoomsGalleryWidget'; import { StartRitualWidget } from '@/widgets/start-ritual-widget/ui/StartRitualWidget'; const buildSpaceQuery = ( roomId: string, goalInput: string, soundPresetId: string, timerLabel: string, ) => { const params = new URLSearchParams({ room: roomId, sound: soundPresetId, timer: timerLabel, }); const normalizedGoal = goalInput.trim(); if (normalizedGoal) { params.set('goal', normalizedGoal); } return params.toString(); }; export const AppHubWidget = () => { const router = useRouter(); const { pushToast } = useToast(); const { thoughts, thoughtCount, clearThoughts } = useThoughtInbox(); const { selectedRoomId, selectRoom } = useRoomSelection( ROOM_THEMES[0].id, ); const [goalInput, setGoalInput] = useState(''); const [selectedGoalId, setSelectedGoalId] = useState(null); const [isCustomEntryOpen, setCustomEntryOpen] = useState(false); const [activeUtilityPanel, setActiveUtilityPanel] = useState( null, ); const visualMode: AppHubVisualMode = DEFAULT_APP_HUB_VISUAL_MODE; const cinematic = visualMode === 'cinematic'; const enterSpace = (soundPresetId: string, timerLabel: string) => { const query = buildSpaceQuery( selectedRoomId, goalInput, soundPresetId, timerLabel, ); router.push(`/space?${query}`); }; const handleGoalChipSelect = (chip: GoalChip) => { setSelectedGoalId(chip.id); setGoalInput(chip.label); }; const handleGoalInputChange = (value: string) => { setGoalInput(value); if (selectedGoalId && value.trim() === '') { setSelectedGoalId(null); } }; const handleQuickEnter = () => { enterSpace(SOUND_PRESETS[0].id, TIMER_PRESETS[0].label); }; const handleCustomEnter = (selection: CustomEntrySelection) => { setCustomEntryOpen(false); enterSpace(selection.soundId, selection.timerLabel); }; const handleLogout = () => { pushToast({ title: '로그아웃은 목업에서만 동작해요', description: '실제 인증 로직은 연결하지 않았습니다.', }); }; return (
router.push('/settings')} />
setCustomEntryOpen(true)} inStage /> )} />
setCustomEntryOpen(false)} onEnter={handleCustomEnter} /> setActiveUtilityPanel(null)} onClearInbox={() => { clearThoughts(); pushToast({ title: '메모 인박스를 비웠어요' }); }} />
); };