Skip to content

Commit 24202de

Browse files
authored
Merge pull request #119 from MBTips/dev
6차 배포 Test (Dev -> Main)
2 parents e4f8059 + 770943e commit 24202de

File tree

5 files changed

+51
-11
lines changed

5 files changed

+51
-11
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ jobs:
2525
npm install tailwindcss@latest postcss@latest autoprefixer@latest
2626
npm install --save-dev @types/node
2727
28+
- name: Create .env file # env 파일 생성 단계 추가
29+
run: |
30+
echo "VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }}" > .env
31+
2832
- name: Run build
2933
run: npm run build --verbose # 프로젝트에 맞는 빌드 명령어
30-
env:
31-
VITE_GA_MEASUREMENT_ID: ${{ secrets.VITE_GA_MEASUREMENT_ID }} # Google Analytics 환경 변수 사용
3234

3335
- name: Docker build & push
3436
run: |

src/components/ToastMessage.tsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useEffect } from "react";
2+
3+
interface ToastMessageProps {
4+
message: string;
5+
duration?: number;
6+
onClose: () => void;
7+
}
8+
9+
const ToastMessage = ({
10+
message,
11+
duration = 3000,
12+
onClose
13+
}: ToastMessageProps) => {
14+
useEffect(() => {
15+
const timer = setTimeout(onClose, duration);
16+
return () => clearTimeout(timer);
17+
}, [duration, onClose]);
18+
19+
return (
20+
<div className="fixed bottom-[108px] left-1/2 flex h-[52px] w-full max-w-[320px] -translate-x-1/2 items-center justify-center rounded-[12px] bg-black text-center text-[16px] leading-[24px] font-medium tracking-[0%] text-white">
21+
{message}
22+
</div>
23+
);
24+
};
25+
26+
export default ToastMessage;

src/libs/analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import ReactGA from "react-ga4";
22

33
const GA_MEASUREMENT_ID = import.meta.env.VITE_GA_MEASUREMENT_ID || "";
44

5-
const isProduction = process.env.NODE_ENV === "production";
5+
const isProduction = import.meta.env.MODE === "production";
66

77
const initGA = () => {
88
if (isProduction && GA_MEASUREMENT_ID) {

src/pages/SelectInfo.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import FormButton from "@/components/button/FormButton";
44
import Header from "@/components/Header";
55
import { getMBTIgroup, mapAgeToNumber } from "@/utils/helpers";
66
import instance from "@/api/axios";
7+
import ToastMessage from "@/components/ToastMessage";
78

89
const SelectInfo = () => {
910
const location = useLocation();
@@ -29,6 +30,7 @@ const SelectInfo = () => {
2930
const [gender, setGender] = useState<string | null>(null);
3031
const [relationship, setRelationship] = useState<string | null>(null);
3132
const [interest, setInterest] = useState<string[]>([]);
33+
const [toastMessage, setToastMessage] = useState<string | null>(null);
3234

3335
const mbtiOptions = ["E", "N", "F", "P", "I", "S", "T", "J"];
3436
const ageOptions = ["10대", "20대", "30대 이상"];
@@ -95,17 +97,22 @@ const SelectInfo = () => {
9597
setter(state === value ? null : value);
9698
};
9799

100+
const showToast = (message: string) => {
101+
setToastMessage(message);
102+
setTimeout(() => setToastMessage(null), 3000);
103+
};
104+
98105
const handleStartChat = async () => {
99106
const isMBTIComplete = Object.values(selectedMBTI).every(
100107
(val) => val !== null
101108
);
102109
// 선택한 MBTI값이 하나라도 부재할 경우
103110
if (!isMBTIComplete) {
104-
return alert("각 MBTI 그룹에서 하나의 값을 선택해주세요."); // TODO: Toast popup UI 완료 시 반영 예정
111+
return showToast("MBTI를 선택해주세요");
105112
}
106113
// 이름 필수 && 이름이 입력되지 않았을 경우 (virtualFriend)
107114
if (isNameRequired && !name) {
108-
return alert("이름을 입력해주세요."); // TODO: Toast popup UI 완료 시 반영 예정
115+
return showToast("이름을 입력해주세요");
109116
}
110117

111118
const mbti = `${selectedMBTI.E}${selectedMBTI.N}${selectedMBTI.F}${selectedMBTI.P}`;
@@ -278,6 +285,13 @@ const SelectInfo = () => {
278285
</div>
279286
</div>
280287

288+
{toastMessage && (
289+
<ToastMessage
290+
message={toastMessage}
291+
onClose={() => setToastMessage(null)}
292+
/>
293+
)}
294+
281295
{/* 대화 시작 버튼 */}
282296
<button
283297
className="my-[22px] h-[60px] w-full rounded-[8px] bg-primary-normal font-bold text-white"

vite.config.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ export default defineConfig(({ mode }: { mode: string }) => {
1919
strictPort: true,
2020
allowedHosts: ["mbtips.kr"],
2121
hmr: isProduction
22-
? false // 배포 환경에서는 HMR 비활성화 (WebSocket 사용 안 함)
22+
? {
23+
host: "mbtips.kr",
24+
protocol: "wss"
25+
}
2326
: {
2427
host: "localhost",
2528
protocol: "wss"
@@ -60,11 +63,6 @@ export default defineConfig(({ mode }: { mode: string }) => {
6063
replacement: path.resolve(__dirname, "src/libs")
6164
}
6265
]
63-
},
64-
define: {
65-
"process.env.VITE_GA_MEASUREMENT_ID": JSON.stringify(
66-
process.env.VITE_GA_MEASUREMENT_ID
67-
)
6866
}
6967
};
7068
});

0 commit comments

Comments
 (0)