Skip to content

Commit 71c0edb

Browse files
committed
fix: post -> til 단어 변경
1 parent 7af773d commit 71c0edb

4 files changed

Lines changed: 25 additions & 25 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import PostDetail from '@/components/write/PostDetail';
22

33
type Props = {
4-
params: Promise<{ postId: string }>;
4+
params: Promise<{ tilId: string }>;
55
};
66

77
const Page = async ({ params }: Props) => {
8-
const { postId } = await params;
9-
return <PostDetail postId={postId} />;
8+
const { tilId } = await params;
9+
return <PostDetail tilId={tilId} />;
1010
};
1111

1212
export default Page;

components/write/Editor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import dynamic from 'next/dynamic';
44
import { useState } from 'react';
55
import type { MDEditorProps } from '@uiw/react-md-editor';
66
import SaveButton from '@/components/write/SaveButton';
7-
import { createPost } from '@/services/write/post.service';
7+
import { createTil } from '@/services/write/til.service';
88
import { auth } from '@/lib/firebase';
99
import { useRouter } from 'next/navigation';
1010

@@ -37,7 +37,7 @@ const Editor = () => {
3737
}
3838

3939
try {
40-
const id = await createPost(user.uid, value, title);
40+
const id = await createTil(user.uid, value, title);
4141
alert('저장 완료!');
4242
console.log('postId:', id);
4343

components/write/PostDetail.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import dynamic from 'next/dynamic';
44
import { useEffect, useState } from 'react';
55
import { useRouter } from 'next/navigation';
66
import { auth } from '@/lib/firebase';
7-
import { fetchMyPost } from '@/services/write/post.service';
8-
import type { Post } from '@/services/write/post.service'; // 같은 파일에 타입 넣었다면 거기서 export한 Post 쓰세요
7+
import { fetchMyTil } from '@/services/write/til.service';
8+
import type { Til } from '@/services/write/til.service'; // 같은 파일에 타입 넣었다면 거기서 export한 Post 쓰세요
99

1010
const Markdown = dynamic(
1111
() => import('@uiw/react-md-editor').then((mod) => mod.default.Markdown),
1212
{ ssr: false }
1313
);
1414

15-
const PostDetail = ({ postId }: { postId: string }) => {
15+
const PostDetail = ({ tilId }: { tilId: string }) => {
1616
const router = useRouter();
17-
const [data, setData] = useState<Post | null>(null);
17+
const [data, setData] = useState<Til | null>(null);
1818
const [loading, setLoading] = useState(true);
1919

2020
useEffect(() => {
@@ -24,13 +24,13 @@ const PostDetail = ({ postId }: { postId: string }) => {
2424
return;
2525
}
2626

27-
const post = await fetchMyPost(user.uid, postId);
27+
const post = await fetchMyTil(user.uid, tilId);
2828
setData(post);
2929
setLoading(false);
3030
});
3131

3232
return () => unsub();
33-
}, [postId, router]);
33+
}, [tilId, router]);
3434

3535
if (loading) return <div className="min-h-screen p-6">로딩중...</div>;
3636
if (!data) return <div className="min-h-screen p-6">글이 없습니다.</div>;
Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import {
88
} from 'firebase/firestore';
99
import { db } from '@/lib/firebase';
1010

11-
export type PostData = {
11+
export type TilData = {
1212
title: string;
1313
content: string;
1414
createdAt: Timestamp | null;
1515
updatedAt: Timestamp | null;
1616
};
1717

18-
export type Post = PostData & { id: string };
18+
export type Til = TilData & { id: string };
1919

20-
export async function createPost(uid: string, content: string, title: string) {
21-
const postsCol = collection(db, 'users', uid, 'posts');
22-
const docRef = await addDoc(postsCol, {
20+
export async function createTil(uid: string, content: string, title: string) {
21+
const tilsCol = collection(db, 'users', uid, 'tils');
22+
const docRef = await addDoc(tilsCol, {
2323
title: title,
2424
content,
2525
createdAt: serverTimestamp(),
@@ -33,7 +33,7 @@ function isRecord(v: unknown): v is Record<string, unknown> {
3333
return typeof v === 'object' && v !== null;
3434
}
3535

36-
function parsePostData(raw: unknown): PostData | null {
36+
function parseTilData(raw: unknown): TilData | null {
3737
if (!isRecord(raw)) return null;
3838

3939
const content = raw.content;
@@ -49,20 +49,20 @@ function parsePostData(raw: unknown): PostData | null {
4949
return { title, content, createdAt, updatedAt };
5050
}
5151

52-
export async function fetchMyPost(
52+
export async function fetchMyTil(
5353
uid: string | null | undefined,
54-
postId: string | null | undefined
55-
): Promise<Post | null> {
56-
// 여기서 uid/postId 실물 확인
57-
console.log('[fetchMyPost] path =', { uid, postId });
54+
tilId: string | null | undefined
55+
): Promise<Til | null> {
56+
// 여기서 uid/tilId 실물 확인
57+
console.log('[fetchMyPost] path =', { uid, tilId });
5858

59-
if (!uid || !postId) return null;
59+
if (!uid || !tilId) return null;
6060

61-
const ref = doc(db, 'users', uid, 'posts', postId);
61+
const ref = doc(db, 'users', uid, 'tils', tilId);
6262
const snap = await getDoc(ref);
6363
if (!snap.exists()) return null;
6464

65-
const parsed = parsePostData(snap.data());
65+
const parsed = parseTilData(snap.data());
6666
if (!parsed) return null;
6767

6868
return { id: snap.id, ...parsed };

0 commit comments

Comments
 (0)