import { defineStore } from 'pinia'
import { get, omit } from 'lodash-es'
import { AxiosWrapper } from '@/utils/axios-wrapper'
const axios = new AxiosWrapper()
export const LoginStore = defineStore('login', () => {
  const login = async (payload) => {
    const type = get(payload, 'type')
    const np = omit(payload, 'type')
    const res = await axios.$post(`/login/${type}`, np)
    return res
  }
  const rp = async (payload) => {
    const type = get(payload, 'type')
    const np = omit(payload, 'type')
    const res = await axios.$post(`/login/updatePwd/${type}`, np)
    return res
  }
  const rpNoNewPassword = async (payload) => {
    const type = get(payload, 'type')
    const np = omit(payload, 'type')
    const res = await axios.$post(`/login/resetPwd/${type}`, np)
    return res
  }
  return { login, rp, rpNoNewPassword }
})
