swap to ultra-fast APIs on homepage, finish continents
This commit is contained in:
parent
644e25f673
commit
9b439d0a19
14 changed files with 365 additions and 114 deletions
1
app/utils/classes.ts
Normal file
1
app/utils/classes.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export const c = (...args: any[]) => args.filter((x) => !!x).join(" ");
|
31
app/utils/metagame.ts
Normal file
31
app/utils/metagame.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
export type MetagameWorld = {
|
||||
id: number;
|
||||
zones: {
|
||||
id: number;
|
||||
locked: boolean;
|
||||
alert?: {
|
||||
id: number;
|
||||
zone: number;
|
||||
start_time: string;
|
||||
end_time: string;
|
||||
ps2alerts: string;
|
||||
alert_type: string;
|
||||
percentages: {
|
||||
nc: number;
|
||||
tr: number;
|
||||
vs: number;
|
||||
};
|
||||
};
|
||||
territory: {
|
||||
nc: number;
|
||||
tr: number;
|
||||
vs: number;
|
||||
};
|
||||
}[];
|
||||
};
|
||||
|
||||
export const fetchMetagameWorlds = async (): Promise<MetagameWorld[]> => {
|
||||
const response = await fetch("https://metagame.ps2.live/all");
|
||||
const data: MetagameWorld[] = await response.json();
|
||||
return data;
|
||||
};
|
15
app/utils/population.ts
Normal file
15
app/utils/population.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
export type PopulationWorld = {
|
||||
id: number;
|
||||
average: number;
|
||||
factions: {
|
||||
nc: number;
|
||||
tr: number;
|
||||
vs: number;
|
||||
};
|
||||
};
|
||||
|
||||
export const fetchPopulationWorlds = async (): Promise<PopulationWorld[]> => {
|
||||
const response = await fetch("https://agg.ps2.live/population/all");
|
||||
const data: PopulationWorld[] = await response.json();
|
||||
return data.map(({ id, average, factions }) => ({ id, average, factions }));
|
||||
};
|
|
@ -12,7 +12,7 @@ export const saerroFetch = async <T>(query: string): Promise<T> => {
|
|||
};
|
||||
|
||||
export type Population = {
|
||||
total: number;
|
||||
total?: number;
|
||||
nc: number;
|
||||
tr: number;
|
||||
vs: number;
|
||||
|
@ -22,10 +22,10 @@ export type Zone = {
|
|||
id: string;
|
||||
name: string;
|
||||
population: Population;
|
||||
vehicles?: Record<(typeof allVehicles)[number], Population> & {
|
||||
vehicles?: Record<typeof allVehicles[number], Population> & {
|
||||
total: number;
|
||||
};
|
||||
classes?: Record<(typeof allClasses)[number], Population>;
|
||||
classes?: Record<typeof allClasses[number], Population>;
|
||||
};
|
||||
|
||||
export type World = {
|
||||
|
|
|
@ -8,14 +8,18 @@ export const pascalCaseToTitleCase = (str: string) => {
|
|||
return toTitleCase(str.replace(/([A-Z])/g, " $1"));
|
||||
};
|
||||
|
||||
export const humanTimeAgo = (ms: number) => {
|
||||
export const snakeCaseToTitleCase = (str: string) => {
|
||||
return toTitleCase(str.replace(/_/g, " "));
|
||||
};
|
||||
|
||||
export const humanTimeAgo = (ms: number, full?: boolean) => {
|
||||
const millis = Math.floor(ms % 1000);
|
||||
const seconds = Math.floor(ms / 1000);
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const hours = Math.floor(minutes / 60);
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}h`;
|
||||
return full ? `${hours}h ${minutes % 60}m` : `${hours}h`;
|
||||
}
|
||||
|
||||
if (minutes > 0) {
|
||||
|
@ -28,3 +32,106 @@ export const humanTimeAgo = (ms: number) => {
|
|||
|
||||
return `${millis}ms`;
|
||||
};
|
||||
|
||||
export const worlds: Record<
|
||||
string,
|
||||
{
|
||||
timeZone: string;
|
||||
locale: string;
|
||||
location: string;
|
||||
platform: string;
|
||||
name: string;
|
||||
}
|
||||
> = {
|
||||
"1": {
|
||||
name: "Connery",
|
||||
timeZone: "America/Los_Angeles",
|
||||
locale: "en-US",
|
||||
location: "US-W",
|
||||
platform: "PC",
|
||||
},
|
||||
"10": {
|
||||
name: "Miller",
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PC",
|
||||
},
|
||||
"13": {
|
||||
name: "Cobalt",
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PC",
|
||||
},
|
||||
"17": {
|
||||
name: "Emerald",
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PC",
|
||||
},
|
||||
"19": {
|
||||
name: "Jaeger",
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PC",
|
||||
},
|
||||
"40": {
|
||||
name: "SolTech",
|
||||
timeZone: "Asia/Tokyo",
|
||||
locale: "en-GB",
|
||||
location: "JP",
|
||||
platform: "PC",
|
||||
},
|
||||
"1000": {
|
||||
name: "Genudine",
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PS4",
|
||||
},
|
||||
"2000": {
|
||||
name: "Ceres",
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PS4",
|
||||
},
|
||||
default: {
|
||||
name: "Unknown",
|
||||
timeZone: "UTC",
|
||||
locale: "en-US",
|
||||
location: "???",
|
||||
platform: "???",
|
||||
},
|
||||
};
|
||||
|
||||
export const zones: Record<string, { name: string; colors: [string, string] }> =
|
||||
{
|
||||
"2": {
|
||||
name: "Indar",
|
||||
colors: ["#edb96b", "#964c2f"],
|
||||
},
|
||||
"4": {
|
||||
name: "Hossin",
|
||||
colors: ["#47570d", "#7b9c05"],
|
||||
},
|
||||
"6": {
|
||||
name: "Amerish",
|
||||
colors: ["#87a12a", "#5f634f"],
|
||||
},
|
||||
"8": {
|
||||
name: "Esamir",
|
||||
colors: ["#d5f3f5", "#a1c7e6"],
|
||||
},
|
||||
"344": {
|
||||
name: "Oshur",
|
||||
colors: ["#00c2bf", "#174185"],
|
||||
},
|
||||
default: {
|
||||
name: "Unknown",
|
||||
colors: ["#000000", "#000000"],
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
export const worlds: Record<
|
||||
string,
|
||||
{ timeZone: string; locale: string; location: string; platform: string }
|
||||
> = {
|
||||
"1": {
|
||||
timeZone: "America/Los_Angeles",
|
||||
locale: "en-US",
|
||||
location: "US-W",
|
||||
platform: "PC",
|
||||
},
|
||||
"10": {
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PC",
|
||||
},
|
||||
"13": {
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PC",
|
||||
},
|
||||
"17": {
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PC",
|
||||
},
|
||||
"19": {
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PC",
|
||||
},
|
||||
"40": {
|
||||
timeZone: "Asia/Tokyo",
|
||||
locale: "en-GB",
|
||||
location: "JP",
|
||||
platform: "PC",
|
||||
},
|
||||
"1000": {
|
||||
timeZone: "America/New_York",
|
||||
locale: "en-US",
|
||||
location: "US-E",
|
||||
platform: "PS4",
|
||||
},
|
||||
"2000": {
|
||||
timeZone: "UTC",
|
||||
locale: "en-GB",
|
||||
location: "EU",
|
||||
platform: "PS4",
|
||||
},
|
||||
default: {
|
||||
timeZone: "UTC",
|
||||
locale: "en-US",
|
||||
location: "???",
|
||||
platform: "???",
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue