added api util functions
This commit is contained in:
@@ -122,7 +122,8 @@ import {
|
||||
FormatFullDate,
|
||||
GetAvgRank,
|
||||
GoToLink,
|
||||
LoadImage
|
||||
LoadImage,
|
||||
getMatchDetails
|
||||
} from "../utils";
|
||||
import {useStore} from "vuex";
|
||||
import {useRoute} from 'vue-router'
|
||||
@@ -146,36 +147,31 @@ export default {
|
||||
})
|
||||
|
||||
// Functions
|
||||
const GetMatch = () => {
|
||||
if (matchIdPattern.test(props.match_id))
|
||||
axios
|
||||
.get(`${process.env.VUE_APP_API_URL}/match/${props.match_id}`)
|
||||
.then((response) => {
|
||||
if (response.data.map)
|
||||
document.title = `${FixMapName(response.data.map)} | csgoWTF`
|
||||
else
|
||||
document.title = `Match-Details | csgoWTF`
|
||||
const GetMatch = async () => {
|
||||
let res = {}
|
||||
if (matchIdPattern.test(props.match_id)) {
|
||||
res = await getMatchDetails(props.match_id)
|
||||
|
||||
store.commit({
|
||||
type: 'changeMatchDetails',
|
||||
data: response.data
|
||||
})
|
||||
if (res.map)
|
||||
document.title = `${FixMapName(res.map)} | csgoWTF`
|
||||
else
|
||||
document.title = `Match-Details | csgoWTF`
|
||||
|
||||
data.matchDetails = store.state.matchDetails
|
||||
data.stats = data.matchDetails.stats
|
||||
data.score = data.matchDetails.score
|
||||
store.commit({
|
||||
type: 'changeMatchDetails',
|
||||
data: res
|
||||
})
|
||||
|
||||
LoadImage(data.matchDetails.map ? data.matchDetails.map : 'random')
|
||||
data.matchDetails = store.state.matchDetails
|
||||
data.stats = data.matchDetails.stats
|
||||
data.score = data.matchDetails.score
|
||||
|
||||
data.avgRank = GetAvgRank(data.stats)
|
||||
LoadImage(data.matchDetails.map ? data.matchDetails.map : 'random')
|
||||
|
||||
console.log(data.matchDetails)
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
// TODO: needs 404
|
||||
})
|
||||
else {
|
||||
data.avgRank = GetAvgRank(data.stats)
|
||||
|
||||
console.log(data.matchDetails)
|
||||
} else {
|
||||
console.log('Match not found')
|
||||
// TODO: needs 404
|
||||
}
|
||||
|
Reference in New Issue
Block a user