-
Notifications
You must be signed in to change notification settings - Fork 1
[FEATURE] 팀피셜록 공유하기 모달 추가 #168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
041aad2
31f5f13
c6fe29e
774a816
76556e0
44ad21d
de41f27
8fee59b
008c5fb
5ab4600
b86e550
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||
| 'use client'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| import Script from 'next/script'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| export default function KakaoScript() { | ||||||||||||||||||||
| return ( | ||||||||||||||||||||
| <Script | ||||||||||||||||||||
| src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.2/kakao.min.js" | ||||||||||||||||||||
| integrity="sha384-TiCUE00h649CAMonG018J2ujOgDKW/kVWlChEuu4jK2vxfAAD0eZxzCKakxg55G4" | ||||||||||||||||||||
| crossOrigin="anonymous" | ||||||||||||||||||||
| strategy="lazyOnload" | ||||||||||||||||||||
| onLoad={() => { | ||||||||||||||||||||
| if (window.Kakao && !window.Kakao.isInitialized()) { | ||||||||||||||||||||
| window.Kakao.init(process.env.NEXT_PUBLIC_KAKAO_JS_KEY!); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Inspect the target file around the reported lines
FILE="src/components/common/KaKaoScript.tsx"
if [ ! -f "$FILE" ]; then
echo "MISSING_FILE:$FILE"
exit 0
fi
echo "== $FILE =="
nl -ba "$FILE" | sed -n '1,120p'Repository: TEAMFICIAL/teamficial-fe Length of output: 174 🌐 Web query:
💡 Result:
|
||||||||||||||||||||
| if (window.Kakao && !window.Kakao.isInitialized()) { | |
| window.Kakao.init(process.env.NEXT_PUBLIC_KAKAO_JS_KEY!); | |
| } | |
| onLoad={() => { | |
| const kakaoKey = process.env.NEXT_PUBLIC_KAKAO_JS_KEY; | |
| if (window.Kakao && !window.Kakao.isInitialized() && kakaoKey) { | |
| window.Kakao.init(kakaoKey); | |
| } | |
| }} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/components/common/KaKaoScript.tsx` around lines 13 - 15, The Kakao SDK
init call in KaKaoScript.tsx currently uses a non-null assertion on
process.env.NEXT_PUBLIC_KAKAO_JS_KEY and will throw if the env var is missing;
change the onLoad logic to first check that process.env.NEXT_PUBLIC_KAKAO_JS_KEY
(or a runtime variable passed into the component) is a non-empty string before
calling window.Kakao.init, skip/init only when window.Kakao exists and
!window.Kakao.isInitialized(), and optionally emit a console.warn or
processLogger message when the key is not set to make the failure visible
without breaking the app; reference window.Kakao and the init call in
KaKaoScript.tsx to locate the change.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||||||||||||
| import { BaseModalProps } from '@/constants/ModalList'; | ||||||||||||||||||
| import BaseModal from '.'; | ||||||||||||||||||
| import Image from 'next/image'; | ||||||||||||||||||
| import { useToast } from '@/contexts/ToastContext'; | ||||||||||||||||||
| import { useUserStore } from '@/store/useUserStore'; | ||||||||||||||||||
|
|
||||||||||||||||||
| const LinkShareModal = ({ isOpen, onClose }: BaseModalProps) => { | ||||||||||||||||||
| const { addToast } = useToast(); | ||||||||||||||||||
| const { userName } = useUserStore(); | ||||||||||||||||||
|
|
||||||||||||||||||
| const getShareUrl = () => { | ||||||||||||||||||
| const uuid = window.location.pathname.split('/').pop(); | ||||||||||||||||||
| return `${window.location.origin}/teampsylog/head/${uuid}`; | ||||||||||||||||||
| }; | ||||||||||||||||||
|
Comment on lines
+11
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 공유 URL 경로가 라우팅 계약과 불일치할 가능성이 큽니다. Line 13에서 수정 예시 const getShareUrl = () => {
const uuid = window.location.pathname.split('/').pop();
- return `${window.location.origin}/teampsylog/head/${uuid}`;
+ return `${window.location.origin}/teampsylog/${uuid}`;
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
|
|
||||||||||||||||||
| const handleKakaoShare = () => { | ||||||||||||||||||
| if (!window.Kakao?.isInitialized()) { | ||||||||||||||||||
| addToast({ message: '카카오톡 공유를 불러오는 중입니다. 잠시 후 다시 시도해주세요.' }); | ||||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const shareUrl = getShareUrl(); | ||||||||||||||||||
|
|
||||||||||||||||||
| window.Kakao.Share.sendDefault({ | ||||||||||||||||||
| objectType: 'feed', | ||||||||||||||||||
| content: { | ||||||||||||||||||
| title: '팀피셜 (Teamficial)', | ||||||||||||||||||
| description: `${userName}님이 협업 후기를 기다리고 있어요!`, | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 28은 수정 예시- description: `${userName}님이 협업 후기를 기다리고 있어요!`,
+ description: `${userName ?? '팀원'}님이 협업 후기를 기다리고 있어요!`,🤖 Prompt for AI Agents |
||||||||||||||||||
| imageUrl: `https://www.teamficial.com/og/Teamficial_metatag_Image.jpg`, | ||||||||||||||||||
| link: { | ||||||||||||||||||
| mobileWebUrl: shareUrl, | ||||||||||||||||||
| webUrl: shareUrl, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| buttons: [ | ||||||||||||||||||
| { | ||||||||||||||||||
| title: '팀피셜록 작성하기', | ||||||||||||||||||
| link: { | ||||||||||||||||||
| mobileWebUrl: shareUrl, | ||||||||||||||||||
| webUrl: shareUrl, | ||||||||||||||||||
| }, | ||||||||||||||||||
| }, | ||||||||||||||||||
| ], | ||||||||||||||||||
| }); | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| const handleCopyLink = async () => { | ||||||||||||||||||
| const shareUrl = getShareUrl(); | ||||||||||||||||||
| await navigator.clipboard.writeText(shareUrl); | ||||||||||||||||||
| addToast({ message: '링크가 복사되었습니다.' }); | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| return ( | ||||||||||||||||||
| <BaseModal isOpen={isOpen} onClose={onClose}> | ||||||||||||||||||
| <div className="desktop:w-115 desktop:pb-0 flex flex-col pb-2"> | ||||||||||||||||||
| <div className="border-b border-b-gray-300 pb-2"> | ||||||||||||||||||
| <p className="body-7 desktop:body-1 text-gray-800">팀피셜록 공유하기</p> | ||||||||||||||||||
| <p className="body-10 desktop:body-4 text-gray-700"> | ||||||||||||||||||
| 사람들에게 나의 소프트스킬 역량을 어필하세요 | ||||||||||||||||||
| </p> | ||||||||||||||||||
| </div> | ||||||||||||||||||
| <div className="desktop:gap-7 flex items-center justify-center gap-5 pt-4"> | ||||||||||||||||||
| <button | ||||||||||||||||||
| onClick={handleKakaoShare} | ||||||||||||||||||
| className="desktop:gap-2 flex flex-col items-center gap-1" | ||||||||||||||||||
| > | ||||||||||||||||||
| <Image src="/images/share-kakao.png" width={48} height={48} alt="카카오톡 공유하기" /> | ||||||||||||||||||
| <p className="body-10 desktop:body-5 text-gray-700">카카오톡</p> | ||||||||||||||||||
| </button> | ||||||||||||||||||
| <button | ||||||||||||||||||
| onClick={handleCopyLink} | ||||||||||||||||||
| className="desktop:gap-2 flex flex-col items-center gap-1" | ||||||||||||||||||
| > | ||||||||||||||||||
| <Image src="/images/share-link.png" width={48} height={48} alt="링크 복사" /> | ||||||||||||||||||
| <p className="body-10 desktop:body-5 text-gray-700">링크복사</p> | ||||||||||||||||||
| </button> | ||||||||||||||||||
| </div> | ||||||||||||||||||
| </div> | ||||||||||||||||||
| </BaseModal> | ||||||||||||||||||
| ); | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| export default LinkShareModal; | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| declare module '*.css'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| interface Window { | ||
| Kakao: { | ||
| isInitialized: () => boolean; | ||
| init: (key: string) => void; | ||
| Share: { | ||
| sendDefault: (settings: KakaoShareSettings) => void; | ||
| }; | ||
| }; | ||
| } | ||
|
|
||
| interface KakaoShareSettings { | ||
| objectType: 'feed' | 'list' | 'location' | 'commerce' | 'text'; | ||
| content: { | ||
| title: string; | ||
| description?: string; | ||
| imageUrl?: string; | ||
| link: { | ||
| mobileWebUrl?: string; | ||
| webUrl?: string; | ||
| }; | ||
| }; | ||
| buttons?: { | ||
| title: string; | ||
| link: { | ||
| mobileWebUrl?: string; | ||
| webUrl?: string; | ||
| }; | ||
| }[]; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
클립보드 쓰기 실패 시 공유 플로우가 중단됩니다.
navigator.clipboard.writeText실패(권한/브라우저 정책) 시 예외가 전파되어openModal('linkShare')가 실행되지 않습니다.try/catch로 실패 토스트 또는 폴백 처리가 필요합니다.수정 예시
🤖 Prompt for AI Agents