Skip to content

Commit 8735bde

Browse files
authored
Merge pull request #252 from MBTips/dev
15차 배포 Test (Dev -> Main)
2 parents 9a0e230 + e31fad7 commit 8735bde

19 files changed

+576
-59
lines changed

public/icon/twitter.svg

Lines changed: 15 additions & 1 deletion
Loading

src/App.tsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
import { useEffect } from "react";
1+
import { useEffect, useState } from "react";
22
import {
33
BrowserRouter as Router,
44
Routes,
55
Route,
66
useLocation
77
} from "react-router-dom";
8+
import { initGA, trackPageView } from "@/libs/analytics";
89
import Home from "@/pages/Home";
910
import SelectInfo from "@/pages/SelectInfo";
1011
import Chat from "@/pages/Chat";
1112
import ChatRecommend from "@/pages/ChatRecommend";
1213
import ChatTips from "@/pages/ChatTips";
13-
import ChatTemporature from "@/pages/ChatTemporature";
14+
import ChatTemperature from "@/pages/ChatTemperature";
1415
import Content from "@/pages/Content";
1516
import Login from "@/pages/Login";
1617
import MyInfo from "@/pages/MyInfo";
1718
import KaKaoLogin from "@/pages/KaKaoLogin";
1819
import MbtiTestIntro from "@/pages/MbtiTestIntro";
1920
import MbtiTestQuestions from "@/pages/MbtiTestQuestions";
2021
import MbtiTestResult from "@/pages/MbtiTestResult";
21-
import CenteredLayout from "@/components/CenteredLayout";
22-
import { initGA, trackPageView } from "@/libs/analytics";
2322
import Error from "@/pages/Error";
23+
import CenteredLayout from "@/components/CenteredLayout";
24+
import ToastMessage from "@/components/ToastMessage";
25+
import useAuthStore from "@/store/useAuthStore";
2426

2527
const PageTracker = () => {
2628
const location = useLocation();
@@ -69,26 +71,46 @@ const PageTracker = () => {
6971
};
7072

7173
const App = () => {
74+
const { logout } = useAuthStore();
75+
const [toastMessage, setToastMessage] = useState("");
76+
const storageAuth = localStorage.getItem("auth-storage");
77+
const parsedAuth = storageAuth ? JSON.parse(storageAuth).state : null;
78+
79+
const checkSession = () => {
80+
const expirationTime = new Date(
81+
new Date(parsedAuth.loginTime).getTime() + 24 * 60 * 60 * 1000
82+
);
83+
const now = new Date();
84+
if (now > expirationTime) {
85+
setToastMessage("로그인 세션이 만료되었습니다.");
86+
logout();
87+
}
88+
};
89+
7290
useEffect(() => {
7391
initGA();
92+
if (parsedAuth) checkSession();
7493
}, []);
7594

7695
return (
7796
<Router>
7897
<PageTracker />
7998
<CenteredLayout>
99+
{toastMessage && (
100+
<ToastMessage
101+
message={toastMessage}
102+
onClose={() => setToastMessage("")}
103+
/>
104+
)}
80105
<Routes>
81106
<Route path="/" element={<Home />} />
82107
<Route path="/select-info" element={<SelectInfo />} />
83108
<Route path="/chat" element={<Chat />} />
109+
<Route path="/chat-recommend/:mbti" element={<ChatRecommend />} />
110+
<Route path="/chat-tips/:mbti" element={<ChatTips />} />
84111
<Route
85-
path="/chat-recommend/:virtualFriendId"
86-
element={<ChatRecommend />}
87-
/>
88-
<Route path="/chat-tips/:virtualFriendId" element={<ChatTips />} />
89-
<Route
90-
path="/chat-temporature/:conversationId"
91-
element={<ChatTemporature />}
112+
path="/chat-temperature/:conversationId"
113+
element={<ChatTemperature />}
92114
/>
93115
<Route path="/contents/:id" element={<Content />} />
94116
<Route path="/login" element={<Login />} />

src/api/axios.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import useAuthStore from "@/store/useAuthStore";
33

44
const instance = axios.create({
55
baseURL: import.meta.env.VITE_API_BASE_URL,
6-
timeout: 10000,
6+
timeout: 100000,
77
headers: {
88
"Content-Type": "application/json"
99
}
@@ -12,7 +12,7 @@ const instance = axios.create({
1212
// 인증 절차가 필요한 API는 authInstance로 HTTP요청
1313
const authInstance = axios.create({
1414
baseURL: import.meta.env.VITE_API_BASE_URL,
15-
timeout: 10000,
15+
timeout: 100000,
1616
headers: {
1717
"Content-Type": "application/json"
1818
}

src/components/button/TwitterShareButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const TwitterShareButton = ({ title }: { title: string }) => {
66
href={`https://twitter.com/intent/tweet?text=${title}&url=${currentUrl}`}
77
className="flex flex-col items-center gap-1"
88
>
9-
<img src="/icon/twitter.svg" alt="트위터 아이콘" width={76} height={76} />
10-
<p className="text-md text-gray-800">트위터</p>
9+
<img src="/icon/twitter.svg" alt="트위터 아이콘" width={72} height={72} />
1110
</a>
1211
);
1312
};
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,36 @@
1-
const UrlCopyButton = ({currentUrl} : {currentUrl : string}) => {
2-
const handleCopy = () => {
3-
navigator.clipboard
4-
.writeText(currentUrl)
5-
.then(() => {
6-
alert("URL이 복사되었습니다!"); // toast로 바꾸어야 함 -> 4.10 정준영
7-
})
8-
.catch((err) => {
9-
console.error("URL 복사 실패:", err);
10-
});
11-
};
12-
13-
return (
1+
import ToastMessage from "@/components/ToastMessage";
2+
import { useState } from "react";
3+
4+
const UrlCopyButton = ({ currentUrl }: { currentUrl: string }) => {
5+
const [toastMessage, setToastMessage] = useState<string>("");
6+
7+
const handleCopy = () => {
8+
navigator.clipboard
9+
.writeText(currentUrl)
10+
.then(() => {
11+
setToastMessage("URL을 복사했습니다.");
12+
})
13+
.catch((err) => {
14+
console.error("URL 복사 실패:", err);
15+
});
16+
};
17+
18+
return (
19+
<>
1420
<button
1521
onClick={handleCopy}
16-
className="bg-primary-normal h-8 text-white flex items-center justify-center rounded-[20px] px-4 py-2"
22+
className="flex h-8 items-center justify-center rounded-[20px] bg-primary-normal px-4 py-2 text-white"
1723
>
1824
복사
1925
</button>
20-
);
21-
};
22-
23-
export default UrlCopyButton;
26+
{toastMessage && (
27+
<ToastMessage
28+
message={toastMessage}
29+
onClose={() => setToastMessage("")}
30+
/>
31+
)}
32+
</>
33+
);
34+
};
35+
36+
export default UrlCopyButton;

src/components/tips/TipsMenu.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ import trackClickEvent from "@/utils/trackClickEvent";
22
import { Link } from "react-router-dom";
33

44
const TipsMenu = ({
5-
mode
5+
mode,
6+
mbti,
7+
conversationId
68
}: {
7-
mode: "topic" | "conversation" | "temporature";
9+
mode: "topic" | "conversation" | "temperature";
10+
mbti?: string;
11+
conversationId?: string;
812
}) => {
913
let text = "";
1014
let tagElement = "";
@@ -16,19 +20,19 @@ const TipsMenu = ({
1620
text = "대화 주제 추천";
1721
tagElement = "대화 주제 추천";
1822
imageUrl = "/icon/starbubble.svg";
19-
href = "/chat-recommend";
23+
href = `/chat-recommend/${mbti}`;
2024
break;
2125
case "conversation":
2226
text = "대화 꿀팁";
2327
tagElement = "대화 꿀팁";
2428
imageUrl = "/icon/lightbulb.svg";
25-
href = "/chat-tips";
29+
href = `/chat-tips/${mbti}`;
2630
break;
27-
case "temporature":
31+
case "temperature":
2832
text = "현재 대화의 온도 측정하기";
2933
tagElement = "대화의 온도";
3034
imageUrl = "/icon/thermometer.svg";
31-
href = "/chat-temporature";
35+
href = `/chat-temperature/${conversationId}`;
3236
break;
3337
default:
3438
return;

src/components/tips/TipsMenuContainer.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import TipsMenu from "@/components/tips/TipsMenu";
22

3-
const TipsMenuContainer = () => {
3+
const TipsMenuContainer = ({
4+
conversationId,
5+
mbti
6+
}: {
7+
conversationId: string;
8+
mbti: string;
9+
}) => {
410
return (
511
<>
6-
<TipsMenu mode="topic" />
7-
<TipsMenu mode="conversation" />
8-
<TipsMenu mode="temporature" />
12+
<TipsMenu mode="topic" mbti={mbti} />
13+
<TipsMenu mode="conversation" mbti={mbti} />
14+
<TipsMenu mode="temperature" conversationId={conversationId} />
915
</>
1016
);
1117
};

src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ body {
3030

3131
main {
3232
@media screen and (min-width: 360px) {
33+
background-color: white;
3334
font-size: 14px;
3435
width: 360px;
3536
}

0 commit comments

Comments
 (0)