Skip to content

Commit 3034ee2

Browse files
committed
feat: tester login & signout
1 parent 033fdfc commit 3034ee2

6 files changed

Lines changed: 101 additions & 4 deletions

File tree

components/login/SocialLoginButtons.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
55

66
import AppleLogin from "@/components/login/AppleLogin";
77
import KakaoLogin from "@/components/login/KakaoLogin";
8+
import TesterLogin from "@/components/login/TesterLogin";
89

910
export default function SocialLoginButtons() {
1011
const insets = useSafeAreaInsets();
@@ -23,6 +24,8 @@ export default function SocialLoginButtons() {
2324
<KakaoLogin />
2425
<View className="my-2" />
2526
{isIOS ? <AppleLogin /> : null}
27+
{isIOS ? <View className="my-2" /> : null}
28+
<TesterLogin />
2629
</View>
2730
<Pressable
2831
onPress={() => router.push("/(tabs)")}

components/login/TesterLogin.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Pressable, Text } from "react-native";
2+
3+
import { testerLogin } from "@/features/auth/testerLogin";
4+
5+
export default function TesterLogin() {
6+
return (
7+
<Pressable
8+
onPress={testerLogin}
9+
className="mx-auto w-full max-w-[500px] flex-row items-center justify-center gap-2 rounded-xl bg-gray-500 px-6 py-4 active:opacity-80"
10+
>
11+
<Text className="text-white">For Test</Text>
12+
</Pressable>
13+
);
14+
}

components/mypage/WithDrawForm.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Animated from "react-native-reanimated";
33
import Svg, { Path } from "react-native-svg";
44

55
import Separator from "@/components/ui/Separator";
6+
import { withdraw } from "@/features/auth/withdraw";
67
import useWithDrawForm from "@/hooks/useWithDrawForm";
78

89
type AccordionProps = {
@@ -91,10 +92,16 @@ export default function WithDrawForm({ title, items }: AccordionProps) {
9192
className={`w-full rounded-lg py-4 ${
9293
checkSubmit() ? "bg-[#816BFF]" : "bg-[#D1C9FF]"
9394
}`}
94-
onPress={() => {
95-
// TODO : 제출 동작
96-
console.log("이유", selected);
97-
console.log("상세 이유", otherReason);
95+
onPress={async () => {
96+
if (checkSubmit()) {
97+
console.log("이유", selected);
98+
console.log("상세 이유", otherReason);
99+
try {
100+
await withdraw();
101+
} catch (error) {
102+
console.error("회원탈퇴 실패:", error);
103+
}
104+
}
98105
}}
99106
>
100107
<Text className="text-center text-[16px] font-semibold text-white">

constants/ApiUrls.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export const UsersSchedulesUrl = `${BACKEND_URL}/users/schedules`;
2020
const AuthUrl = `${BACKEND_URL}/auth`;
2121
export const LoginUrl = `${AuthUrl}/login`;
2222
export const LogoutUrl = `${AuthUrl}/logout`;
23+
export const WithdrawUrl = `${AuthUrl}/withdraw`;

features/auth/testerLogin.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { router } from "expo-router";
2+
import * as SecureStore from "expo-secure-store";
3+
4+
import { LoginUrl } from "@/constants/ApiUrls";
5+
import { publicApi } from "@/features/axios/axiosInstance";
6+
import useUserStore from "@/stores/useUserStore";
7+
8+
export async function testerLogin() {
9+
try {
10+
const response = await publicApi.post(LoginUrl, {
11+
socialId: "tester1",
12+
socialType: "APPLE",
13+
});
14+
15+
const accessToken = response.data.result.accessToken;
16+
const refreshToken = response.data.result.refreshToken;
17+
const nickname = response.data.result.nickname;
18+
const image = response.data.result.image;
19+
20+
console.log("🧪 테스터 로그인 성공 - 사용자 정보:", {
21+
nickname,
22+
image: image ? "있음" : "없음",
23+
accessToken: accessToken ? "있음" : "없음",
24+
refreshToken: refreshToken ? "있음" : "없음",
25+
});
26+
27+
await SecureStore.setItemAsync("accessToken", accessToken);
28+
await SecureStore.setItemAsync("refreshToken", refreshToken);
29+
30+
// Store에 사용자 정보 저장
31+
const { setUserInfo } = useUserStore.getState().action;
32+
setUserInfo(nickname || "Tester", image || "");
33+
34+
console.log("💾 Store에 저장 완료:", {
35+
storedNickname: nickname || "Tester",
36+
storedImage: image || "",
37+
userStoreState: useUserStore.getState(),
38+
});
39+
40+
router.push("/(tabs)");
41+
} catch (error) {
42+
console.log("테스터 로그인 에러:", error);
43+
}
44+
}

features/auth/withdraw.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { router } from "expo-router";
2+
import * as SecureStore from "expo-secure-store";
3+
4+
import { WithdrawUrl } from "@/constants/ApiUrls";
5+
import { authApi } from "@/features/axios/axiosInstance";
6+
import useUserStore from "@/stores/useUserStore";
7+
8+
export async function withdraw() {
9+
try {
10+
await authApi.delete(WithdrawUrl);
11+
12+
console.log("회원탈퇴 성공");
13+
14+
// 토큰 삭제
15+
await SecureStore.deleteItemAsync("accessToken");
16+
await SecureStore.deleteItemAsync("refreshToken");
17+
18+
// Store 초기화
19+
const { clearUserInfo } = useUserStore.getState().action;
20+
clearUserInfo();
21+
22+
// 로그인 화면으로 이동
23+
router.replace("/");
24+
} catch (error) {
25+
console.log("회원탈퇴 에러:", error);
26+
throw error;
27+
}
28+
}

0 commit comments

Comments
 (0)