Skip to content

Commit 8e1fd94

Browse files
committed
Merge remote-tracking branch 'origin/master' into fix/todo
2 parents 2b3dadb + 3bead2a commit 8e1fd94

10 files changed

Lines changed: 77 additions & 25 deletions

File tree

app/routes/mypage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ export default function MyPage() {
55
const { logout } = useLogout();
66

77
return (
8-
<div className="px-30 py-10">
9-
<h1 className="text-[32px] font-bold text-main2 mb-8">
8+
<div className="px-30 py-10 ">
9+
<h1 className="text-[32px] font-bold text-main2 mb-8 ">
1010
안녕하세요, {nickname}님!
1111
</h1>
1212
<div className="flex items-center justify-center">
13-
<div className="max-w-155 bg-white rounded-[10px] shadow-[0_2px_12px_rgba(0,0,0,0.08)] px-8 py-5 flex items-center justify-between">
13+
<div className="flex justify-between max-w-155 bg-white rounded-[10px] shadow-[0_2px_12px_rgba(0,0,0,0.08)] px-8 py-5 w-full">
1414
<div className="flex items-center gap-6">
1515
<span className="text-[20px] font-bold text-main2">{nickname}</span>
1616
<span className="text-[16px] text-sub1">{loginId}</span>

features/auth/api/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
export { REGISTER_MUTATION } from './register.mutation';
22
export { LOGIN_MUTATION } from './login.mutaiton';
3+
export { ME_QUERY } from './me.query';
4+
export type { MeQueryResult } from './me.query';

features/auth/api/me.query.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { gql } from '@apollo/client';
2+
3+
export const ME_QUERY = gql`
4+
query Me {
5+
me {
6+
id
7+
loginId
8+
nickname
9+
createdAt
10+
updatedAt
11+
}
12+
}
13+
`;
14+
15+
export interface MeQueryResult {
16+
me: {
17+
id: number;
18+
loginId: string;
19+
nickname: string;
20+
createdAt: string;
21+
updatedAt: string;
22+
};
23+
}

features/auth/model/useMe.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1+
import { useQuery } from '@apollo/client/react';
12
import { tokenStorage } from 'shared/utils';
2-
3-
interface TokenPayload {
4-
nickname: string;
5-
loginId: string;
6-
}
3+
import { ME_QUERY } from '../api/me.query';
4+
import type { MeQueryResult } from '../api/me.query';
75

86
export function useMe() {
9-
const payload = tokenStorage.parse<TokenPayload>();
7+
const isLoggedIn = !!tokenStorage.get();
8+
9+
const { data } = useQuery<MeQueryResult>(ME_QUERY, {
10+
skip: !isLoggedIn,
11+
});
12+
1013
return {
11-
nickname: payload?.nickname ?? '',
12-
loginId: payload?.loginId ?? '',
14+
nickname: data?.me.nickname ?? '',
15+
loginId: data?.me.loginId ?? '',
1316
};
1417
}

features/history/model/useMyReviews.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface MyReviewsResponse {
99
export function useMyReviews(filter: ReviewFilter) {
1010
const { data, loading, error } = useQuery<MyReviewsResponse>(
1111
MY_REVIEWS_QUERY,
12-
{ variables: { filter } }
12+
{ variables: { filter }, fetchPolicy: 'cache-and-network' }
1313
);
1414

1515
const myReviews: Review[] =

features/review/ui/GuidePanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface GuidePanelProps {
77

88
export function GuidePanel({ steps, stepIndex }: GuidePanelProps) {
99
return (
10-
<aside className="w-84.25 shrink-0 pt-4">
10+
<aside className="min-w-7.5 shrink-0 pt-4">
1111
<h2 className="text-[25px] font-semibold text-main2 mb-4">가이드라인</h2>
1212
<div className="border border-main1 rounded-[10px] bg-white p-6">
1313
{steps.map((step, i) => {

features/review/ui/ProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface ProgressBarProps {
88

99
export function ProgressBar({ steps, stepIndex }: ProgressBarProps) {
1010
return (
11-
<div className="px-54.5 pt-6 pb-2 shrink-0">
11+
<div className="px-54.5 pt-6 pb-2 shrink-0 min-w-325">
1212
<div className="flex gap-2">
1313
{steps.map((step, i) => {
1414
const { bar, label } = colorMap[step.color];

features/review/ui/WritePanel.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export function WritePanel({
3333

3434
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
3535
if (e.key !== 'Enter') return;
36+
if (e.nativeEvent.isComposing) return;
3637

3738
const textarea = textareaRef.current!;
3839
const { value, selectionStart, selectionEnd } = textarea;
@@ -59,17 +60,24 @@ export function WritePanel({
5960

6061
if (isEmptyItem) {
6162
// 빈 항목에서 Enter → 리스트 종료, 접두사 제거
62-
newValue = value.substring(0, lineStart) + value.substring(selectionStart);
63+
newValue =
64+
value.substring(0, lineStart) + value.substring(selectionStart);
6365
newCursor = lineStart;
6466
} else if (unorderedMatch) {
6567
const [, indent, bullet] = unorderedMatch;
6668
const insertion = `\n${indent}${bullet} `;
67-
newValue = value.substring(0, selectionStart) + insertion + value.substring(selectionEnd);
69+
newValue =
70+
value.substring(0, selectionStart) +
71+
insertion +
72+
value.substring(selectionEnd);
6873
newCursor = selectionStart + insertion.length;
6974
} else {
7075
const [, indent, numStr] = orderedMatch!;
7176
const insertion = `\n${indent}${parseInt(numStr) + 1}. `;
72-
newValue = value.substring(0, selectionStart) + insertion + value.substring(selectionEnd);
77+
newValue =
78+
value.substring(0, selectionStart) +
79+
insertion +
80+
value.substring(selectionEnd);
7381
newCursor = selectionStart + insertion.length;
7482
}
7583

@@ -83,7 +91,7 @@ export function WritePanel({
8391
};
8492

8593
return (
86-
<section className="flex-1 flex flex-col gap-4 pt-4 min-w-0">
94+
<section className="flex-1 flex flex-col gap-4 pt-4 min-w-[300px]">
8795
<h2 className="text-[25px] font-semibold text-main2">
8896
{currentStep.title}
8997
</h2>

features/todo/todo.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ import { ReviewStartModal } from 'features/review';
1717
export const Todo = () => {
1818
const [isModalOpen, setIsModalOpen] = useState(false);
1919
const [selectedDate, setSelectedDate] = useState<Date>(() => new Date());
20-
const dateString = selectedDate.toISOString().split('T')[0];
2120

22-
const { myReviews } = useMyReviews({ date: dateString });
21+
const { myReviews } = useMyReviews({ date: formatDateToYYYYMMDD(selectedDate) });
2322
const todayReview = myReviews[0] ?? null;
2423
const [isAddGoalOpen, setIsAddGoalOpen] = useState(false);
2524

@@ -93,6 +92,18 @@ export const Todo = () => {
9392
[goals, hiddenGoalIds]
9493
);
9594

95+
const allTasksDone = useMemo(
96+
() => todos.length > 0 && todos.every((t) => t.total > 0 && t.completed === t.total),
97+
[todos]
98+
);
99+
100+
const isPast10pmKST =
101+
new Date(
102+
new Date().toLocaleString('en-US', { timeZone: 'Asia/Seoul' })
103+
).getHours() >= 22;
104+
105+
const canStartReview = allTasksDone || isPast10pmKST;
106+
96107
const handlePrevDate = () => {
97108
setSelectedDate((prev) => {
98109
const next = new Date(prev);
@@ -371,8 +382,13 @@ export const Todo = () => {
371382
) : (
372383
<div className="flex justify-center">
373384
<button
374-
onClick={() => setIsModalOpen(true)}
375-
className="w-full max-w-215 mt-30 py-4 bg-main1 text-white rounded-[10px] text-[20px] font-medium cursor-pointer"
385+
onClick={() => canStartReview && setIsModalOpen(true)}
386+
disabled={!canStartReview}
387+
className={`w-full max-w-215 mt-30 py-4 rounded-[10px] text-[20px] font-medium transition-colors ${
388+
canStartReview
389+
? 'bg-main1 text-white cursor-pointer'
390+
: 'bg-sub3 text-sub2 cursor-not-allowed'
391+
}`}
376392
>
377393
오늘 하루 회고로 마무리하기
378394
</button>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
"codegen": "graphql-codegen --config codegen.ts"
1313
},
1414
"dependencies": {
15+
"@apollo/client": "^4.1.6",
1516
"@base-ui/react": "^1.2.0",
1617
"@fontsource-variable/geist": "^5.2.8",
17-
"class-variance-authority": "^0.7.1",
18-
"clsx": "^2.1.1",
19-
"@apollo/client": "^4.1.6",
2018
"@react-router/node": "7.12.0",
2119
"@react-router/serve": "7.12.0",
20+
"class-variance-authority": "^0.7.1",
21+
"clsx": "^2.1.1",
2222
"graphql": "^16.13.1",
2323
"isbot": "^5.1.31",
2424
"lucide-react": "^0.577.0",

0 commit comments

Comments
 (0)