Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"remove": "serverless remove"
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.5",
"@reduxjs/toolkit": "^2.11.2",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
"file-saver": "^2.0.5",
"lucide-react": "^0.562.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.7",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-redux": "^9.2.0",
"react-router-dom": "^6.15.0",
"recharts": "^2.5.0",
"xlsx": "^0.18.5"
Expand All @@ -31,8 +31,8 @@
"@my-commit/eslint-config": "workspace:*",
"@types/file-saver": "^2.0.7",
"@types/node": "^20.1.1",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^4.0.0",
"autoprefixer": "^10.4.15",
"daisyui": "^3.5.1",
Expand Down
17 changes: 12 additions & 5 deletions apps/web/src/Routes.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';

import { DailySummaryPage } from './pages/DailySummaryPage';
import { LogWriterPage } from './pages/LogWriterPage';

const router = createBrowserRouter([
{
path: '/',
element: <LogWriterPage />,
lazy: async () => {
const module = await import('./pages/LogWriterPage');
return {
Component: module.LogWriterPage,
};
Comment on lines +6 to +10

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add visible loading UI for lazy route resolution

Switching routes to lazy makes page components load asynchronously, but this file does not introduce any RouterProvider fallbackElement; React Router renders null while a lazy route module is resolving. On first load (for /) or slow-network navigation, users will see a blank page with no feedback, which looks like a hang. Add a fallback element (or equivalent route-level fallback) so lazy route transitions remain observable.

Useful? React with 👍 / 👎.

},
},
{
path: '/summary',
element: <DailySummaryPage />,
lazy: async () => {
const module = await import('./pages/DailySummaryPage');
return {
Component: module.DailySummaryPage,
};
},
},
]);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ReactElement } from 'react';
import { Label, ReferenceDot } from 'recharts';

import { minutesToTimeString } from '../../../utils/DateUtil';
Expand All @@ -7,7 +8,7 @@ export const getPoints = (data: ChartDataPoint[]) => {
const { highPoint, lowPoint } = findHighLowPoints(data);
const currentPointConfig = getCurrentPointConfig(data, highPoint, lowPoint);

const points: JSX.Element[] = [];
const points: ReactElement[] = [];

if (highPoint) {
const color = highPoint.need >= 0 ? 'red' : 'green';
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/components/dialogs/RestTimeInputDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ interface RestTimeInputDialogProps {
isOpen: boolean;
onClose: () => void;
onSubmit: (minutes: number) => void;
onSkip: () => void;
}

export const RestTimeInputDialog: React.FC<RestTimeInputDialogProps> = ({
isOpen,
onClose,
onSubmit,
onSkip,
}) => {
const [minutesInput, setMinutesInput] = useState('');
const [error, setError] = useState('');
Expand Down Expand Up @@ -75,6 +77,11 @@ export const RestTimeInputDialog: React.FC<RestTimeInputDialogProps> = ({
}
};

const handleSkip = () => {
onSkip();
onClose();
};

if (!isOpen) return null;

return (
Expand All @@ -85,6 +92,8 @@ export const RestTimeInputDialog: React.FC<RestTimeInputDialogProps> = ({
원하는 휴식 시간을 분 단위로 입력하세요.
<br />
종료 1분 전과 종료 시각에 알림을 받을 수 있습니다.
<br />
알림이 필요 없다면 바로 소비 기록만 등록할 수 있습니다.
</p>

<div className="form-control">
Expand Down Expand Up @@ -116,6 +125,13 @@ export const RestTimeInputDialog: React.FC<RestTimeInputDialogProps> = ({
<button type="button" className="btn btn-ghost" onClick={onClose}>
취소 (ESC)
</button>
<button
type="button"
className="btn btn-outline"
onClick={handleSkip}
>
알람 없이 등록
</button>
<button
type="button"
className="btn btn-primary"
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/components/texts/ProductiveToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface ProductiveToggleProps {
isProductive: boolean;
setIsProductive: (value: boolean) => void;
onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
checkboxRef: React.RefObject<HTMLInputElement>;
checkboxRef: React.RefObject<HTMLInputElement | null>;
}

export const ProductiveToggle = ({
Expand Down
59 changes: 37 additions & 22 deletions apps/web/src/components/texts/TextLogContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,33 +149,47 @@ export const TextLogContainer = () => {
setIsProductive(true);
}, []);

const handleRestTimeSubmit = (minutes: number) => {
if (!pendingRestLog) return;
const appendPendingConsumptionLog = useCallback(
(minutes: number | null) => {
if (!pendingRestLog) return;

const { timeStr, content } = pendingRestLog;
const { timeStr, content } = pendingRestLog;

// 휴식 로그 추가
const newLogItem = createLogItem(timeStr, false, content);
const updatedRawLog = addLogEntry(
rawLogs,
newLogItem,
timeInput.trim() !== '',
);
// 소비 로그 추가
const newLogItem = createLogItem(timeStr, false, content);
const updatedRawLog = addLogEntry(
rawLogsRef.current,
newLogItem,
timeInput.trim() !== '',
);

setRawLogs(updatedRawLog);
setRawLogs(updatedRawLog);

// 알림 설정
dispatch(
setRestNotification({
targetTime: timeStr,
durationMinutes: minutes,
}),
);
if (minutes && minutes > 0) {
dispatch(
setRestNotification({
targetTime: timeStr,
durationMinutes: minutes,
}),
);
} else {
dispatch(clearRestNotification());
}

// 상태 초기화
resetInputs();
setPendingRestLog(null);
textareaRef.current?.focus();
// 상태 초기화
resetInputs();
setPendingRestLog(null);
textareaRef.current?.focus();
},
[dispatch, pendingRestLog, resetInputs, setRawLogs, timeInput],
);

const handleRestTimeSubmit = (minutes: number) => {
appendPendingConsumptionLog(minutes);
};

const handleRestTimeSkip = () => {
appendPendingConsumptionLog(null);
};

const handleRestDialogClose = () => {
Expand Down Expand Up @@ -334,6 +348,7 @@ export const TextLogContainer = () => {
isOpen={isRestDialogOpen}
onClose={handleRestDialogClose}
onSubmit={handleRestTimeSubmit}
onSkip={handleRestTimeSkip}
/>
</div>
);
Expand Down
29 changes: 23 additions & 6 deletions apps/web/src/pages/LogWriterPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Bell, Timer } from 'lucide-react';
import { useEffect, useState } from 'react';
import { lazy, Suspense, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';

import { AuthHeader } from '../components/auth/AuthHeader';
Expand All @@ -8,7 +8,6 @@ import { DataManagementButton } from '../components/dataManagement/DataManagemen
import { DayNavigator } from '../components/days/DayNavigator';
import { TextLogContainer } from '../components/texts/TextLogContainer';
import { Area_AvailableRestTimeChart } from '../features/AvailableRestTimeChartArea';
import { DataManagementDialog } from '../features/dataManagement/DataManagementDialog';
import { Area_ProductivePaceChart } from '../features/ProductivePaceChartArea';
import {
useRemainingTime,
Expand All @@ -19,6 +18,12 @@ import { ThemeSelector } from '../features/theme/ThemeSelector';
import { RootState } from '../store';
import { triggerCurrentDateFetch } from '../store/logs';

const DataManagementDialog = lazy(() =>
import('../features/dataManagement/DataManagementDialog').then((module) => ({
default: module.DataManagementDialog,
})),
);

export const LogWriterPage = () => {
// 휴식 알림 시스템 활성화
useRestNotification();
Expand Down Expand Up @@ -93,10 +98,22 @@ export const LogWriterPage = () => {
isOpen={isSoundSettingsOpen}
onClose={() => setIsSoundSettingsOpen(false)}
/>
<DataManagementDialog
isOpen={isDataManagementOpen}
onClose={() => setIsDataManagementOpen(false)}
/>
{isDataManagementOpen && (
<Suspense
fallback={
<div className="modal modal-open modal-bottom sm:modal-middle">
<div className="modal-box flex h-40 w-full max-w-2xl items-center justify-center">
<span className="loading loading-spinner loading-md" />
</div>
</div>
}
>
<DataManagementDialog
isOpen={isDataManagementOpen}
onClose={() => setIsDataManagementOpen(false)}
/>
</Suspense>
)}
<ConflictDialog />
</div>
);
Expand Down
Loading