Skip to content

Commit 975655e

Browse files
authored
hotfix: 일부 오류 수정 (#12)
username 관련 오류 및 SSR 렌더린 관련 오류로 추정되는 오류 수정
1 parent 6fc9c58 commit 975655e

File tree

4 files changed

+9
-25
lines changed

4 files changed

+9
-25
lines changed

src/app/(with-tracker)/(auth-required)/layout.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
33
import { cookies } from 'next/headers';
44
import { Header } from '@/components';
55
import { PATHS } from '@/constants';
6-
import { getCookieForAuth } from '@/utils/cookieUtil';
76
import { me } from '@/apis';
87
import { getQueryClient } from '@/utils/queryUtil';
98

@@ -17,7 +16,7 @@ export default async function Layout({ children }: IProp) {
1716
await client.prefetchQuery({
1817
queryKey: [PATHS.ME],
1918
queryFn: async () =>
20-
await me(getCookieForAuth(cookies, ['access_token', 'refresh_token'])),
19+
await me({ headers: { Cookie: cookies().toString() } }),
2120
});
2221

2322
return (

src/app/(with-tracker)/(auth-required)/main/page.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Metadata } from 'next';
33
import { cookies } from 'next/headers';
44
import { PATHS } from '@/constants';
55
import { postList, postSummary } from '@/apis';
6-
import { getCookieForAuth } from '@/utils/cookieUtil';
76
import { getQueryClient } from '@/utils/queryUtil';
87
import { Content } from './Content';
98

@@ -26,7 +25,7 @@ export default async function Page({ searchParams }: IProp) {
2625
queryKey: [PATHS.POSTS, [searchParams.asc, searchParams.sort]],
2726
queryFn: async () =>
2827
await postList(
29-
getCookieForAuth(cookies, ['access_token', 'refresh_token']),
28+
{ headers: { Cookie: cookies().toString() } },
3029
{
3130
asc: searchParams.asc === 'true',
3231
sort: searchParams.sort || '',
@@ -38,9 +37,7 @@ export default async function Page({ searchParams }: IProp) {
3837
await client.prefetchQuery({
3938
queryKey: [PATHS.SUMMARY],
4039
queryFn: async () =>
41-
await postSummary(
42-
getCookieForAuth(cookies, ['access_token', 'refresh_token']),
43-
),
40+
await postSummary({ headers: { Cookie: cookies().toString() } }),
4441
});
4542

4643
return (

src/components/auth-required/main/Section/Graph.tsx

+3-13
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import {
1212
Tooltip,
1313
Legend,
1414
} from 'chart.js';
15-
import { useQuery, useQueryClient } from '@tanstack/react-query';
16-
import { useMemo, useState } from 'react';
15+
import { useQuery } from '@tanstack/react-query';
16+
import { useState } from 'react';
1717
import { COLORS, PATHS, SCREENS } from '@/constants';
1818
import { Dropdown, Input } from '@/components';
1919
import { useResponsive } from '@/hooks';
2020
import { postDetail } from '@/apis';
21-
import { PostDetailValue, PostSummaryDto } from '@/types';
21+
import { PostDetailValue } from '@/types';
2222

2323
ChartJS.register(
2424
CategoryScale,
@@ -47,14 +47,6 @@ interface IProp {
4747

4848
export const Graph = ({ id, releasedAt }: IProp) => {
4949
const width = useResponsive();
50-
const client = useQueryClient();
51-
const maxDate = useMemo(
52-
() =>
53-
(
54-
client.getQueryData([PATHS.SUMMARY]) as PostSummaryDto
55-
)?.stats.lastUpdatedDate.split('T')[0],
56-
[],
57-
);
5850

5951
const isMBI = width < SCREENS.MBI;
6052

@@ -90,7 +82,6 @@ export const Graph = ({ id, releasedAt }: IProp) => {
9082
form="SMALL"
9183
value={type.start}
9284
min={releasedAt.split('T')[0]}
93-
max={maxDate}
9485
onChange={(e) => setType({ ...type, start: e.target.value })}
9586
placeholder="시작 날짜"
9687
type="date"
@@ -101,7 +92,6 @@ export const Graph = ({ id, releasedAt }: IProp) => {
10192
form="SMALL"
10293
value={type.end}
10394
min={type.start ? type.start : releasedAt.split('T')[0]}
104-
max={maxDate}
10595
onChange={(e) => setType({ ...type, end: e.target.value })}
10696
placeholder="종료 날짜"
10797
type="date"

src/components/auth-required/main/Section/index.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import { Graph } from './Graph';
1111

1212
export const Section = (p: PostType) => {
1313
const [open, setOpen] = useState(false);
14-
1514
const client = useQueryClient();
1615

17-
const { username } = client.getQueryData([PATHS.ME]) as UserDto;
16+
const username = (client.getQueryData([PATHS.ME]) as UserDto)?.username;
17+
const url = `${process.env.NEXT_PUBLIC_VELOG_URL}/@${username || ''}/${p.slug}`;
1818

1919
return (
2020
<section className="flex flex-col w-full h-fit relative">
@@ -31,9 +31,7 @@ export const Section = (p: PostType) => {
3131
title="해당 글로 바로가기"
3232
onClick={(e) => {
3333
e.stopPropagation();
34-
window.open(
35-
`${process.env.NEXT_PUBLIC_VELOG_URL}/@${username}/${p.slug}`,
36-
);
34+
window.open(url);
3735
}}
3836
>
3937
<Icon name="Shortcut" color="#ECECEC" size={20} />

0 commit comments

Comments
 (0)