{"version":3,"file":"static/chunks/8903-114b2e4a7385a456.js","mappings":"AAAA","sources":["webpack://_N_E/./src/hooks/useSessionUrl.ts","webpack://_N_E/./src/api/auth.ts","webpack://_N_E/./src/components/Member/hooks/useKakaoSignInUp.ts","webpack://_N_E/./src/components/signIn/SignInComponents.tsx","webpack://_N_E/./src/pages/member/login/index.tsx","webpack://_N_E/"],"sourcesContent":["const useSessionUrl = ()=>{\n const isBrowser = \"object\" !== \"undefined\";\n const setSessionUrl = (url)=>{\n if (!isBrowser) {\n return;\n }\n sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem(\"sessionUrl\", url);\n };\n const getSessionUrl = ()=>{\n if (!isBrowser) {\n return;\n }\n if (!(sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem(\"sessionUrl\"))) {\n return null;\n }\n return sessionStorage.getItem(\"sessionUrl\");\n };\n const removeSessionUrl = ()=>{\n if (!isBrowser) {\n return;\n }\n sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.removeItem(\"sessionUrl\");\n };\n return {\n setSessionUrl,\n getSessionUrl,\n removeSessionUrl\n };\n};\nexport default useSessionUrl;\n","import { otherApiClient } from \"./index\";\nexport const fetchAccessToken = async (id)=>{\n const { data } = await otherApiClient.market(\"/auth/kakao/accessToken\", {\n params: {\n identificationId: id\n }\n });\n return data;\n};\n","import useRedirect, { REDIRECT_QUERY } from \"@/hooks/useRedirect\";\nimport { useAuthStore } from \"@/lib/auth/AuthStore\";\nimport { gaSignupCompleted } from \"@/lib/ga4\";\nimport { loginCompleted, signupCompleted, updateUserInfoMixpanel } from \"@/lib/mixpanels/mixpanel\";\nimport { HOME_PAGE, LOGIN_PAGE, SIGNUP_AFTER_USER_PROFILE } from \"@/settings/constant\";\nimport { useMutation } from \"@tanstack/react-query\";\nimport { useRouter } from \"next/router\";\nimport { useCallback, useEffect } from \"react\";\nimport { getMe } from \"src/api/getMe\";\nimport LoginDialog from \"src/store/loginDialog\";\nimport { useSavedUserSourceStore } from \"src/store/main\";\nimport useSessionUrl from \"../../../hooks/useSessionUrl\";\nimport dayjs from \"dayjs\";\nimport { fetchAccessToken } from \"../../../api/auth\";\n// 환경설정 분리\nconst KAKAO_AUTH_CONFIG = {\n REDIRECT_URI: \"\".concat(process.env.NEXT_PUBLIC_MARKET_API_ENDPOINT, \"/auth/kakao/callback\"),\n APP_ENDPOINT: process.env.NEXT_PUBLIC_APP_ENDPOINT\n};\nconst useKakaoSignInUp = ()=>{\n const router = useRouter();\n const { query , pathname } = router;\n const authStore = useAuthStore();\n const { getSessionUrl , setSessionUrl , removeSessionUrl } = useSessionUrl();\n const { setState } = LoginDialog((state)=>({\n isOpenSignUpDialog: state.isOpenLoginDialog,\n setState: state.setState\n })) //회원가입, 로그인시 다이얼로그 store\n ;\n const getMeMutation = useMutation(getMe);\n const { redirectAgain , redirectPath } = useRedirect();\n const fetchAccesTokenMutation = useMutation(fetchAccessToken);\n const { updateUserMeta } = useSavedUserSourceStore((param)=>{\n let { updateUserMeta } = param;\n return {\n updateUserMeta\n };\n });\n // 카카오 로그인 핸들러 개선\n const onKakao = useCallback(async ()=>{\n removeSessionUrl();\n redirectPath && setSessionUrl(redirectPath);\n try {\n const { Kakao } = window;\n await Kakao.Auth.authorize({\n redirectUri: KAKAO_AUTH_CONFIG.REDIRECT_URI,\n state: \"\".concat(KAKAO_AUTH_CONFIG.APP_ENDPOINT).concat(router.pathname)\n });\n } catch (error) {\n handleError(error);\n }\n }, [\n pathname,\n redirectPath\n ]);\n // 인증 후 처리 로직 개선\n const processKakaoCallback = async (param)=>{\n let { identificationId , signupUser } = param;\n try {\n const { accessToken } = await fetchAccesTokenMutation.mutateAsync(identificationId);\n const { user } = await getMeMutation.mutateAsync(accessToken);\n authStore.updateUser(user);\n updateUserMeta({\n mainSubject: user === null || user === void 0 ? void 0 : user.mainSubject,\n job: user === null || user === void 0 ? void 0 : user.job\n });\n trackUserLogin({\n signupUser,\n user\n });\n handleRedirect(user);\n } catch (error) {\n handleError(error);\n }\n };\n const trackUserLogin = (param)=>{\n let { signupUser , user } = param;\n {\n (user === null || user === void 0 ? void 0 : user.job) && updateUserInfoMixpanel({\n userProfile: {\n subject: user === null || user === void 0 ? void 0 : user.mainSubject,\n userType: user === null || user === void 0 ? void 0 : user.job,\n school: []\n },\n userId: user.id.toString()\n });\n }\n if (signupUser === \"true\") {\n signupCompleted({\n user_id: authStore.user.id.toString(),\n \"Registration Method\": \"kakao\",\n \"Login Method\": \"kakao\",\n $name: authStore.user.displayName,\n $email: authStore.user.email,\n \"Phone Number\": authStore.user.phoneNumber\n });\n gaSignupCompleted({\n user_id: authStore.user.id.toString(),\n registration_date: dayjs().format(\"YYYY-MM-DD HH:mm:ss\"),\n type: \"kakao\",\n name: authStore.user.displayName\n });\n }\n loginCompleted({\n user_id: authStore.user.id.toString(),\n \"Registration Method\": \"kakao\",\n \"Login Method\": \"kakao\",\n $name: authStore.user.displayName,\n $email: authStore.user.email,\n \"Phone Number\": authStore.user.phoneNumber\n });\n };\n const handleRedirect = (user)=>{\n //TODO 세션에 저장한거 보내주기\n const savedRedirectPath = getSessionUrl();\n if (!(user === null || user === void 0 ? void 0 : user.job) && pathname.includes(\"login\")) {\n router.push({\n pathname: \"\".concat(SIGNUP_AFTER_USER_PROFILE),\n query: savedRedirectPath ? {\n [REDIRECT_QUERY]: savedRedirectPath,\n alreadySignupUser: true\n } : {\n alreadySignupUser: true\n }\n });\n return;\n } else if (!(user === null || user === void 0 ? void 0 : user.job)) {\n router.push({\n pathname: \"\".concat(SIGNUP_AFTER_USER_PROFILE),\n query: savedRedirectPath && {\n [REDIRECT_QUERY]: savedRedirectPath\n }\n });\n return;\n }\n if (savedRedirectPath) {\n router.push(savedRedirectPath);\n return;\n }\n router.push(HOME_PAGE);\n };\n const handleError = (status)=>{\n if (status === \"409\") {\n setState(\"openSignUpDialogContents\", {\n title: \"휴대폰 번호로 이미 가입했어요.\",\n content: \"로그인 페이지에서 ‘휴대폰 번호로 로그인’ 버튼을 클릭해주세요.\",\n btnLabel: \"로그인하러 가기\",\n onOk: ()=>{\n redirectAgain(LOGIN_PAGE);\n setState(\"isOpenSignUpDialog\", false);\n }\n });\n } else {\n setState(\"openSignUpDialogContents\", {\n title: \"로그인에 실패했어요.\",\n content: \"다시 시도해주세요. 문제가 지속되면 고객센터로 문의해주세요.\",\n btnLabel: \"로그인하러 가기\",\n onOk: ()=>{\n redirectAgain(LOGIN_PAGE);\n setState(\"isOpenSignUpDialog\", false);\n }\n });\n }\n setState(\"isOpenSignUpDialog\", true);\n };\n useEffect(()=>{\n const { signupUser , identificationId , statusCode } = query;\n //TODO identificationId 있을경우 로그인 처리\n if (statusCode && statusCode !== \"200\") {\n handleError(statusCode.toString());\n return;\n }\n if (identificationId) {\n processKakaoCallback({\n signupUser: signupUser.toString(),\n identificationId: identificationId.toString()\n });\n }\n }, [\n query\n ]);\n return {\n onKakao\n };\n};\nexport default useKakaoSignInUp;\n","import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport useRedirect from \"@/hooks/useRedirect\";\nimport { mixpanelEvent } from \"@/lib/mixpanels/mixpanel\";\nimport { LOGIN_WITH_PHONE_PAGE } from \"@/settings/constant\";\nimport { Button } from \"@bookips/solvook-ui-library\";\nimport { Typography, styled as muiStyled } from \"@mui/material\";\nimport React from \"react\";\nimport Icon from \"../icon/Icon\";\nimport { KakaoLoginIcon, Mobile, Sizes, WhaleIcon } from \"../icon/IconList\";\nconst SignInUp = {\n SIGNIN: \"로그인\",\n SIGNUP: \"가입하기\"\n};\nexport const KakaoButton = (param)=>{\n let { type , onKakao } = param;\n return /*#__PURE__*/ _jsx(KakaoLoginButtonWrapper, {\n children: /*#__PURE__*/ _jsx(Button, {\n variant: \"solid\",\n className: \"login-btn\",\n onClick: ()=>{\n onKakao();\n //mx-119, mx-121\n mixpanelEvent(\"\".concat(SignInUp[type] === SignInUp.SIGNIN ? \"Login\" : \"Sign Up\", \" Started\"), {\n \"Button Name\": \"\".concat(SignInUp[type] === SignInUp.SIGNIN ? \"카카오로 로그인\" : \"카카오로 가입하기\")\n });\n },\n label: /*#__PURE__*/ _jsxs(Typography, {\n variant: \"semibold16\",\n children: [\n /*#__PURE__*/ _jsx(Icon, {\n icon: KakaoLoginIcon,\n size: Sizes.small\n }),\n \"카카오로 \",\n SignInUp[type]\n ]\n })\n })\n });\n};\nexport const PhoneButton = (param)=>{\n let { type , onPhone } = param;\n const { redirectAgain } = useRedirect();\n const handleClick = ()=>{\n redirectAgain(LOGIN_WITH_PHONE_PAGE);\n // mx-121\n mixpanelEvent(\"Login Started\", {\n \"Button Name\": \"휴대폰 번호로 로그인\"\n });\n };\n return /*#__PURE__*/ _jsx(Button, {\n variant: \"strokeSecondary\",\n onClick: onPhone || handleClick,\n className: \"login-btn\",\n label: /*#__PURE__*/ _jsxs(Typography, {\n variant: \"semibold16\",\n children: [\n /*#__PURE__*/ _jsx(Icon, {\n icon: Mobile,\n size: Sizes.small\n }),\n \"휴대폰 번호로 \",\n SignInUp[type]\n ]\n })\n });\n};\nexport const WhaleButton = ()=>{\n const { redirectAgain } = useRedirect();\n const onWhale = ()=>{\n // @todo redirect url이 붙는 작업 필요\n // mx-121\n mixpanelEvent(\"Login Started\", {\n \"Button Name\": \"웨일로 로그인\"\n });\n redirectAgain(process.env.NEXT_PUBLIC_API_ENDPOINT + \"/sessions/oauth/whale/authorize/\");\n };\n return /*#__PURE__*/ _jsx(WhaleLoginButtonWrapper, {\n children: /*#__PURE__*/ _jsx(Button, {\n className: \"whale-btn\",\n onClick: onWhale,\n children: /*#__PURE__*/ _jsx(Icon, {\n icon: WhaleIcon\n })\n })\n });\n};\nexport const SignInMain = (param)=>{\n let { children } = param;\n return /*#__PURE__*/ _jsx(SignInWrapper, {\n children: /*#__PURE__*/ _jsx(\"div\", {\n children: children\n })\n });\n};\nexport const SignIn = Object.assign(SignInMain, {\n KakaoButton: KakaoButton,\n PhoneButton: PhoneButton,\n WhaleButton: WhaleButton\n});\nexport const SignInWrapper = muiStyled(\"div\")((param)=>{\n let { theme } = param;\n return {\n width: \"100%\",\n maxWidth: \"440px\",\n height: \"100%\",\n minHeight: \"600px\",\n maxHeight: \"800px\",\n display: \"flex\",\n flexDirection: \"column\",\n padding: \"60px 0\",\n margin: \"40px 0\",\n background: \"white\",\n borderRadius: \"12px\",\n boxShadow: \"0px 4px 12px 0px rgba(0, 0, 0, 0.08), 0px 4px 8px 0px rgba(0, 0, 0, 0.04)\",\n \"> div\": {\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"32px\",\n margin: \"0 40px\",\n \"&:not(:nth-of-type(1))\": {\n marginTop: \"16px\"\n }\n },\n \".login-btn\": {\n height: \"56px\",\n span: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"8px\"\n }\n },\n \"&:hover\": {\n borderColor: theme.palette.primary.main\n },\n \"@media (max-width: 1200px)\": {\n boxShadow: \"none\",\n padding: \"32px 0\",\n margin: \"0\"\n },\n \"@media (max-width: 768px)\": {\n \"> div\": {\n margin: \"0 20px\"\n }\n }\n };\n});\nexport const WhaleLoginButtonWrapper = muiStyled(\"div\")((param)=>{\n let { theme } = param;\n return {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n button: {\n width: \"64px\",\n height: \"64px\",\n padding: \"0\",\n borderRadius: \"80px\",\n border: \"1px solid \".concat(theme.palette.grey[200])\n },\n \"@media (max-width: 1200px)\": {},\n \"@media (max-width: 768px)\": {}\n };\n});\nexport const KakaoLoginButtonWrapper = muiStyled(\"div\")((param)=>{\n let { theme } = param;\n return {\n button: {\n backgroundColor: \"#fee500\",\n width: \"100%\",\n height: \"56px\",\n display: \"flex\",\n gap: \"8px\",\n alignItems: \"center\",\n borderRadius: \"6px\",\n color: theme.palette.blackAndWhite.black,\n \"@media (max-width: 1200px)\": {},\n \"@media (max-width: 768px)\": {},\n \"&:hover, &:active\": {\n backgroundColor: \"#F0DA11\"\n }\n }\n };\n});\n","import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from \"react/jsx-runtime\";\nimport { MemberPageHeader } from \"@/components/Member/MemberPageHeader\";\nimport { MemberPageLayout } from \"@/components/Member/MemberPageLayout\";\nimport useKakaoSignInUp from \"@/components/Member/hooks/useKakaoSignInUp\";\nimport Icon from \"@/components/icon/Icon\";\nimport { ArrowRight, Sizes } from \"@/components/icon/IconList\";\nimport { SignIn } from \"@/components/signIn/SignInComponents\";\nimport useRedirect from \"@/hooks/useRedirect\";\nimport { mixpanelEvent } from \"@/lib/mixpanels/mixpanel\";\nimport useWindowDimensions from \"@/lib/web-ui/useWindowDimensions\";\nimport { REGISTRATION_PAGE } from \"@/settings/constant\";\nimport { Button, ConfirmDialog } from \"@bookips/solvook-ui-library\";\nimport { Divider, Typography, styled as muiStyled, useTheme } from \"@mui/material\";\nimport LoginDialog from \"src/store/loginDialog\";\nimport { FooterButtonBox } from \"../signup/form\";\nconst LoginNextPage = ()=>{\n const theme = useTheme();\n const { isTablet } = useWindowDimensions();\n const { onKakao } = useKakaoSignInUp();\n const { redirectPath , redirectAgain } = useRedirect();\n let isPartnerLogin = false;\n if (typeof redirectPath === \"string\" && redirectPath.startsWith(\"http\")) {\n const destinationDomain = new URL(redirectPath);\n isPartnerLogin = destinationDomain.origin === process.env.NEXT_PUBLIC_PARTNER_URL;\n }\n const { isOpenSignUpDialog , openSignUpDialogContents , setState } = LoginDialog((state)=>({\n isOpenSignUpDialog: state.isOpenSignUpDialog,\n openSignUpDialogContents: state.openSignUpDialogContents,\n setState: state.setState\n })) //회원가입, 로그인시 다이얼로그 store\n ;\n return /*#__PURE__*/ _jsxs(LoginNextPageWrapper, {\n children: [\n isTablet ? /*#__PURE__*/ _jsx(MemberPageHeader, {\n pageTitle: \"로그인\",\n showBackButton: true\n }) : /*#__PURE__*/ _jsx(MemberPageHeader, {\n showLogo: true\n }),\n /*#__PURE__*/ _jsxs(SignIn, {\n children: [\n /*#__PURE__*/ _jsx(Typography, {\n variant: \"bold28\",\n sx: {\n textAlign: \"center\"\n },\n children: !isPartnerLogin ? /*#__PURE__*/ _jsxs(_Fragment, {\n children: [\n \"쏠북에 다시 오신걸\",\n /*#__PURE__*/ _jsx(\"br\", {}),\n \" 환영합니다!\"\n ]\n }) : /*#__PURE__*/ _jsxs(_Fragment, {\n children: [\n \"쏠북 저자센터\",\n /*#__PURE__*/ _jsx(\"br\", {}),\n \"로그인\"\n ]\n })\n }),\n /*#__PURE__*/ _jsxs(InnerBox, {\n children: [\n /*#__PURE__*/ _jsxs(\"div\", {\n className: \"sing-in-btn-box\",\n children: [\n /*#__PURE__*/ _jsx(SignIn.KakaoButton, {\n type: \"SIGNIN\",\n onKakao: onKakao\n }),\n /*#__PURE__*/ _jsx(SignIn.PhoneButton, {\n type: \"SIGNIN\"\n })\n ]\n }),\n !isPartnerLogin && /*#__PURE__*/ _jsxs(_Fragment, {\n children: [\n /*#__PURE__*/ _jsx(Divider, {\n children: /*#__PURE__*/ _jsx(Typography, {\n variant: \"bold12\",\n color: theme.palette.text.disabled,\n children: \"또는\"\n })\n }),\n /*#__PURE__*/ _jsx(SignIn.WhaleButton, {})\n ]\n }),\n /*#__PURE__*/ _jsxs(ButtonInTypography, {\n variant: \"regular14\",\n color: theme.palette.text.secondary,\n sx: {\n gap: \"8px\"\n },\n children: [\n isPartnerLogin ? \"쏠북 저자가 아니신가요?\" : \"쏠북에 처음 오셨나요?\",\n /*#__PURE__*/ _jsx(Button, {\n variant: \"strokeSecondary\",\n className: \"sign-up-btn\",\n label: /*#__PURE__*/ _jsxs(ButtonInTypography, {\n variant: \"semibold14\",\n color: theme.palette.text.secondary,\n sx: {\n gap: \"4px\"\n },\n onClick: isPartnerLogin ? ()=>{\n window.open(\"https://promotion.solvook.com/apply/author\");\n } : ()=>{\n //mx-122\n mixpanelEvent(\"Sign Up Button Clicked\");\n redirectAgain(\"\".concat(REGISTRATION_PAGE));\n },\n children: [\n isPartnerLogin ? \"저자 신청\" : \"회원가입\",\n /*#__PURE__*/ _jsx(Icon, {\n icon: ArrowRight,\n size: Sizes.smallHalf,\n color: theme.palette.text.secondary\n })\n ]\n })\n })\n ]\n })\n ]\n })\n ]\n }),\n /*#__PURE__*/ _jsx(ConfirmDialog, {\n open: isOpenSignUpDialog,\n severity: openSignUpDialogContents.severity || \"caution\",\n onClose: ()=>{},\n title: openSignUpDialogContents.title,\n content: openSignUpDialogContents.content,\n footer: /*#__PURE__*/ _jsx(FooterButtonBox, {\n children: /*#__PURE__*/ _jsx(Button, {\n variant: \"solid\",\n label: openSignUpDialogContents.btnLabel,\n onClick: ()=>{\n openSignUpDialogContents.onOk();\n setState(\"isOpenSignUpDialog\", false);\n }\n })\n })\n })\n ]\n });\n};\nLoginNextPage.getLayout = (page)=>{\n return /*#__PURE__*/ _jsx(MemberPageLayout, {\n children: page\n });\n};\nconst LoginNextPageWrapper = muiStyled(\"div\")((param)=>{\n let { theme } = param;\n return {\n width: \"100%\",\n height: \"100%\",\n minHeight: \"752px\",\n display: \"flex\",\n flexDirection: \"column\",\n alignItems: \"center\",\n h1: {\n fontSize: \"40px\",\n fontWeight: \"bold\",\n marginBottom: \"64px\",\n \"@media (max-width: 1200px)\": {},\n \"@media (max-width: 768px)\": {}\n }\n };\n});\nexport const InnerBox = muiStyled(\"div\")((param)=>{\n let { theme } = param;\n return {\n width: \"100%\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"20px\",\n \".sing-in-btn-box\": {\n position: \"relative\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"12px\"\n },\n \".sign-up-btn\": {\n height: \"24px\",\n padding: \"2px 8px\",\n gap: \"4px\"\n }\n };\n});\nexport const ButtonInTypography = muiStyled(Typography)((param)=>{\n let { theme } = param;\n return {\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\"\n };\n});\nexport default LoginNextPage;\n"],"names":[],"sourceRoot":""}