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

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

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

/**
 * @returns {Promise<{data : UserGetMe,success : boolean}>}
 */
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<{success: boolean, msg: string, username: string}>}
 */
export const registerUser = async (email, username, password, fullname, phoneNumber, trialRequest) => {
  return apiPublic.post('/register', {
    email,
    username,
    password,
    fullname,
    phoneNumber,
    trialRequest,
  });
};
