diff --git a/src/store/index.js b/src/store/index.js index 6721540..143c14b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,7 +6,8 @@ export default createStore({ vanityUrl: '', matchDetails: {}, playerDetails: {}, - playersArr: [] + playersArr: [], + scroll_state: 0 }, mutations: { changeId64(state, payload) { @@ -24,6 +25,9 @@ export default createStore({ changePlayesArr(state, payload) { state.playersArr = payload.data }, + changeScrollState(state, payload) { + state.scroll_state = payload + }, resetId64(state) { state.id64 = '' }, @@ -39,6 +43,9 @@ export default createStore({ resetPlayesArr(state) { state.playersArr = [] }, + resetScrollState(state) { + state.scroll_state = 0 + } }, actions: { }, diff --git a/src/utils/ApiRequests.js b/src/utils/ApiRequests.js index 1960bd5..683d61f 100644 --- a/src/utils/ApiRequests.js +++ b/src/utils/ApiRequests.js @@ -129,3 +129,16 @@ export const GetWeaponDmg = async (match_id) => { console.log(e) } } + +export const LoadMoreMatchesExplore = async (date) => { + try { + const res = await axios.get(`${API_URL}/matches/next/${date}`) + + if (res.status === 200) { + return res.data + } + } catch (err) { + // TODO: 400, 404 + console.log(err.response.status, err.response.statusText) + } +} diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 3ec8b21..3633edc 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -93,3 +93,11 @@ export const CreatePlayersArray = (stats) => { } return arr } + +export const scrollToPos = (pos = 0) => { + window.scrollTo({ + top: pos, + left: 0, + behavior: 'smooth' + }) +} diff --git a/src/utils/index.js b/src/utils/index.js index cd5a5dc..904d865 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,20 +1,38 @@ -import {FormatDate, FormatDuration, FormatFullDate, FormatFullDuration, FormatVacDate, MatchNotParsedTime} from "./DateTime"; +import { + FormatDate, + FormatDuration, + FormatFullDate, + FormatFullDuration, + FormatVacDate, + MatchNotParsedTime +} from "./DateTime"; import {GoToLink, GoToMatch, GoToPlayer} from "./GoTo"; import {SaveLastVisitedToLocalStorage} from "./LocalStorage"; import {GetHLTV_1} from "./HLTV"; import {DisplayRank, LoadImage} from "./Display"; -import {GetMatchDetails, GetPlayerMeta, GetPlayerValue, GetUser, LoadMoreMatches, TrackMe, GetWeaponDmg, GetMatches} from "./ApiRequests"; +import { + GetMatchDetails, + GetMatches, + GetPlayerMeta, + GetPlayerValue, + GetUser, + GetWeaponDmg, + LoadMoreMatches, + LoadMoreMatchesExplore, + TrackMe +} from "./ApiRequests"; import { checkStatEmpty, closeNav, constructAvatarUrl, + CreatePlayersArray, FixMapName, getPlayerArr, GetWinLoss, setTitle, - truncate, sortObjectValue, - CreatePlayersArray + truncate, + scrollToPos } from "./Utils"; export { @@ -48,5 +66,7 @@ export { sortObjectValue, GetWeaponDmg, CreatePlayersArray, - GetMatches + GetMatches, + LoadMoreMatchesExplore, + scrollToPos } diff --git a/src/views/Explore.vue b/src/views/Explore.vue index 246c5ee..e4b92ae 100644 --- a/src/views/Explore.vue +++ b/src/views/Explore.vue @@ -5,13 +5,19 @@

Recent matches

+ +
+ +
@@ -63,6 +78,10 @@ export default { h3 { margin-bottom: 2rem; } + + .load-more { + padding: 1rem 0; + } } @media (max-width: 1200px) { diff --git a/src/views/Player.vue b/src/views/Player.vue index f8f5fd8..0138129 100644 --- a/src/views/Player.vue +++ b/src/views/Player.vue @@ -202,8 +202,8 @@
-
@@ -211,7 +211,7 @@