Skip to content

Commit

Permalink
fix: 최초 로그인 시 기기 언어를 확인하여 기본 설정 언어(setting_language) 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
nnyouung committed Dec 22, 2024
1 parent 5c65366 commit c479a2a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/pages/login/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@ import { useTranslation } from "react-i18next";
import * as SecureStore from "expo-secure-store";
import * as Sentry from "@sentry/react-native";
import * as Notifications from "expo-notifications";
import { getLocales } from "expo-localization";

import { CustomTheme } from "@styles/CustomTheme";
import LoginStyles from "@pages/login/LoginStyles";
import { useOnboarding } from "src/states/OnboardingContext.js";
import { useAuth } from "src/states/AuthContext";
import { getMyProfile, login, createNotificationToken } from "config/api";
import {
getMyProfile,
login,
createNotificationToken,
updateMyProfile,
} from "config/api";

import BottomTwoButtons from "@components/common/BottomTwoButtons";
import IconNotSeePw from "@components/login/IconNotSeePw";
Expand Down Expand Up @@ -78,6 +84,7 @@ const LoginPage = () => {
const id = loginResponse.data.member_id;
const accessToken = loginResponse.data.accessToken;
const refreshToken = loginResponse.data.refreshToken;
const isFirstLogin = loginResponse.data.isFirstLogin;

await SecureStore.setItemAsync("memberId", JSON.stringify(id));
await SecureStore.setItemAsync("accessToken", accessToken);
Expand All @@ -87,6 +94,10 @@ const LoginPage = () => {
console.log(accessToken);
updateOnboardingData({ id, accessToken, refreshToken });

if (isFirstLogin) {
await updateSettingLanguage();
}

const profileResponse = await getMyProfile();
if (profileResponse.data.isVerified) {
setIsLoggedIn(true);
Expand Down Expand Up @@ -132,6 +143,19 @@ const LoginPage = () => {
}
};

const updateSettingLanguage = async () => {
try {
const formData = new FormData();
formData.append(
"settingLanguage",
getLocales()[0].languageCode.toUpperCase(),
);
await updateMyProfile(formData);
} catch (error) {
console.error("언어 설정 업데이트 오류:", error);
}
};

useEffect(() => {
if (isMockLoginEnabled) {
emailRef.val = mockEmail;
Expand Down

0 comments on commit c479a2a

Please sign in to comment.