Skip to content

Commit

Permalink
hotfix: 일부 오류 수정 (#12)
Browse files Browse the repository at this point in the history
username 관련 오류 및 SSR 렌더린 관련 오류로 추정되는 오류 수정
  • Loading branch information
six-standard authored Feb 9, 2025
1 parent 6fc9c58 commit 975655e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/app/(with-tracker)/(auth-required)/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
import { cookies } from 'next/headers';
import { Header } from '@/components';
import { PATHS } from '@/constants';
import { getCookieForAuth } from '@/utils/cookieUtil';
import { me } from '@/apis';
import { getQueryClient } from '@/utils/queryUtil';

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

return (
Expand Down
7 changes: 2 additions & 5 deletions src/app/(with-tracker)/(auth-required)/main/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Metadata } from 'next';
import { cookies } from 'next/headers';
import { PATHS } from '@/constants';
import { postList, postSummary } from '@/apis';
import { getCookieForAuth } from '@/utils/cookieUtil';
import { getQueryClient } from '@/utils/queryUtil';
import { Content } from './Content';

Expand All @@ -26,7 +25,7 @@ export default async function Page({ searchParams }: IProp) {
queryKey: [PATHS.POSTS, [searchParams.asc, searchParams.sort]],
queryFn: async () =>
await postList(
getCookieForAuth(cookies, ['access_token', 'refresh_token']),
{ headers: { Cookie: cookies().toString() } },
{
asc: searchParams.asc === 'true',
sort: searchParams.sort || '',
Expand All @@ -38,9 +37,7 @@ export default async function Page({ searchParams }: IProp) {
await client.prefetchQuery({
queryKey: [PATHS.SUMMARY],
queryFn: async () =>
await postSummary(
getCookieForAuth(cookies, ['access_token', 'refresh_token']),
),
await postSummary({ headers: { Cookie: cookies().toString() } }),
});

return (
Expand Down
16 changes: 3 additions & 13 deletions src/components/auth-required/main/Section/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import {
Tooltip,
Legend,
} from 'chart.js';
import { useQuery, useQueryClient } from '@tanstack/react-query';
import { useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useState } from 'react';
import { COLORS, PATHS, SCREENS } from '@/constants';
import { Dropdown, Input } from '@/components';
import { useResponsive } from '@/hooks';
import { postDetail } from '@/apis';
import { PostDetailValue, PostSummaryDto } from '@/types';
import { PostDetailValue } from '@/types';

ChartJS.register(
CategoryScale,
Expand Down Expand Up @@ -47,14 +47,6 @@ interface IProp {

export const Graph = ({ id, releasedAt }: IProp) => {
const width = useResponsive();
const client = useQueryClient();
const maxDate = useMemo(
() =>
(
client.getQueryData([PATHS.SUMMARY]) as PostSummaryDto
)?.stats.lastUpdatedDate.split('T')[0],
[],
);

const isMBI = width < SCREENS.MBI;

Expand Down Expand Up @@ -90,7 +82,6 @@ export const Graph = ({ id, releasedAt }: IProp) => {
form="SMALL"
value={type.start}
min={releasedAt.split('T')[0]}
max={maxDate}
onChange={(e) => setType({ ...type, start: e.target.value })}
placeholder="시작 날짜"
type="date"
Expand All @@ -101,7 +92,6 @@ export const Graph = ({ id, releasedAt }: IProp) => {
form="SMALL"
value={type.end}
min={type.start ? type.start : releasedAt.split('T')[0]}
max={maxDate}
onChange={(e) => setType({ ...type, end: e.target.value })}
placeholder="종료 날짜"
type="date"
Expand Down
8 changes: 3 additions & 5 deletions src/components/auth-required/main/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import { Graph } from './Graph';

export const Section = (p: PostType) => {
const [open, setOpen] = useState(false);

const client = useQueryClient();

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

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

0 comments on commit 975655e

Please sign in to comment.