import axios from 'axios'

// Config
import { baseURL } from '../../../Config'

export const getByGameId = async (gameId: string) => {
  try {
    const { data } = await axios.get(baseURL + '/games/' + gameId)
    return data
  } catch (error) {
    console.error(error)
  }
}

export const getUserById = async (userId: string | null) => {
  try {
    const { data } = await axios.get(baseURL + '/users/' + userId)
    return data
  } catch (error) {
    console.error(error)
  }
}

interface GameUserData {
  intermediateGameLevel: string
  advancedGameLevel: string
}

export const changeGameLevel = async (userId: string | null, userData: GameUserData) => {
  try {
    const { data } = await axios.put(baseURL + '/users/' + userId, userData)
    return data
  } catch (error) {
    console.error(error)
  }
}
