Skip to content

Commit f1076c8

Browse files
committed
fix: 로그인 분기 처리 추가
- 로그인 안되어있을 경우 LoginDialog 호출
1 parent fd4c979 commit f1076c8

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

components/post/post-editor.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import PostTags from '@/components/post/post-tags';
1616
import { DialogTrigger, Dialog } from '@/components/ui/Dialog';
1717
import SavePostDialog from '@/components/post/post-save-dialog';
1818
import { useRouter } from 'next/navigation';
19+
import { useUserProfile } from '@/lib/service/user/use-user-service';
20+
import LoginDialog from '@/components/auth/login-dialog';
1921

2022
interface PostEditorProps {
2123
id: string;
@@ -29,6 +31,7 @@ const PostEditor: FunctionComponent<PostEditorProps> = ({ id, status }) => {
2931
const { mutate: updatePostMutate } = useUpdatePostMutation();
3032
const titleRef = useRef<{ getTitle: () => string }>(null);
3133
const tagListRef = useRef<{ getTagList: () => string[] }>(null);
34+
const isLogin = useUserProfile().data !== undefined;
3235

3336
const editorRef = useRef<MDXEditorMethods>(null);
3437

@@ -113,10 +116,14 @@ const PostEditor: FunctionComponent<PostEditorProps> = ({ id, status }) => {
113116
저장하기
114117
</Button>
115118
</DialogTrigger>
116-
<SavePostDialog
117-
onSubmit={updatePost}
118-
initialArchiveId={archiveId}
119-
/>
119+
{isLogin ? (
120+
<SavePostDialog
121+
onSubmit={updatePost}
122+
initialArchiveId={archiveId}
123+
/>
124+
) : (
125+
<LoginDialog />
126+
)}
120127
</Dialog>
121128
</div>
122129
</div>

components/post/url-text-field.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@ import {
2121
} from '@/constants/SummaryOptionLabels';
2222
import { useCreatePostMutation } from '@/lib/service/post/use-post-service';
2323
import { useSummaryStore } from '@/store/useSummaryStore';
24+
import LoginDialog from '@/components/auth/login-dialog';
25+
import { useUserProfile } from '@/lib/service/user/use-user-service';
2426

2527
const URLTextField = () => {
2628
const { url, setUrl, options, setOptions } = useSummaryStore();
2729
const [dialogMessage, setDialogMessage] = useState<string | null>(null);
30+
const isLogin = useUserProfile().data !== undefined;
2831

2932
const handleConfirm = (options: SummaryOptions) => {
3033
setOptions(options);
@@ -94,7 +97,7 @@ const URLTextField = () => {
9497
설정
9598
</button>
9699
</DialogTrigger>
97-
<OptionDialog onConfirm={handleConfirm} />
100+
{isLogin ? <OptionDialog onConfirm={handleConfirm} /> : <LoginDialog />}
98101
</Dialog>
99102
<TextField
100103
placeholder="URL을 입력해주세요."

components/summary/feadback-box.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
'use client';
22

3+
import LoginDialog from '@/components/auth/login-dialog';
34
import OptionDialog from '@/components/summary/option-dialog';
45
import Button from '@/components/ui/Button';
56
import { DialogTrigger } from '@/components/ui/Dialog';
67
import { useCreatePostMutation } from '@/lib/service/post/use-post-service';
8+
import { useUserProfile } from '@/lib/service/user/use-user-service';
79
import { cn } from '@/lib/utils';
810
import { useSummaryStore } from '@/store/useSummaryStore';
911
import { typography } from '@/styles/typography';
@@ -14,13 +16,16 @@ import { FunctionComponent } from 'react';
1416
const FeedbackBox: FunctionComponent = () => {
1517
const { url, options, setOptions } = useSummaryStore();
1618
const { mutate } = useCreatePostMutation();
19+
const isLogin = useUserProfile().data !== undefined;
20+
1721
const handleConfirm = (newOptions: SummaryOptions) => {
1822
setOptions(options);
1923
mutate({
2024
url,
2125
options: newOptions,
2226
});
2327
};
28+
2429
return (
2530
<div
2631
className={cn(
@@ -35,7 +40,11 @@ const FeedbackBox: FunctionComponent = () => {
3540
재요약하기
3641
</Button>
3742
</DialogTrigger>
38-
<OptionDialog onConfirm={handleConfirm} initialOptions={options} />
43+
{isLogin ? (
44+
<OptionDialog onConfirm={handleConfirm} initialOptions={options} />
45+
) : (
46+
<LoginDialog />
47+
)}
3948
</Dialog>
4049
</div>
4150
);

0 commit comments

Comments
 (0)