{"version":3,"file":"LoginPage-eaf40e3e.js","sources":["../../../app/javascript/stores/auth.store.ts","../../../app/javascript/pages/candidate/LoginPage.vue"],"sourcesContent":["import { AxiosResponse } from 'axios';\nimport { acceptHMRUpdate, defineStore } from 'pinia';\nimport AuthService from '@/services/auth.service';\nimport { IRegisterUser, IUserLogin } from '@/types/common/general';\n\ninterface IState {\n  user: Record<string, unknown> | undefined;\n}\n\nconst initialState: IState = { user: AuthService.getUser() };\n\nexport const useAuthStore = defineStore('auth.store', {\n  state: (): IState => ({ ...initialState }),\n  getters: {\n    isAuthenticated: (state: IState) => !!state.user,\n  },\n  actions: {\n    login(user: IUserLogin) {\n      return AuthService.login(user).then(\n        (response: AxiosResponse) => {\n          this.user = response.data;\n          return Promise.resolve(response);\n        },\n        (error) => {\n          return Promise.reject(error);\n        },\n      );\n    },\n    setUser(user: Record<string, unknown> | undefined){\n      this.user = user\n    },\n    logout() {\n      AuthService.logout().then(() => {\n        this.user = undefined;\n      });\n    },\n    register(user: IRegisterUser) {\n      return AuthService.register(user);\n    },\n  },\n});\n\nif (import.meta.hot) {\n  import.meta.hot.accept(acceptHMRUpdate(useAuthStore, import.meta.hot));\n}\n","<template>\n  <div class=\"d-flex justify-content-center px-3\">\n    <div class=\"mw-1091x col-12 bg-white-primary mt-3 pt-5 pb-2 pb-md-5 mx-3 mx-md-5 rounded-8\">\n      <form @submit=\"submitAccount\">\n        <div class=\"sign-up gap-4r gap-md-32px d-flex flex-column\">\n          <div class=\"sign-up__header\">\n            <div class=\"d-flex justify-content-center\">\n              <img alt=\"\" src=\"@/assets/image/logo.svg\" />\n            </div>\n            <h1 class=\"text-center size-20 mt-3 fw-bold mb-0\">繝ュ繧ー繧、繝ウ</h1>\n            <div v-if=\"checkAccountValid\" class=\"text-center mt-4 mb-3\">\n              <span class=\"text-danger bg-danger bg-opacity-10 border rounded-2 border-danger px-1 py-3\">{{ messageError\n                }}</span>\n            </div>\n          </div>\n          <div class=\"sign-up__body\">\n            <div class=\"row justify-content-center\">\n              <div class=\"col-11 col-md-5 pt-3\">\n                <label for=\"email-form\" class=\"form-label size-12\">繝。繝シ繝ォ繧「繝峨Ξ繧ケ</label>\n                <input type=\"email\" class=\"form-control border-0 bg-silver-primary input-primary\"\n                  v-model=\"userInformation.email\" id=\"email-form\" placeholder=\"繝。繝シ繝ォ繧「繝峨Ξ繧ケ繧貞�蜉媾">\n              </div>\n              <div class=\"col-11 col-md-5 pt-3\">\n                <label for=\"password-form\" class=\"form-label size-12 fw-normal\">繝代せ繝ッ繝シ繝�</label>\n                <div class=\"input-group position-relative\">\n                  <input :type=\"checkTypePassword ? 'text' : 'password'\"\n                    class=\"form-control border-0 rounded-2 bg-silver-primary input-primary\"\n                    v-model=\"userInformation.password\" id=\"password-form\" placeholder=\"繝代せ繝ッ繝シ繝峨r蜈・蜉媾">\n                  <div class=\"position-absolute top-15 end-0 pe-3 cursor-pointer\">\n                    <img v-show=\"!checkTypePassword\" @click=\"changeTypePass\" src=\"@/assets/image/pass.svg\" />\n                    <img v-show=\"checkTypePassword\" @click=\"changeTypePass\" src=\"@/assets/image/view-pass.svg\" />\n                  </div>\n                </div>\n              </div>\n\n              <div class=\"mw-576x col-12 size-12 mt-2r mt-md-a4 p-md-0\">\n                <p class=\"text-center mb-2\">\n                  <a href=\"/candidate/forgot_password\" class=\"color-blue-primary text-decoration-none\">繝代せ繝ッ繝シ繝峨r縺雁ソ倥l縺ョ譁ケ縺ッ縺薙■繧噂n                    <img src=\"@/assets/images/icons/arrow-right-blue.svg\" />\n                  </a>\n                </p>\n                <div class=\"row justify-content-center\">\n                  <button class=\"btn-signup btn btn-primary col-md-6 h-3\" type=\"submit\">\n                    繝ュ繧ー繧、繝ウ\n                  </button>\n                </div>\n              </div>\n            </div>\n          </div>\n          <div class=\"sign-up_footer text-center border-top pt-3\">\n            <a :href=\"CANDIDATE_SIGN_UP_PATH\" class=\"text-decoration-none color-blue-primary mt-md-a4\">\n              莨壼藤逋サ骭イ縺後♀貂医∩縺ァ縺ェ縺�婿縺ッ縺薙■繧噂n              <img alt=\"\" class=\"me-2\" src=\"@/assets/images/icons/arrow-right-blue.svg\" />\n            </a>\n          </div>\n        </div>\n      </form>\n    </div>\n  </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { reactive, ref, onMounted, computed } from 'vue';\nimport { useAuthStore } from '@/stores/auth.store';\nimport { login } from \"@/apis/candidate\";\nimport { verifyAccountType } from \"@/types/api/session\";\nimport { CANDIDATE_SIGN_UP_PATH } from \"@/constant/routers/path\";\nimport 'bootstrap/dist/js/bootstrap.min.js';\n\nconst checkTypePassword = ref<Boolean>(false);\nconst authStore = useAuthStore();\nconst checkAccountValid = ref<Boolean>(false);\nconst messageError = ref('');\n\nconst userInformation = reactive<verifyAccountType>({\n  email: \"\",\n  password: \"\",\n  redirect_to: new URLSearchParams(window.location.search).get('redirect_to')\n});\n\nconst redirectToPanel = () => {\n  window.location.href = '/panel/';\n};\n\nconst loggedIn = computed(() => authStore.isAuthenticated);\n\nonMounted(() => {\n  document.querySelectorAll('.modal-backdrop').forEach(backdrop => backdrop.remove());\n  if (loggedIn.value) {\n    redirectToPanel();\n  }\n});\n\nconst submitAccount = async (e: Event) => {\n  e.preventDefault();\n\n  const response = await login(userInformation);\n  if (response.status && response.status === 200) {\n    localStorage.setItem('access_token', response.data?.token);\n\n    if (response.data?.redirect_url) {\n      window.location.href = response.data.redirect_url\n    } else if (document.referrer.includes(window.location.host)) {\n      window.location.href = document.referrer\n    } else {\n      window.location.href = '/'\n    }\n  } else {\n    messageError.value = response.data.field_error[0].message;\n    checkAccountValid.value = true\n  }\n};\n\nconst changeTypePass = () => {\n  checkTypePassword.value = !checkTypePassword.value;\n};\n</script>\n"],"names":["initialState","AuthService","useAuthStore","defineStore","state","user","response","error","checkTypePassword","ref","authStore","checkAccountValid","messageError","userInformation","reactive","redirectToPanel","loggedIn","computed","onMounted","backdrop","submitAccount","e","login","_a","_b","changeTypePass"],"mappings":"mpBASA,MAAMA,EAAuB,CA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