Add getActivityPage

This commit is contained in:
Max
2019-06-14 18:26:26 -04:00
parent b0874bb7e0
commit 08d6d22fb3
3 changed files with 64 additions and 19 deletions

View File

@@ -1,11 +1,11 @@
import { Gamemode, Category, SkillName } from '../types';
import { Gamemode, SkillName, ActivityName } from '../types';
import {
BASE_URL,
GAMEMODE_URL,
STATS_URL,
SCORES_URL,
SKILLS,
OTHER,
ACTIVITIES,
} from './constants';
export const getStatsURL = (gamemode: Gamemode, rsn: string) =>
@@ -25,6 +25,17 @@ export const getSkillPageURL = (
skill
)}&page=${page}`;
export const getActivityPageURL = (
gamemode: Gamemode,
activity: ActivityName,
page: number
) =>
`${BASE_URL}${
GAMEMODE_URL[gamemode]
}${SCORES_URL}category_type=1&table=${ACTIVITIES.indexOf(
activity
)}&page=${page}`;
export const numberFromElement = (el: CheerioElement) => {
const innerText = el.firstChild.data;
const number = innerText ? innerText.replace(/[\n|,]/g, '') : '-1';