|
| 1 | +"use client" |
| 2 | + |
| 3 | +import { Card } from "@/components/ui/card" |
| 4 | +import { Button } from "@/components/ui/Button" |
| 5 | +import { Switch } from "@/components/ui/switch" |
| 6 | +import { ShareButton } from "@/components/analysis/ShareButton" |
| 7 | +import { Globe, Lock, MessageSquare, Share2, ThumbsUp } from "lucide-react" |
| 8 | +import { useRepositoryPublic } from "@/hooks/analysis/useRepositoryPublic" |
| 9 | +import { useState } from "react" |
| 10 | + |
| 11 | +interface Props { |
| 12 | + userId: number |
| 13 | + repoId: number |
| 14 | + initialPublic: boolean |
| 15 | +} |
| 16 | + |
| 17 | +export function RepositoryPublicSection({ userId, repoId, initialPublic }: Props) { |
| 18 | + const { isPublic, togglePublic } = useRepositoryPublic(initialPublic, userId, repoId) |
| 19 | + const [liked, setLiked] = useState(false) |
| 20 | + const [likeCount, setLikeCount] = useState(42) |
| 21 | + |
| 22 | + const handleLike = () => { |
| 23 | + setLiked((prev) => !prev) |
| 24 | + setLikeCount((prev) => (liked ? prev - 1 : prev + 1)) |
| 25 | + } |
| 26 | + |
| 27 | + return ( |
| 28 | + <> |
| 29 | + {/* 🌐 공개 설정 */} |
| 30 | + <Card className="mb-8 p-6"> |
| 31 | + <div className="flex items-center justify-between"> |
| 32 | + <div className="flex items-center gap-3"> |
| 33 | + {isPublic ? ( |
| 34 | + <Globe className="h-5 w-5 text-green-500" /> |
| 35 | + ) : ( |
| 36 | + <Lock className="h-5 w-5 text-muted-foreground" /> |
| 37 | + )} |
| 38 | + <div> |
| 39 | + <h3 className="font-semibold">리포지토리 공개 설정</h3> |
| 40 | + <p className="text-sm text-muted-foreground"> |
| 41 | + {isPublic |
| 42 | + ? "이 리포지토리의 분석 결과가 커뮤니티에 공개됩니다." |
| 43 | + : "이 리포지토리의 분석 결과는 비공개 상태입니다."} |
| 44 | + </p> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | + |
| 48 | + <div className="flex items-center gap-2"> |
| 49 | + <span className="text-sm text-muted-foreground">{isPublic ? "공개" : "비공개"}</span> |
| 50 | + <Switch checked={isPublic} onCheckedChange={togglePublic} /> |
| 51 | + </div> |
| 52 | + </div> |
| 53 | + </Card> |
| 54 | + |
| 55 | + {/* 💬 커뮤니티 섹션 */} |
| 56 | + {isPublic ? ( |
| 57 | + <> |
| 58 | + <Card className="p-6 mb-8"> |
| 59 | + <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between"> |
| 60 | + <div> |
| 61 | + <h3 className="mb-1 font-semibold">커뮤니티 반응</h3> |
| 62 | + <p className="text-sm text-muted-foreground">다른 개발자들과 소통하세요.</p> |
| 63 | + </div> |
| 64 | + <div className="flex gap-2"> |
| 65 | + <Button variant="outline" size="sm" className="gap-2 bg-transparent"> |
| 66 | + <MessageSquare className="h-4 w-4" /> |
| 67 | + 댓글 (n) |
| 68 | + </Button> |
| 69 | + <ShareButton /> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | + </Card> |
| 73 | + |
| 74 | + {/* ⚠️ TODO: 댓글 컴포넌트 연결 위치 */} |
| 75 | + {/* |
| 76 | + <CommentSection |
| 77 | + repoId={repoId} |
| 78 | + userId={userId} |
| 79 | + /> |
| 80 | + */} |
| 81 | + </> |
| 82 | + ) : ( |
| 83 | + <Card className="p-6 text-center text-muted-foreground"> |
| 84 | + 🔒 이 리포지토리는 현재 비공개 상태입니다. |
| 85 | + </Card> |
| 86 | + )} |
| 87 | + </> |
| 88 | + ) |
| 89 | +} |
0 commit comments