import { configApp } from '@/config/app';
import { apiApp, apiPublic } from './api';

/**
 * @param {string} username
 * @param {string} password
 * @param {string} profileId
 * @returns {Promise<import('@type/User').UserLogin>}
 */
export const loginUser = async (username, password, profileId) => {
  const payloadLogin = {
    username,
    password,
    profileId,
    version: configApp.verNumber,
  };

  return apiApp.post('/extension/login', payloadLogin);
};

/**
 * @returns {Promise<import('@type/AutoShopee/User').UserGetMeResponse>}
 */
export const getUserInfo = async () => apiApp.get('/extension/user/get/me');

/**
 * @param {string} email
 * @param {string} username
 * @param {string} password
 * @param {string} fullname
 * @param {string} phoneNumber
 * @param {boolean} trialRequest
 * @returns {Promise<import('@type/AutoShopee/User').UserRegisterResult>}
 */
export const registerUser = async (email, username, password, fullname, phoneNumber, trialRequest) => {
  return apiPublic.post('/register', {
    email,
    username,
    password,
    fullname,
    phoneNumber,
    trialRequest,
  });
};
