Skip to content

Commit 3665381

Browse files
authored
[FRONTEND] 회원가입 기능 구현 (#24)
## #️⃣연관된 이슈 없음 ## 📝작업 내용 회원가입 기능 구현, 백엔드 연결 x
1 parent 0bb2ec1 commit 3665381

File tree

24 files changed

+3287
-261
lines changed

24 files changed

+3287
-261
lines changed

frontend/.env

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
VITE_KAKAO_CLIENT_ID=e84faf4e473047e82fd05e50e9b0c0ce
2+
VITE_KAKAO_AUTH_URL=https://kauth.kakao.com/oauth/authorize
3+
VITE_KAKAO_REDIRECT_URI=http://localhost:3000/oauth/kakao/redirect
4+
VITE_API_URL=https://api.comtogether.com

frontend/.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"cSpell.words": [
3+
"kakao",
4+
"lineheigh",
5+
"lineheight",
6+
"VITE"
7+
]
8+
}

frontend/package-lock.json

Lines changed: 3021 additions & 229 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13+
"@tanstack/react-query": "^5.89.0",
14+
"axios": "^1.12.2",
15+
"i": "^0.3.7",
16+
"npm": "^11.6.0",
1317
"react": "^19.1.1",
1418
"react-dom": "^19.1.1",
1519
"react-router": "^7.8.2",

frontend/src/api/.gitkeep

Whitespace-only changes.

frontend/src/api/useKakaoLogin.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import axios from "axios";
2+
import { useMutation } from "@tanstack/react-query";
3+
import { useAuthStore } from "../stores/useAuthStore";
4+
import { useTokenStore } from "../stores/useTokenStore";
5+
6+
export const useKakaoLogin = () => {
7+
const setUser = useAuthStore((state) => state.setUser);
8+
const setTokens = useTokenStore((state) => state.setTokens);
9+
10+
const mutation = useMutation({
11+
mutationFn: (code: string) =>
12+
axios.post(
13+
`${import.meta.env.VITE_API_URL}/auth/kakao`,
14+
{ code }
15+
),
16+
onSuccess: (response) => {
17+
const { user, accessToken, refreshToken } = response.data;
18+
setUser(user);
19+
setTokens(accessToken, refreshToken);
20+
},
21+
onError: (error) => {
22+
console.error("Kakao login error:", error);
23+
},
24+
});
25+
26+
const initiateKakaoLogin = () => {
27+
const kakaoAuthUrl = `https://kauth.kakao.com/oauth/authorize?client_id=${import.meta.env.VITE_KAKAO_CLIENT_ID}&redirect_uri=${import.meta.env.VITE_KAKAO_REDIRECT_URI}&response_type=code`;
28+
window.location.href = kakaoAuthUrl;
29+
};
30+
31+
return { initiateKakaoLogin, mutation };
32+
}

frontend/src/assets/image/icon/chatBotIcon.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default function ChatBotIcon({ text }: { text: string }) {
1616
dominantBaseline="middle"
1717
fontSize="23.657px"
1818
fontWeight="700"
19-
lineHeight="150%"
19+
lineheight="150%"
2020
fill="#fff"
2121
>
2222
{text}
@@ -30,9 +30,9 @@ export default function ChatBotIcon({ text }: { text: string }) {
3030
width="84.4844"
3131
height="84.4844"
3232
filterUnits="userSpaceOnUse"
33-
color-interpolation-filters="sRGB"
33+
colorInterpolationFilters="sRGB"
3434
>
35-
<feFlood flood-opacity="0" result="BackgroundImageFix" />
35+
<feFlood floodOpacity="0" result="BackgroundImageFix" />
3636
<feColorMatrix
3737
in="SourceAlpha"
3838
type="matrix"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import style from "./chatBot.module.css";
2+
import { useSearchChatBotStore } from "@/stores/useSearchChatBotStore";
3+
import RecentSearchItem from "./recentSearchItem";
4+
import SearchResult from "./searchResult/searchResult";
5+
6+
export default function ChatBot() {
7+
const { result, resultNotFound, recentSearches } =
8+
useSearchChatBotStore.useMultiple((state) => ({
9+
result: state.result,
10+
resultNotFound: state.resultNotFound,
11+
recentSearches: state.recentSearches,
12+
}));
13+
14+
const clearRecentSearches = useSearchChatBotStore.useClearRecentSearches();
15+
16+
return (
17+
<div className={style.chatBot}>
18+
{/* 검색 결과가 있는 경우 */}
19+
{result && <SearchResult />}
20+
21+
{/* 검색 결과가 없는 경우 */}
22+
{resultNotFound && (
23+
<div className={style.noResult}>
24+
<p>검색 결과가 없습니다.</p>
25+
<p>다른 키워드로 검색해보세요.</p>
26+
</div>
27+
)}
28+
29+
{/* 최근 검색어 */}
30+
{!result && !resultNotFound && recentSearches.length > 0 && (
31+
<div className={style.recentSearches}>
32+
<div className={style.recentHeader}>
33+
<span>최근 검색어</span>
34+
<button onClick={clearRecentSearches}>전체 삭제</button>
35+
</div>
36+
<div className={style.recentList}>
37+
{recentSearches.map((keyword) => (
38+
<RecentSearchItem key={keyword} keyword={keyword} />
39+
))}
40+
</div>
41+
</div>
42+
)}
43+
</div>
44+
);
45+
}

frontend/src/components/common/chatBot/chatBotModal/chatBotModal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import close_icon from "@/assets/image/icon/close_icon.svg";
55
import SearchBar from "@/components/common/searchBar/searchBar";
66
import SearchResult from "@/components/common/chatBot/searchResult/searchResult";
77
import { useSearchChatBotStore } from "@/stores/useSearchChatBotStore";
8+
import { useShallow } from "zustand/shallow";
89

910
interface ChatBotModalProps {
1011
open: boolean;
@@ -13,7 +14,12 @@ interface ChatBotModalProps {
1314

1415
export default function ChatBotModal({ open, onClose }: ChatBotModalProps) {
1516
const modalBackground = useRef<HTMLDivElement>(null);
16-
const { result, setShowMore } = useSearchChatBotStore();
17+
const { result, setShowMore } = useSearchChatBotStore(
18+
useShallow((state) => ({
19+
result: state.result,
20+
setShowMore: state.setShowMore,
21+
}))
22+
);
1723

1824
if (!open) return null;
1925

frontend/src/components/common/chatBot/recentSearchItem.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ const style = {
2424
cursor: "pointer",
2525
};
2626

27-
export default function RecentSearchItem({
28-
keyword,
29-
onRemove,
30-
}: RecentSearchItemProps) {
31-
const { setSearch, handleSearch } = useSearchChatBotStore();
27+
export default function RecentSearchItem({ keyword }: RecentSearchItemProps) {
28+
const { setSearch, handleSearch, handleRemoveRecent } =
29+
useSearchChatBotStore();
3230
const onClick = () => {
3331
setSearch(keyword);
3432
setTimeout(() => {
@@ -42,7 +40,7 @@ export default function RecentSearchItem({
4240
className="recent-search-remove"
4341
onClick={(e) => {
4442
e.stopPropagation();
45-
onRemove(keyword);
43+
handleRemoveRecent(keyword);
4644
}}
4745
>
4846
&nbsp;

0 commit comments

Comments
 (0)