Skip to content

Commit 69a40d9

Browse files
authored
[SSD-151] 링크 공유하기 버튼 (#89)
* [SSD-151] feat: 타임페이퍼 링크 공유하기 기능 * [SSD-151] chore: 컴포넌트 추가 * [SSD-151] fix: 환경변수 복사 누락 * [SSD-151] fix: Dockerfile 환경 변수 * [SSD-151] fix: docker-compose 환경 변수 * [SSD-151] fix: timepapaerId 전달 * [SSD-151] chore: 이벤트 브랜치 제거
1 parent fcde401 commit 69a40d9

File tree

6 files changed

+74
-11
lines changed

6 files changed

+74
-11
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
- deploy
87
- deploy/*
9-
- feat/SSD-133-포스트잇-예외-처리
108

119
jobs:
1210
deploy:
@@ -49,6 +47,7 @@ jobs:
4947
echo "MAIL_PASSWORD=${{ secrets.MAIL_PASSWORD }}" >> .env
5048
echo "TIME_PAPER_URL=${{ secrets.TIME_PAPER_URL }}" >> .env
5149
echo "ORIGIN=${{ secrets.ORIGIN }}" >> .env
50+
echo "VITE_KAKAO_API_KEY=${{ secrets.VITE_KAKAO_API_KEY }}" >> .env
5251
5352
- name: Add ssh-agent
5453
uses: webfactory/[email protected]

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ services:
6363
- type=local,src=/tmp/.build-cache/client
6464
args:
6565
VITE_API_URL: ${VITE_API_URL}
66+
VITE_KAKAO_API_KEY: ${VITE_KAKAO_API_KEY}
6667
image: yejinoh58/timepaper-client-image:latest
6768
env_file:
6869
- .env

frontend/Dockerfile.local

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# 빌드 단계
22
FROM node:23-alpine AS build
33

4-
ARG VITE_API_URL
4+
ARG VITE_API_URL
5+
ARG VITE_KAKAO_API_KEY
56
ENV VITE_API_URL=$VITE_API_URL
7+
ENV VITE_KAKAO_API_KEY=$VITE_KAKAO_API_KEY
68

79
WORKDIR /app
810

frontend/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
<meta charset="UTF-8" />
55
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7-
<title>Vite + React</title>
7+
<title>Timepaper</title>
8+
<script
9+
src="https://t1.kakaocdn.net/kakao_js_sdk/2.7.4/kakao.min.js"
10+
integrity="sha384-DKYJZ8NLiK8MN4/C5P2dtSmLQ4KwPaoqAfyA/DfmEc1VDxu4yyC7wy6K1Hs90nka"
11+
crossorigin="anonymous"
12+
></script>
813
</head>
914
<body>
1015
<div id="root"></div>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import React, { useEffect } from 'react';
2+
import BottomButton from '../BottomButton/BottomButton';
3+
4+
export default function ShareLink({ timepaperId }) {
5+
const KAKAO_API_KEY = import.meta.env.VITE_KAKAO_API_KEY;
6+
const realUrl = `https://43.201.24.13.sslip.io/timepaper/${timepaperId}`;
7+
8+
useEffect(() => {
9+
if (!window.Kakao) {
10+
console.error('Kakao SDK 로드 안됨');
11+
return;
12+
}
13+
if (!window.Kakao.isInitialized()) {
14+
window.Kakao.init(KAKAO_API_KEY);
15+
console.log('Kakao 초기화:', window.Kakao.isInitialized());
16+
}
17+
}, []);
18+
19+
const shareKakao = () => {
20+
if (!window.Kakao) {
21+
console.error('Kakao SDK 로드 안됨');
22+
return;
23+
}
24+
25+
window.Kakao.Share.sendDefault({
26+
objectType: 'feed',
27+
content: {
28+
title: '친구에게서 타임페이퍼가 왔어요💕',
29+
description: '',
30+
imageUrl: `https://43.201.24.13.sslip.io/assets/timepaperLogo-0WzOUFBd.png`,
31+
link: {
32+
mobileWebUrl: realUrl,
33+
webUrl: realUrl,
34+
},
35+
},
36+
buttons: [
37+
{
38+
title: '친구가 전달한 타임페이퍼로 🚀',
39+
link: {
40+
mobileWebUrl: realUrl,
41+
webUrl: realUrl,
42+
},
43+
},
44+
],
45+
});
46+
};
47+
return (
48+
<>
49+
<BottomButton onClick={shareKakao} title={`공유하기`} isEnable={true}></BottomButton>
50+
</>
51+
);
52+
}

frontend/src/pages/time-paper-detail/TimePaperDetail.jsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import ConfirmModal from '../../components/confirmmodal/ConfirmModal';
99
import Modal from '../../components/Modal/Modal';
1010
import { finishLoading, startLoading } from '../../store/slices/loadingSlice';
1111
import Alert from '../../components/Alert/Alert';
12+
import ShareLink from '../../components/share-link/ShareLink';
1213

1314
export default function TimePaperDetail() {
1415
const { timepaperId } = useParams();
@@ -45,7 +46,7 @@ export default function TimePaperDetail() {
4546
if (timePaperResponse && timePaperResponse.data && timePaperResponse.data.data) {
4647
const timePaperData = timePaperResponse.data.data;
4748
if (timePaperData.locked) {
48-
navigate(`/timepaper/${timepaperId}/lock`, { replace: true});
49+
navigate(`/timepaper/${timepaperId}/lock`, { replace: true });
4950
return;
5051
}
5152

@@ -234,12 +235,15 @@ export default function TimePaperDetail() {
234235
)}
235236
</div>
236237
)}
237-
<BottomButton
238-
title="포스트잇 작성"
239-
onClick={handlePostItCreateClick}
240-
isEnable={true}
241-
className={styles.postitCreate}
242-
/>
238+
<div className={styles.buttonGroup}>
239+
<ShareLink timepaperId={timepaperId}></ShareLink>
240+
<BottomButton
241+
title="포스트잇 작성"
242+
onClick={handlePostItCreateClick}
243+
isEnable={true}
244+
className={styles.postitCreate}
245+
/>
246+
</div>
243247
</div>
244248
</div>
245249
</div>

0 commit comments

Comments
 (0)