add graphql-codegen
This commit is contained in:
parent
4543e6a237
commit
de209ce26a
|
@ -0,0 +1,14 @@
|
|||
overwrite: true
|
||||
schema: ${REACT_APP_API_URI:https://api.tribalwarshelp.com/graphql}
|
||||
generates:
|
||||
src/libs/graphql/types.ts:
|
||||
plugins:
|
||||
- "typescript"
|
||||
- "typescript-operations"
|
||||
config:
|
||||
skipTypename: true
|
||||
namingConvention:
|
||||
enumValues: keep
|
||||
scalars:
|
||||
ID: number
|
||||
Time: Date | string
|
|
@ -45,7 +45,8 @@
|
|||
"start": "react-app-rewired start",
|
||||
"build": "react-app-rewired build",
|
||||
"test": "react-app-rewired test --env=jest-environment-jsdom-sixteen",
|
||||
"eject": "react-scripts eject"
|
||||
"eject": "react-scripts eject",
|
||||
"codegen": "graphql-codegen"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
|
@ -66,6 +67,9 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@graphql-codegen/cli": "^1.21.3",
|
||||
"@graphql-codegen/typescript": "^1.21.1",
|
||||
"@graphql-codegen/typescript-operations": "^1.17.15",
|
||||
"@types/lodash": "^4.14.165",
|
||||
"@types/react-color": "^3.0.4",
|
||||
"@types/react-router-dom": "^5.1.6",
|
||||
|
|
|
@ -26,7 +26,10 @@ export interface Props<T> {
|
|||
orderDirection?: OrderDirection;
|
||||
selection?: boolean;
|
||||
idFieldName?: string;
|
||||
getRowKey?: (row: T, index: number) => string | number | null | undefined;
|
||||
getIDFieldName?: (
|
||||
row: T,
|
||||
index: number
|
||||
) => string | number | null | undefined;
|
||||
onRequestSort?: (
|
||||
orderBy: string,
|
||||
orderDirection: OrderDirection
|
||||
|
@ -58,7 +61,7 @@ function Table<T extends object>({
|
|||
size,
|
||||
selected,
|
||||
onSelect,
|
||||
getRowKey,
|
||||
getIDFieldName,
|
||||
}: Props<T>) {
|
||||
const { t } = useTranslation(TABLE);
|
||||
const preparedFooterProps = {
|
||||
|
@ -119,8 +122,8 @@ function Table<T extends object>({
|
|||
return (
|
||||
<TableRow
|
||||
key={
|
||||
getRowKey
|
||||
? getRowKey(item, index)
|
||||
getIDFieldName
|
||||
? getIDFieldName(item, index)
|
||||
: isObjKey(item, idFieldName)
|
||||
? item[idFieldName] + ''
|
||||
: index
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Version = {
|
||||
code: string;
|
||||
host: string;
|
||||
};
|
||||
|
||||
export type VersionList = {
|
||||
versions?: List<Version[]>;
|
||||
};
|
|
@ -1,7 +1,11 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { VERSIONS } from './queries';
|
||||
import { VersionsQueryVariables } from 'libs/graphql/types';
|
||||
import { VersionList, Version } from './types';
|
||||
import {
|
||||
QueryVersionsArgs,
|
||||
VersionCode,
|
||||
Query,
|
||||
Version,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
versions: Version[];
|
||||
|
@ -9,18 +13,18 @@ export type QueryResult = {
|
|||
};
|
||||
|
||||
const useVersions = (versionCode: string): QueryResult => {
|
||||
const { data, loading } = useQuery<VersionList, VersionsQueryVariables>(
|
||||
VERSIONS,
|
||||
{
|
||||
fetchPolicy: 'cache-first',
|
||||
variables: {
|
||||
sort: ['host ASC'],
|
||||
filter: {
|
||||
codeNEQ: [versionCode],
|
||||
},
|
||||
const { data, loading } = useQuery<
|
||||
Pick<Query, 'versions'>,
|
||||
QueryVersionsArgs
|
||||
>(VERSIONS, {
|
||||
fetchPolicy: 'cache-first',
|
||||
variables: {
|
||||
sort: ['host ASC'],
|
||||
filter: {
|
||||
codeNEQ: [versionCode as VersionCode],
|
||||
},
|
||||
}
|
||||
);
|
||||
},
|
||||
});
|
||||
return {
|
||||
versions: data?.versions?.items ?? [],
|
||||
loading,
|
||||
|
|
|
@ -2,7 +2,6 @@ import React, { useRef, useState } from 'react';
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import * as ROUTES from 'config/routes';
|
||||
import * as NAMESPACES from 'config/namespaces';
|
||||
import { SERVER_STATUS } from 'config/app';
|
||||
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
|
@ -21,7 +20,7 @@ import {
|
|||
import Link from 'common/Link/Link';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Server } from './types';
|
||||
import { Server, ServerStatus } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server?: Server;
|
||||
|
@ -91,7 +90,7 @@ function GridItem({ t, server, hideTooltip = true }: Props) {
|
|||
params={{ key: server.key }}
|
||||
>
|
||||
{server.key}{' '}
|
||||
{SERVER_STATUS.CLOSED === server.status
|
||||
{ServerStatus.CLOSED === server.status
|
||||
? `(${t(
|
||||
NAMESPACES.COMMON + `:serverStatus.${server.status}`
|
||||
).toLowerCase()})`
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
import { ServerStatus } from 'config/app';
|
||||
|
||||
export type Server = {
|
||||
key: string;
|
||||
status: ServerStatus;
|
||||
numberOfPlayers: number;
|
||||
numberOfTribes: number;
|
||||
numberOfVillages: number;
|
||||
};
|
||||
|
||||
export type ServerList = {
|
||||
servers?: List<Server[]>;
|
||||
};
|
|
@ -1,6 +1,10 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { ServersQueryVariables } from 'libs/graphql/types';
|
||||
import { ServerList, Server } from './types';
|
||||
import {
|
||||
QueryServersArgs,
|
||||
VersionCode,
|
||||
Server,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
import { SERVERS } from './queries';
|
||||
import extractVersionCodeFromHostname from 'utils/extractVersionCodeFromHostname';
|
||||
|
||||
|
@ -12,8 +16,8 @@ export type QueryResult = {
|
|||
|
||||
const useServers = (page: number, perPage: number): QueryResult => {
|
||||
const { data, loading: loadingServers } = useQuery<
|
||||
ServerList,
|
||||
ServersQueryVariables
|
||||
Pick<Query, 'servers'>,
|
||||
QueryServersArgs
|
||||
>(SERVERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -21,7 +25,11 @@ const useServers = (page: number, perPage: number): QueryResult => {
|
|||
offset: (page - 1) * perPage,
|
||||
limit: perPage,
|
||||
filter: {
|
||||
versionCode: [extractVersionCodeFromHostname(window.location.hostname)],
|
||||
versionCode: [
|
||||
extractVersionCodeFromHostname(
|
||||
window.location.hostname
|
||||
) as VersionCode,
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -11,7 +11,7 @@ import useTitle from 'libs/useTitle';
|
|||
import useScrollToElement from 'libs/useScrollToElement';
|
||||
import { validateRowsPerPage } from 'common/Table/helpers';
|
||||
import { SEARCH_PAGE } from 'config/namespaces';
|
||||
import { MODE, LIMIT } from './constants';
|
||||
import { LIMIT, Mode } from './constants';
|
||||
|
||||
import { Container, Paper } from '@material-ui/core';
|
||||
import ModeSelector from 'common/ModeSelector/ModeSelector';
|
||||
|
@ -22,7 +22,7 @@ import ServerTable from './components/ServerTable/ServerTable';
|
|||
function SearchPage() {
|
||||
const [query, setQuery] = useQueryParams({
|
||||
q: withDefault(StringParam, ''),
|
||||
mode: withDefault(StringParam, MODE.PLAYER),
|
||||
mode: withDefault(StringParam, Mode.Player),
|
||||
page: withDefault(NumberParam, 0),
|
||||
limit: withDefault(NumberParam, LIMIT),
|
||||
});
|
||||
|
@ -56,9 +56,9 @@ function SearchPage() {
|
|||
};
|
||||
|
||||
switch (query.mode.toLowerCase()) {
|
||||
case MODE.TRIBE:
|
||||
case Mode.Tribe:
|
||||
return <TribeTable {...tableProps} />;
|
||||
case MODE.SERVER:
|
||||
case Mode.Server:
|
||||
return <ServerTable {...tableProps} />;
|
||||
default:
|
||||
return <PlayerTable {...tableProps} />;
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Props as TableFooterProps } from 'common/Table/TableFooter';
|
|||
import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/PlayerProfileLink';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Player } from './types';
|
||||
import { FoundPlayer } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -36,7 +36,7 @@ function PlayerTable({
|
|||
...column,
|
||||
valueFormatter:
|
||||
index === 1
|
||||
? (player: Player) => (
|
||||
? (player: FoundPlayer) => (
|
||||
<PlayerProfileLink
|
||||
player={player}
|
||||
tribe={
|
||||
|
@ -53,7 +53,7 @@ function PlayerTable({
|
|||
loading={loading}
|
||||
data={players}
|
||||
size="small"
|
||||
getRowKey={(row: Player) => row.server + row.id}
|
||||
getIDFieldName={(row: FoundPlayer) => row.server + row.id}
|
||||
footerProps={{
|
||||
page,
|
||||
rowsPerPage: limit,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { FoundPlayer } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
export const COLUMNS: Column<FoundPlayer>[] = [
|
||||
{
|
||||
field: 'server',
|
||||
label: 'playerTable.columns.server',
|
||||
|
@ -17,20 +17,20 @@ export const COLUMNS: Column<Player>[] = [
|
|||
field: 'bestRank',
|
||||
label: 'playerTable.columns.bestRank',
|
||||
sortable: false,
|
||||
valueFormatter: (player: Player) => player.bestRank,
|
||||
valueFormatter: (player: FoundPlayer) => player.bestRank,
|
||||
},
|
||||
{
|
||||
field: 'mostPoints',
|
||||
label: 'playerTable.columns.mostPoints',
|
||||
sortable: false,
|
||||
valueFormatter: (player: Player) =>
|
||||
valueFormatter: (player: FoundPlayer) =>
|
||||
formatNumber('commas', player.mostPoints),
|
||||
},
|
||||
{
|
||||
field: 'mostVillages',
|
||||
label: 'playerTable.columns.mostVillages',
|
||||
sortable: false,
|
||||
valueFormatter: (player: Player) =>
|
||||
valueFormatter: (player: FoundPlayer) =>
|
||||
formatNumber('commas', player.mostVillages),
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,16 +1,5 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
server: string;
|
||||
id: number;
|
||||
name: string;
|
||||
bestRank: number;
|
||||
mostPoints: number;
|
||||
mostVillages: number;
|
||||
tribeID: number;
|
||||
tribeTag: string;
|
||||
};
|
||||
import { FoundPlayerList } from 'libs/graphql/types';
|
||||
|
||||
export type PlayerList = {
|
||||
foundPlayers?: List<Player[]>;
|
||||
foundPlayers?: FoundPlayerList;
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { SEARCH_PLAYER } from './queries';
|
||||
|
||||
import { SearchPlayerQueryVariables } from 'libs/graphql/types';
|
||||
import { Player, PlayerList } from './types';
|
||||
import { QuerySearchPlayerArgs, FoundPlayer } from 'libs/graphql/types';
|
||||
import { PlayerList } from './types';
|
||||
|
||||
export type QueryResult = {
|
||||
players: Player[];
|
||||
players: FoundPlayer[];
|
||||
loading: boolean;
|
||||
total: number;
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ const usePlayers = (
|
|||
const skip = q.trim() === '';
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
SearchPlayerQueryVariables
|
||||
QuerySearchPlayerArgs
|
||||
>(SEARCH_PLAYER, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -9,7 +9,7 @@ import Link from 'common/Link/Link';
|
|||
import { Props as TableFooterProps } from 'common/Table/TableFooter';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Server } from './types';
|
||||
import { Server } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Server } from './types';
|
||||
import { Server } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Server>[] = [
|
||||
{
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
import { ServerStatus } from 'config/app';
|
||||
|
||||
export type Server = {
|
||||
key: string;
|
||||
status: ServerStatus;
|
||||
numberOfPlayers: number;
|
||||
numberOfTribes: number;
|
||||
numberOfVillages: number;
|
||||
};
|
||||
|
||||
export type ServerList = {
|
||||
servers?: List<Server[]>;
|
||||
};
|
|
@ -1,8 +1,12 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { SERVERS } from './queries';
|
||||
|
||||
import { ServersQueryVariables } from 'libs/graphql/types';
|
||||
import { Server, ServerList } from './types';
|
||||
import {
|
||||
QueryServersArgs,
|
||||
Query,
|
||||
Server,
|
||||
VersionCode,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
servers: Server[];
|
||||
|
@ -18,8 +22,8 @@ const useServers = (
|
|||
): QueryResult => {
|
||||
const skip = q.trim() === '';
|
||||
const { loading: loadingServers, data } = useQuery<
|
||||
ServerList,
|
||||
ServersQueryVariables
|
||||
Pick<Query, 'servers'>,
|
||||
QueryServersArgs
|
||||
>(SERVERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -27,7 +31,7 @@ const useServers = (
|
|||
offset: page * limit,
|
||||
sort: ['status DESC', 'key ASC'],
|
||||
filter: {
|
||||
versionCode: [version],
|
||||
versionCode: [version as VersionCode],
|
||||
keyIEQ: '%' + q + '%',
|
||||
},
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@ import Link from 'common/Link/Link';
|
|||
import { Props as TableFooterProps } from 'common/Table/TableFooter';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Tribe } from './types';
|
||||
import { FoundTribe } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -37,7 +37,7 @@ function TribeTable({
|
|||
...column,
|
||||
valueFormatter:
|
||||
index === 1
|
||||
? (tribe: Tribe) => (
|
||||
? (tribe: FoundTribe) => (
|
||||
<Link
|
||||
to={ROUTES.SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
params={{ key: tribe.server, id: tribe.id }}
|
||||
|
@ -51,7 +51,7 @@ function TribeTable({
|
|||
loading={loading}
|
||||
data={tribes}
|
||||
size="small"
|
||||
getRowKey={(row: Tribe) => row.server + row.id}
|
||||
getIDFieldName={(row: FoundTribe) => row.server + row.id}
|
||||
footerProps={{
|
||||
page,
|
||||
rowsPerPage: limit,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { FoundTribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
export const COLUMNS: Column<FoundTribe>[] = [
|
||||
{
|
||||
field: 'server',
|
||||
label: 'tribeTable.columns.server',
|
||||
|
@ -17,19 +17,20 @@ export const COLUMNS: Column<Tribe>[] = [
|
|||
field: 'bestRank',
|
||||
label: 'tribeTable.columns.bestRank',
|
||||
sortable: false,
|
||||
valueFormatter: (tribe: Tribe) => tribe.bestRank,
|
||||
valueFormatter: (tribe: FoundTribe) => tribe.bestRank,
|
||||
},
|
||||
{
|
||||
field: 'mostPoints',
|
||||
label: 'tribeTable.columns.mostPoints',
|
||||
sortable: false,
|
||||
valueFormatter: (tribe: Tribe) => formatNumber('commas', tribe.mostPoints),
|
||||
valueFormatter: (tribe: FoundTribe) =>
|
||||
formatNumber('commas', tribe.mostPoints),
|
||||
},
|
||||
{
|
||||
field: 'mostVillages',
|
||||
label: 'tribeTable.columns.mostVillages',
|
||||
sortable: false,
|
||||
valueFormatter: (tribe: Tribe) =>
|
||||
valueFormatter: (tribe: FoundTribe) =>
|
||||
formatNumber('commas', tribe.mostVillages),
|
||||
},
|
||||
];
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
server: string;
|
||||
id: number;
|
||||
name: string;
|
||||
tag: string;
|
||||
bestRank: number;
|
||||
mostPoints: number;
|
||||
mostVillages: number;
|
||||
};
|
||||
import { FoundTribeList } from 'libs/graphql/types';
|
||||
|
||||
export type TribeList = {
|
||||
foundTribes?: List<Tribe[]>;
|
||||
foundTribes?: FoundTribeList;
|
||||
};
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { SEARCH_TRIBE } from './queries';
|
||||
|
||||
import { SearchTribeQueryVariables } from 'libs/graphql/types';
|
||||
import { Tribe, TribeList } from './types';
|
||||
import { QuerySearchTribeArgs, FoundTribe } from 'libs/graphql/types';
|
||||
import { TribeList } from './types';
|
||||
|
||||
export type QueryResult = {
|
||||
tribes: Tribe[];
|
||||
tribes: FoundTribe[];
|
||||
loading: boolean;
|
||||
total: number;
|
||||
};
|
||||
|
@ -19,7 +19,7 @@ const useTribes = (
|
|||
const skip = q.trim() === '';
|
||||
const { loading: loadingTribes, data } = useQuery<
|
||||
TribeList,
|
||||
SearchTribeQueryVariables
|
||||
QuerySearchTribeArgs
|
||||
>(SEARCH_TRIBE, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export const MODE = {
|
||||
PLAYER: 'player',
|
||||
TRIBE: 'tribe',
|
||||
SERVER: 'server',
|
||||
};
|
||||
export enum Mode {
|
||||
Player = 'player',
|
||||
Tribe = 'tribe',
|
||||
Server = 'server',
|
||||
}
|
||||
|
||||
export const LIMIT = 25;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import React from 'react';
|
||||
import { SERVER_PAGE } from 'config/routes';
|
||||
import Link from 'common/Link/Link';
|
||||
import { Maybe } from 'libs/graphql/types';
|
||||
|
||||
export interface Tribe {
|
||||
id: number;
|
||||
|
@ -10,13 +11,13 @@ export interface Tribe {
|
|||
export interface Player {
|
||||
id: number;
|
||||
name: string;
|
||||
tribe?: Tribe;
|
||||
tribe?: Maybe<Tribe>;
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
player: Player;
|
||||
server: string;
|
||||
tribe?: Tribe;
|
||||
tribe?: Maybe<Tribe>;
|
||||
}
|
||||
|
||||
function PlayerProfileLink({ player, server, tribe }: Props) {
|
||||
|
|
|
@ -14,8 +14,7 @@ import DateTimePicker from 'common/Picker/DateTimePicker';
|
|||
import Table from '../Table/Table';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { EnnoblementsQueryVariables } from 'libs/graphql/types';
|
||||
import { Ennoblements as EnnoblementsT } from './types';
|
||||
import { QueryEnnoblementsArgs, Query } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -36,8 +35,8 @@ function LatestSavedEnnoblements({ t, server }: Props) {
|
|||
const limit = validateRowsPerPage(query.limit);
|
||||
useScrollToElement(document.documentElement, [query.page, limit]);
|
||||
const { data: queryData, loading: queryLoading } = useQuery<
|
||||
EnnoblementsT,
|
||||
EnnoblementsQueryVariables
|
||||
Pick<Query, 'ennoblements'>,
|
||||
QueryEnnoblementsArgs
|
||||
>(ENNOBLEMENTS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -81,9 +80,9 @@ function LatestSavedEnnoblements({ t, server }: Props) {
|
|||
maxDate={maxDate}
|
||||
minDate={minDate}
|
||||
showTodayButton
|
||||
onChange={d => {
|
||||
onChange={date => {
|
||||
setQuery({
|
||||
[id]: d ? d : undefined,
|
||||
[id]: date ? date : undefined,
|
||||
page: 0,
|
||||
});
|
||||
}}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Ennoblement = {
|
||||
village: {
|
||||
id: number;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
newOwner?: {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
newOwnerTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
oldOwner?: {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
oldOwnerTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
ennobledAt: Date | string;
|
||||
};
|
||||
|
||||
export type Ennoblements = {
|
||||
ennoblements?: List<Ennoblement[]>;
|
||||
};
|
|
@ -49,9 +49,9 @@ function EnnoblementsTable({
|
|||
return (
|
||||
<Link
|
||||
to={SERVER_PAGE.VILLAGE_PAGE.INDEX_PAGE}
|
||||
params={{ key: server, id: e.village.id }}
|
||||
params={{ key: server, id: e.village?.id }}
|
||||
>
|
||||
{buildVillageName(e.village.name, e.village.x, e.village.y)}
|
||||
{buildVillageName(e.village?.name, e.village?.x, e.village?.y)}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
|
@ -102,7 +102,7 @@ function EnnoblementsTable({
|
|||
<MUILink
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href={buildVillageURL(version.host, server, e.village.id)}
|
||||
href={buildVillageURL(version.host, server, e.village?.id ?? 0)}
|
||||
>
|
||||
<IconButton>
|
||||
<Visibility />
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Maybe } from 'libs/graphql/types';
|
||||
|
||||
export interface Tribe {
|
||||
id: number;
|
||||
tag: string;
|
||||
|
@ -6,19 +8,21 @@ export interface Tribe {
|
|||
export interface Player {
|
||||
id: number;
|
||||
name: string;
|
||||
tribe?: Tribe;
|
||||
tribe?: Maybe<Tribe>;
|
||||
}
|
||||
|
||||
export interface Village {
|
||||
id: number;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export interface Ennoblement {
|
||||
village: {
|
||||
id: number;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
newOwner?: Player;
|
||||
newOwnerTribe?: Tribe;
|
||||
oldOwner?: Player;
|
||||
oldOwnerTribe?: Tribe;
|
||||
village?: Maybe<Village>;
|
||||
newOwner?: Maybe<Player>;
|
||||
newOwnerTribe?: Maybe<Tribe>;
|
||||
oldOwner?: Maybe<Player>;
|
||||
oldOwnerTribe?: Maybe<Tribe>;
|
||||
ennobledAt: Date | string;
|
||||
}
|
||||
|
|
|
@ -14,8 +14,8 @@ import ModeSelector from 'common/ModeSelector/ModeSelector';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { PlayersList, Mode, Player } from './types';
|
||||
import { QueryPlayersArgs, Query, Player } from 'libs/graphql/types';
|
||||
import { Mode } from './types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -25,8 +25,8 @@ export interface Props {
|
|||
function ODRankingPlayers({ server, t }: Props) {
|
||||
const [mode, setMode] = useState<Mode>('rankTotal');
|
||||
const { loading: loadingData, data } = useQuery<
|
||||
PlayersList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,24 +1 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
scoreAtt: number;
|
||||
rankAtt: number;
|
||||
scoreDef: number;
|
||||
rankDef: number;
|
||||
scoreSup: number;
|
||||
rankSup: number;
|
||||
scoreTotal: number;
|
||||
rankTotal: number;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type PlayersList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
||||
|
||||
export type Mode = 'rankAtt' | 'rankDef' | 'rankSup' | 'rankTotal';
|
||||
|
|
|
@ -13,8 +13,8 @@ import ModeSelector from 'common/ModeSelector/ModeSelector';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { TribesQueryVariables } from 'libs/graphql/types';
|
||||
import { TribesList, Mode, Tribe } from './types';
|
||||
import { QueryTribesArgs, Query, Tribe } from 'libs/graphql/types';
|
||||
import { Mode } from './types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -24,8 +24,8 @@ export interface Props {
|
|||
function ODRankingTribes({ server, t }: Props) {
|
||||
const [mode, setMode] = useState<Mode>('rankTotal');
|
||||
const { loading: loadingData, data } = useQuery<
|
||||
TribesList,
|
||||
TribesQueryVariables
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>(TRIBES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -41,14 +41,14 @@ function ODRankingTribes({ server, t }: Props) {
|
|||
const items = data?.tribes?.items ?? [];
|
||||
const loading = loadingData && items.length === 0;
|
||||
|
||||
const formatScore = (p: Tribe): string => {
|
||||
const formatScore = (tribe: Tribe): string => {
|
||||
switch (mode) {
|
||||
case 'rankAtt':
|
||||
return formatNumber('commas', p.scoreAtt);
|
||||
return formatNumber('commas', tribe.scoreAtt);
|
||||
case 'rankDef':
|
||||
return formatNumber('commas', p.scoreDef);
|
||||
return formatNumber('commas', tribe.scoreDef);
|
||||
case 'rankTotal':
|
||||
return formatNumber('commas', p.scoreTotal);
|
||||
return formatNumber('commas', tribe.scoreTotal);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
{
|
||||
|
|
|
@ -1,18 +1 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
scoreAtt: number;
|
||||
rankAtt: number;
|
||||
scoreDef: number;
|
||||
rankDef: number;
|
||||
scoreTotal: number;
|
||||
rankTotal: number;
|
||||
};
|
||||
|
||||
export type TribesList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
||||
|
||||
export type Mode = 'rankAtt' | 'rankDef' | 'rankTotal';
|
||||
|
|
|
@ -11,8 +11,7 @@ import TableToolbar from 'common/Table/TableToolbar';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { ServerStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { ServerStats } from './types';
|
||||
import { QueryServerStatsArgs, Query } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -22,8 +21,8 @@ export interface Props {
|
|||
function PlayerStatistics({ server, t }: Props) {
|
||||
const dateUtils = useDateUtils();
|
||||
const { loading: loadingData, data: queryRes } = useQuery<
|
||||
ServerStats,
|
||||
ServerStatsQueryVariables
|
||||
Pick<Query, 'serverStats'>,
|
||||
QueryServerStatsArgs
|
||||
>(STATISTICS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Item = {
|
||||
activePlayers: number;
|
||||
createDate: string | Date;
|
||||
};
|
||||
|
||||
export type ServerStats = {
|
||||
serverStats?: List<Item[]>;
|
||||
};
|
|
@ -11,8 +11,7 @@ import Link from 'common/Link/Link';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { PlayerList, Player } from './types';
|
||||
import { QueryPlayersArgs, Query, Player } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -21,8 +20,8 @@ export interface Props {
|
|||
|
||||
function RecentlyDeletedPlayers({ server, t }: Props) {
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(RECENTLY_DELETED_PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
mostPoints: number;
|
||||
deletedAt: string | Date;
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
|
@ -11,8 +11,7 @@ import Link from 'common/Link/Link';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { TribesQueryVariables } from 'libs/graphql/types';
|
||||
import { TribeList, Tribe } from './types';
|
||||
import { QueryTribesArgs, Query, Tribe } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -21,8 +20,8 @@ export interface Props {
|
|||
|
||||
function RecentlyDeletedTribes({ server, t }: Props) {
|
||||
const { loading: loadingTribes, data } = useQuery<
|
||||
TribeList,
|
||||
TribesQueryVariables
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>(RECENTLY_DELETED_TRIBES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
{
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
name: string;
|
||||
mostPoints: number;
|
||||
deletedAt: string | Date;
|
||||
};
|
||||
|
||||
export type TribeList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
|
@ -16,8 +16,12 @@ import ModeSelector from 'common/ModeSelector/ModeSelector';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { DailyPlayerStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { DailyPlayerStatsList, DailyPlayerStatsRecord, Mode } from './types';
|
||||
import {
|
||||
QueryDailyPlayerStatsArgs,
|
||||
DailyPlayerStatsRecord,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
import { Mode } from './types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -28,8 +32,8 @@ function TodaysBestStatsPlayers({ t }: Props) {
|
|||
const dateUtils = useDateUtils();
|
||||
const [mode, setMode] = useState<Mode>('scoreAtt');
|
||||
const { loading: loadingData, data } = useQuery<
|
||||
DailyPlayerStatsList,
|
||||
DailyPlayerStatsQueryVariables
|
||||
Pick<Query, 'dailyPlayerStats'>,
|
||||
QueryDailyPlayerStatsArgs
|
||||
>(DAILY_PLAYER_STATS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -108,12 +112,15 @@ function TodaysBestStatsPlayers({ t }: Props) {
|
|||
...column,
|
||||
valueFormatter:
|
||||
index === 0
|
||||
? (record: DailyPlayerStatsRecord) => (
|
||||
<PlayerProfileLink
|
||||
player={record.player}
|
||||
server={server.key}
|
||||
/>
|
||||
)
|
||||
? (record: DailyPlayerStatsRecord) =>
|
||||
record.player ? (
|
||||
<PlayerProfileLink
|
||||
player={record.player}
|
||||
server={server.key}
|
||||
/>
|
||||
) : (
|
||||
'-'
|
||||
)
|
||||
: index === 1
|
||||
? (record: DailyPlayerStatsRecord) =>
|
||||
formatNumber('commas', record[mode])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Column } from 'common/Table/types';
|
||||
import { DailyPlayerStatsRecord } from './types';
|
||||
import { DailyPlayerStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<DailyPlayerStatsRecord>[] = [
|
||||
{
|
||||
|
|
|
@ -1,29 +1,3 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type DailyPlayerStatsRecord = {
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreSup: number;
|
||||
scoreTotal: number;
|
||||
points: number;
|
||||
villages: number;
|
||||
createDate: string;
|
||||
player: Player;
|
||||
};
|
||||
|
||||
export type DailyPlayerStatsList = {
|
||||
dailyPlayerStats?: List<DailyPlayerStatsRecord[]>;
|
||||
};
|
||||
|
||||
export type Mode =
|
||||
| 'scoreAtt'
|
||||
| 'scoreDef'
|
||||
|
|
|
@ -15,8 +15,12 @@ import ModeSelector from 'common/ModeSelector/ModeSelector';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { DailyTribeStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { DailyTribeStatsList, DailyTribeStatsRecord, Mode } from './types';
|
||||
import {
|
||||
QueryDailyTribeStatsArgs,
|
||||
DailyTribeStatsRecord,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
import { Mode } from './types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -27,8 +31,8 @@ function TodaysBestStatsTribes({ t }: Props) {
|
|||
const dateUtils = useDateUtils();
|
||||
const [mode, setMode] = useState<Mode>('scoreAtt');
|
||||
const { loading: loadingData, data } = useQuery<
|
||||
DailyTribeStatsList,
|
||||
DailyTribeStatsQueryVariables
|
||||
Pick<Query, 'dailyTribeStats'>,
|
||||
QueryDailyTribeStatsArgs
|
||||
>(DAILY_TRIBE_STATS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -103,14 +107,17 @@ function TodaysBestStatsTribes({ t }: Props) {
|
|||
...column,
|
||||
valueFormatter:
|
||||
index === 0
|
||||
? (record: DailyTribeStatsRecord) => (
|
||||
<Link
|
||||
to={SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
params={{ key: server.key, id: record.tribe.id }}
|
||||
>
|
||||
{record.tribe.tag}
|
||||
</Link>
|
||||
)
|
||||
? (record: DailyTribeStatsRecord) =>
|
||||
record.tribe ? (
|
||||
<Link
|
||||
to={SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
params={{ key: server.key, id: record.tribe.id }}
|
||||
>
|
||||
{record.tribe.tag}
|
||||
</Link>
|
||||
) : (
|
||||
'-'
|
||||
)
|
||||
: index === 1
|
||||
? (record: DailyTribeStatsRecord) =>
|
||||
formatNumber('commas', record[mode])
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Column } from 'common/Table/types';
|
||||
import { DailyTribeStatsRecord } from './types';
|
||||
import { DailyTribeStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<DailyTribeStatsRecord>[] = [
|
||||
{
|
||||
|
|
|
@ -1,25 +1,3 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
export type DailyTribeStatsRecord = {
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreSup: number;
|
||||
scoreTotal: number;
|
||||
points: number;
|
||||
villages: number;
|
||||
createDate: string;
|
||||
tribe: Tribe;
|
||||
};
|
||||
|
||||
export type DailyTribeStatsList = {
|
||||
dailyTribeStats?: List<DailyTribeStatsRecord[]>;
|
||||
};
|
||||
|
||||
export type Mode =
|
||||
| 'scoreAtt'
|
||||
| 'scoreDef'
|
||||
|
|
|
@ -12,8 +12,7 @@ import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/Play
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { PlayerList, Player } from './types';
|
||||
import { QueryPlayersArgs, Player, Query } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -22,8 +21,8 @@ export interface Props {
|
|||
|
||||
function Top5Players({ server, t }: Props) {
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(TOP_5_PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
points: number;
|
||||
rank: number;
|
||||
dailyGrowth: number;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
|
@ -11,8 +11,7 @@ import Link from 'common/Link/Link';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { TribesQueryVariables } from 'libs/graphql/types';
|
||||
import { TribeList, Tribe } from './types';
|
||||
import { QueryTribesArgs, Query, Tribe } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -21,8 +20,8 @@ export interface Props {
|
|||
|
||||
function Top5Tribes({ server, t }: Props) {
|
||||
const { loading: loadingTribes, data } = useQuery<
|
||||
TribeList,
|
||||
TribesQueryVariables
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>(TOP_5_TRIBES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
{
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
points: number;
|
||||
rank: number;
|
||||
dominance: number;
|
||||
};
|
||||
|
||||
export type TribeList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
|
@ -11,8 +11,7 @@ import TableToolbar from 'common/Table/TableToolbar';
|
|||
import Paper from '../Paper/Paper';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { ServerStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { ServerStats } from './types';
|
||||
import { QueryServerStatsArgs, Query } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -22,8 +21,8 @@ export interface Props {
|
|||
function TribeStatistics({ server, t }: Props) {
|
||||
const dateUtils = useDateUtils();
|
||||
const { loading: loadingData, data: queryRes } = useQuery<
|
||||
ServerStats,
|
||||
ServerStatsQueryVariables
|
||||
Pick<Query, 'serverStats'>,
|
||||
QueryServerStatsArgs
|
||||
>(STATISTICS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Item = {
|
||||
activeTribes: number;
|
||||
createDate: string | Date;
|
||||
};
|
||||
|
||||
export type ServerStats = {
|
||||
serverStats?: List<Item[]>;
|
||||
};
|
|
@ -33,10 +33,13 @@ import MarkerField from './components/MarkerField/MarkerField';
|
|||
import Card from './components/Card/Card';
|
||||
|
||||
import {
|
||||
PlayersQueryVariables,
|
||||
TribesQueryVariables,
|
||||
QueryPlayersArgs,
|
||||
QueryTribesArgs,
|
||||
Tribe,
|
||||
Player,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
import { Tribe, Player, PlayerList, TribeList, Settings, HasID } from './types';
|
||||
import { Settings, HasID } from './types';
|
||||
|
||||
function MapPage() {
|
||||
const [mapURL, setMapURL] = useState<string>('');
|
||||
|
@ -64,7 +67,7 @@ function MapPage() {
|
|||
createUpdateMarkerItemHandler: createUpdateTribeMarkerItemHandler,
|
||||
handleAddMarker: handleAddTribeMarker,
|
||||
loading: loadingTribeMarkers,
|
||||
} = useMarkers<Tribe, TribesQueryVariables>(client, {
|
||||
} = useMarkers<Tribe, QueryTribesArgs>(client, {
|
||||
paramName: 'tribe',
|
||||
query: TRIBES,
|
||||
dataKey: 'tribes',
|
||||
|
@ -80,7 +83,7 @@ function MapPage() {
|
|||
createUpdateMarkerItemHandler: createUpdatePlayerMarkerItemHandler,
|
||||
handleAddMarker: handleAddPlayerMarker,
|
||||
loading: loadingPlayerMarkers,
|
||||
} = useMarkers<Player, PlayersQueryVariables>(client, {
|
||||
} = useMarkers<Player, QueryPlayersArgs>(client, {
|
||||
paramName: 'player',
|
||||
query: PLAYERS,
|
||||
dataKey: 'players',
|
||||
|
@ -94,7 +97,7 @@ function MapPage() {
|
|||
useTitle(t('title', { key }));
|
||||
const loading = loadingTribeMarkers || loadingPlayerMarkers;
|
||||
|
||||
const createSettingsChangeHandler = (key: keyof Settings) => (
|
||||
const createChangeSettingsHandler = (key: keyof Settings) => (
|
||||
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>,
|
||||
colorOrChecked?: string | boolean
|
||||
) => {
|
||||
|
@ -109,7 +112,10 @@ function MapPage() {
|
|||
|
||||
const searchPlayers = async (searchValue: string): Promise<Player[]> => {
|
||||
try {
|
||||
const { data } = await client.query<PlayerList, PlayersQueryVariables>({
|
||||
const { data } = await client.query<
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>({
|
||||
query: PLAYERS,
|
||||
variables: {
|
||||
limit: 10,
|
||||
|
@ -132,7 +138,10 @@ function MapPage() {
|
|||
|
||||
const searchTribes = async (searchValue: string): Promise<Tribe[]> => {
|
||||
try {
|
||||
const { data } = await client.query<TribeList, TribesQueryVariables>({
|
||||
const { data } = await client.query<
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>({
|
||||
query: TRIBES,
|
||||
variables: {
|
||||
limit: 10,
|
||||
|
@ -225,7 +234,7 @@ function MapPage() {
|
|||
type="number"
|
||||
name="scale"
|
||||
value={query.scale}
|
||||
onChange={createSettingsChangeHandler('scale')}
|
||||
onChange={createChangeSettingsHandler('scale')}
|
||||
fullWidth
|
||||
variant="standard"
|
||||
inputProps={{
|
||||
|
@ -239,7 +248,7 @@ function MapPage() {
|
|||
type="number"
|
||||
name="centerX"
|
||||
value={query.centerX}
|
||||
onChange={createSettingsChangeHandler('centerX')}
|
||||
onChange={createChangeSettingsHandler('centerX')}
|
||||
fullWidth
|
||||
variant="standard"
|
||||
inputProps={{
|
||||
|
@ -253,7 +262,7 @@ function MapPage() {
|
|||
type="number"
|
||||
name="centerY"
|
||||
value={query.centerY}
|
||||
onChange={createSettingsChangeHandler('centerY')}
|
||||
onChange={createChangeSettingsHandler('centerY')}
|
||||
fullWidth
|
||||
variant="standard"
|
||||
inputProps={{
|
||||
|
@ -266,29 +275,29 @@ function MapPage() {
|
|||
{
|
||||
name: 'backgroundColor',
|
||||
color: query.backgroundColor,
|
||||
onChange: createSettingsChangeHandler('backgroundColor'),
|
||||
onChange: createChangeSettingsHandler('backgroundColor'),
|
||||
},
|
||||
{
|
||||
name: 'playerVillageColor',
|
||||
color: query.playerVillageColor,
|
||||
onChange: createSettingsChangeHandler('playerVillageColor'),
|
||||
onChange: createChangeSettingsHandler('playerVillageColor'),
|
||||
},
|
||||
{
|
||||
name: 'barbarianVillageColor',
|
||||
color: query.barbarianVillageColor,
|
||||
onChange: createSettingsChangeHandler(
|
||||
onChange: createChangeSettingsHandler(
|
||||
'barbarianVillageColor'
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'gridLineColor',
|
||||
color: query.gridLineColor,
|
||||
onChange: createSettingsChangeHandler('gridLineColor'),
|
||||
onChange: createChangeSettingsHandler('gridLineColor'),
|
||||
},
|
||||
{
|
||||
name: 'continentNumberColor',
|
||||
color: query.continentNumberColor,
|
||||
onChange: createSettingsChangeHandler(
|
||||
onChange: createChangeSettingsHandler(
|
||||
'continentNumberColor'
|
||||
),
|
||||
},
|
||||
|
@ -307,27 +316,27 @@ function MapPage() {
|
|||
{
|
||||
name: 'markersOnly',
|
||||
checked: query.markersOnly,
|
||||
onChange: createSettingsChangeHandler('markersOnly'),
|
||||
onChange: createChangeSettingsHandler('markersOnly'),
|
||||
},
|
||||
{
|
||||
name: 'showBarbarian',
|
||||
checked: query.showBarbarian,
|
||||
onChange: createSettingsChangeHandler('showBarbarian'),
|
||||
onChange: createChangeSettingsHandler('showBarbarian'),
|
||||
},
|
||||
{
|
||||
name: 'largerMarkers',
|
||||
checked: query.largerMarkers,
|
||||
onChange: createSettingsChangeHandler('largerMarkers'),
|
||||
onChange: createChangeSettingsHandler('largerMarkers'),
|
||||
},
|
||||
{
|
||||
name: 'showGrid',
|
||||
checked: query.showGrid,
|
||||
onChange: createSettingsChangeHandler('showGrid'),
|
||||
onChange: createChangeSettingsHandler('showGrid'),
|
||||
},
|
||||
{
|
||||
name: 'showContinentNumbers',
|
||||
checked: query.showContinentNumbers,
|
||||
onChange: createSettingsChangeHandler(
|
||||
onChange: createChangeSettingsHandler(
|
||||
'showContinentNumbers'
|
||||
),
|
||||
},
|
||||
|
|
|
@ -23,8 +23,11 @@ function Map({ src = '', alt = 'Map', maxWidth = 1000, t }: Props) {
|
|||
|
||||
return (
|
||||
<div>
|
||||
{isGenerating && <InfoWhileGenerating t={t} />}
|
||||
{!isGenerating && <InfoAfterGenerating t={t} />}
|
||||
{isGenerating ? (
|
||||
<InfoWhileGenerating t={t} />
|
||||
) : (
|
||||
<InfoAfterGenerating t={t} />
|
||||
)}
|
||||
<div
|
||||
className={classes.imageWrapper}
|
||||
style={{ maxWidth: `${maxWidth}px` }}
|
||||
|
|
|
@ -1,30 +1,10 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
export type TribeList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
||||
|
||||
export type Marker<T = undefined> = {
|
||||
id: string;
|
||||
item: T | null;
|
||||
color: string;
|
||||
};
|
||||
|
||||
export type Settings = Object & {
|
||||
export type Settings = {
|
||||
showBarbarian: boolean;
|
||||
largerMarkers: boolean;
|
||||
markersOnly: boolean;
|
||||
|
|
|
@ -5,7 +5,6 @@ import { isNil } from 'lodash';
|
|||
import { isValidColor } from 'libs/serialize-query-params/ColorParam';
|
||||
|
||||
import { ApolloClient, DocumentNode } from '@apollo/client';
|
||||
import { List } from 'libs/graphql/types';
|
||||
import { Marker, HasID } from './types';
|
||||
|
||||
export type MarkerBag<T> = {
|
||||
|
@ -24,6 +23,11 @@ export type MarkerBag<T> = {
|
|||
loading: boolean;
|
||||
};
|
||||
|
||||
type List<T> = {
|
||||
items: T[];
|
||||
total: number;
|
||||
};
|
||||
|
||||
export interface Options<VariablesT> {
|
||||
paramName: string;
|
||||
query: DocumentNode;
|
||||
|
@ -87,7 +91,7 @@ const useMarkers = <T extends HasID, VariablesT>(
|
|||
indexByID: { [key: number]: number }
|
||||
) => {
|
||||
return client
|
||||
.query<Record<string, List<T[]>>, VariablesT>({
|
||||
.query<Record<string, List<T>>, VariablesT>({
|
||||
query: opts.query,
|
||||
variables: opts.getVariables(ids),
|
||||
fetchPolicy: 'network-only',
|
||||
|
@ -97,7 +101,7 @@ const useMarkers = <T extends HasID, VariablesT>(
|
|||
setMarkers(
|
||||
res.data[opts.dataKey].items
|
||||
.map(item => {
|
||||
return getNewMarker(item, colorByID[item.id]);
|
||||
return createMarker(item, colorByID[item.id]);
|
||||
})
|
||||
.sort((a, b) => {
|
||||
if (a.item && b.item) {
|
||||
|
@ -113,7 +117,7 @@ const useMarkers = <T extends HasID, VariablesT>(
|
|||
});
|
||||
};
|
||||
|
||||
const getNewMarker = (
|
||||
const createMarker = (
|
||||
item: T | null = null,
|
||||
color: string = '#000000'
|
||||
): Marker<T> => ({
|
||||
|
@ -131,7 +135,7 @@ const useMarkers = <T extends HasID, VariablesT>(
|
|||
};
|
||||
|
||||
const handleAddMarker = () => {
|
||||
setMarkers([...markers, getNewMarker()]);
|
||||
setMarkers([...markers, createMarker()]);
|
||||
};
|
||||
|
||||
const createDeleteMarkerHandler = (id: string) => () => {
|
||||
|
|
|
@ -15,8 +15,7 @@ import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/Play
|
|||
import Dot from 'features/ServerPage/common/Dot/Dot';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { EnnoblementsQueryVariables } from 'libs/graphql/types';
|
||||
import { Ennoblements as EnnoblementsT, Ennoblement } from './types';
|
||||
import { QueryEnnoblementsArgs, Ennoblement, Query } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -32,8 +31,8 @@ function Ennoblements({ t, server, playerID }: Props) {
|
|||
const limit = validateRowsPerPage(query.limit);
|
||||
useScrollToElement(document.documentElement, [query.page, limit]);
|
||||
const { data: queryData, loading: queryLoading } = useQuery<
|
||||
EnnoblementsT,
|
||||
EnnoblementsQueryVariables
|
||||
Pick<Query, 'ennoblements'>,
|
||||
QueryEnnoblementsArgs
|
||||
>(ENNOBLEMENTS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -89,9 +88,13 @@ function Ennoblements({ t, server, playerID }: Props) {
|
|||
return (
|
||||
<Link
|
||||
to={SERVER_PAGE.VILLAGE_PAGE.INDEX_PAGE}
|
||||
params={{ key: server, id: e.village.id }}
|
||||
params={{ key: server, id: e.village?.id }}
|
||||
>
|
||||
{buildVillageName(e.village.name, e.village.x, e.village.y)}
|
||||
{buildVillageName(
|
||||
e.village?.name,
|
||||
e.village?.x,
|
||||
e.village?.y
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
},
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Ennoblement = {
|
||||
village: {
|
||||
id: number;
|
||||
name: string;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
newOwner?: {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
newOwnerTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
oldOwner?: {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
oldOwnerTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
ennobledAt: Date | string;
|
||||
};
|
||||
|
||||
export type Ennoblements = {
|
||||
ennoblements?: List<Ennoblement[]>;
|
||||
};
|
|
@ -15,10 +15,10 @@ import Link from 'common/Link/Link';
|
|||
|
||||
import { TFunction } from 'i18next';
|
||||
import {
|
||||
PlayerHistory as PlayerHistoryT,
|
||||
PlayerHistoryItem,
|
||||
Variables,
|
||||
} from './types';
|
||||
DailyPlayerStatsRecord,
|
||||
PlayerHistoryRecord,
|
||||
} from 'libs/graphql/types';
|
||||
import { PlayerHistory as PlayerHistoryT, Variables } from './types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -75,7 +75,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
const total = queryData?.playerHistory?.total ?? 0;
|
||||
|
||||
const formatColumn = (
|
||||
v: PlayerHistoryItem,
|
||||
v: PlayerHistoryRecord & { stats?: DailyPlayerStatsRecord },
|
||||
valueKey:
|
||||
| 'points'
|
||||
| 'totalVillages'
|
||||
|
@ -125,7 +125,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
field: 'tribe',
|
||||
label: t('playerHistory.columns.tribe'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return v.tribe ? (
|
||||
<Link
|
||||
to={SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
|
@ -142,7 +142,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
field: 'points',
|
||||
label: t('playerHistory.columns.points'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'points', 'points', 'rank');
|
||||
},
|
||||
},
|
||||
|
@ -150,7 +150,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
field: 'totalVillages',
|
||||
label: t('playerHistory.columns.totalVillages'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'totalVillages', 'villages');
|
||||
},
|
||||
},
|
||||
|
@ -158,14 +158,14 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
field: 'scoreAtt',
|
||||
label: t('playerHistory.columns.scoreAtt'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'scoreAtt', 'scoreAtt', 'rankAtt');
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'scoreDef',
|
||||
label: t('playerHistory.columns.scoreDef'),
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'scoreDef', 'scoreDef', 'rankDef');
|
||||
},
|
||||
sortable: false,
|
||||
|
@ -173,7 +173,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
{
|
||||
field: 'scoreSup',
|
||||
label: t('playerHistory.columns.scoreSup'),
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'scoreSup', 'scoreSup', 'rankSup');
|
||||
},
|
||||
sortable: false,
|
||||
|
@ -181,7 +181,7 @@ function PlayerHistory({ t, server, playerID }: Props) {
|
|||
{
|
||||
field: 'scoreTotal',
|
||||
label: t('playerHistory.columns.scoreTotal'),
|
||||
valueFormatter: (v: PlayerHistoryItem) => {
|
||||
valueFormatter: (v: PlayerHistoryRecord) => {
|
||||
return formatColumn(v, 'scoreTotal', 'scoreTotal', 'rankTotal');
|
||||
},
|
||||
sortable: false,
|
||||
|
|
|
@ -1,43 +1,10 @@
|
|||
import {
|
||||
DailyPlayerStatsFilter,
|
||||
List,
|
||||
PlayerHistoryFilter,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export type DailyPlayerStatsItem = {
|
||||
points: number;
|
||||
villages: number;
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreSup: number;
|
||||
scoreTotal: number;
|
||||
createDate: string | Date;
|
||||
};
|
||||
|
||||
export type PlayerHistoryItem = {
|
||||
rank: number;
|
||||
points: number;
|
||||
totalVillages: number;
|
||||
scoreAtt: number;
|
||||
rankAtt: number;
|
||||
scoreDef: number;
|
||||
rankDef: number;
|
||||
scoreSup: number;
|
||||
rankSup: number;
|
||||
scoreTotal: number;
|
||||
rankTotal: number;
|
||||
createDate: string | Date;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
stats?: DailyPlayerStatsItem;
|
||||
};
|
||||
|
||||
export type PlayerHistory = {
|
||||
playerHistory?: List<PlayerHistoryItem[]>;
|
||||
dailyPlayerStats?: List<DailyPlayerStatsItem[]>;
|
||||
};
|
||||
export type PlayerHistory = Pick<Query, 'dailyPlayerStats' | 'playerHistory'>;
|
||||
|
||||
export type Variables = {
|
||||
server: string;
|
||||
|
|
|
@ -2,13 +2,13 @@ import React from 'react';
|
|||
|
||||
import { Card, CardContent, Typography } from '@material-ui/core';
|
||||
import Table from 'common/Table/Table';
|
||||
import { NameChange } from '../../../../libs/PlayerPageContext/types';
|
||||
import { PlayerNameChange } from 'libs/graphql/types';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
nameChanges: NameChange[];
|
||||
nameChanges: PlayerNameChange[];
|
||||
}
|
||||
|
||||
function NameChanges({ t, nameChanges }: Props) {
|
||||
|
|
|
@ -12,8 +12,8 @@ import ModeSelector from 'common/ModeSelector/ModeSelector';
|
|||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Serie } from '@nivo/line';
|
||||
import { PlayerHistoryQueryVariables } from 'libs/graphql/types';
|
||||
import { Mode, PlayerHistory } from './types';
|
||||
import { QueryPlayerHistoryArgs, Query } from 'libs/graphql/types';
|
||||
import { Mode } from './types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -27,8 +27,8 @@ function Statistics({ t, server, playerID }: Props) {
|
|||
const isMobileDevice = useMediaQuery(theme.breakpoints.down('sm'));
|
||||
const dateUtils = useDateUtils();
|
||||
const { data: queryRes, loading } = useQuery<
|
||||
PlayerHistory,
|
||||
PlayerHistoryQueryVariables
|
||||
Pick<Query, 'playerHistory'>,
|
||||
QueryPlayerHistoryArgs
|
||||
>(PLAYER_HISTORY, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Mode =
|
||||
| 'points'
|
||||
| 'totalVillages'
|
||||
|
@ -7,17 +5,3 @@ export type Mode =
|
|||
| 'scoreDef'
|
||||
| 'scoreSup'
|
||||
| 'scoreTotal';
|
||||
|
||||
export type Item = {
|
||||
points: number;
|
||||
totalVillages: number;
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreSup: number;
|
||||
scoreTotal: number;
|
||||
createDate: string | Date;
|
||||
};
|
||||
|
||||
export type PlayerHistory = {
|
||||
playerHistory?: List<Item[]>;
|
||||
};
|
||||
|
|
|
@ -12,8 +12,11 @@ import Table from 'common/Table/Table';
|
|||
import Link from 'common/Link/Link';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { TribeChangesQueryVariables } from 'libs/graphql/types';
|
||||
import { TribeChangesQuery, TribeChange } from './types';
|
||||
import {
|
||||
QueryTribeChangesArgs,
|
||||
TribeChangeRecord,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
@ -29,8 +32,8 @@ function TribeChanges({ t, server, playerID }: Props) {
|
|||
const limit = validateRowsPerPage(query.limit);
|
||||
useScrollToElement(document.documentElement, [query.page, limit]);
|
||||
const { data: queryData, loading: queryLoading } = useQuery<
|
||||
TribeChangesQuery,
|
||||
TribeChangesQueryVariables
|
||||
Pick<Query, 'tribeChanges'>,
|
||||
QueryTribeChangesArgs
|
||||
>(TRIBE_CHANGES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -61,7 +64,7 @@ function TribeChanges({ t, server, playerID }: Props) {
|
|||
field: 'oldTribe',
|
||||
label: t('tribeChanges.columns.oldTribe'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: TribeChange) => {
|
||||
valueFormatter: (v: TribeChangeRecord) => {
|
||||
return v.oldTribe ? (
|
||||
<Link
|
||||
to={SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
|
@ -78,7 +81,7 @@ function TribeChanges({ t, server, playerID }: Props) {
|
|||
field: 'newTribe',
|
||||
label: t('tribeChanges.columns.newTribe'),
|
||||
sortable: false,
|
||||
valueFormatter: (v: TribeChange) => {
|
||||
valueFormatter: (v: TribeChangeRecord) => {
|
||||
return v.newTribe ? (
|
||||
<Link
|
||||
to={SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type TribeChange = {
|
||||
oldTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
newTribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
createdAt: Date | string;
|
||||
};
|
||||
|
||||
export type TribeChangesQuery = {
|
||||
tribeChanges?: List<TribeChange[]>;
|
||||
};
|
|
@ -6,8 +6,8 @@ import { SERVER_PAGE } from 'config/namespaces';
|
|||
import Context from './context';
|
||||
|
||||
import { PLAYER } from './queries';
|
||||
import { PlayerQueryVariables } from 'libs/graphql/types';
|
||||
import { Params, PlayerQueryResult } from './types';
|
||||
import { QueryPlayerArgs, Query } from 'libs/graphql/types';
|
||||
import { Params } from './types';
|
||||
|
||||
import NotFoundPage from 'features/ServerPage/features/NotFoundPage/NotFoundPage';
|
||||
import Spinner from 'common/Spinner/Spinner';
|
||||
|
@ -19,9 +19,9 @@ export interface Props {
|
|||
function Provider({ children }: Props) {
|
||||
const { key, id } = useParams<Params>();
|
||||
const { t } = useTranslation(SERVER_PAGE.PLAYER_PAGE.COMMON);
|
||||
const { loading: loadingServers, data } = useQuery<
|
||||
PlayerQueryResult,
|
||||
PlayerQueryVariables
|
||||
const { loading: loadingPlayer, data } = useQuery<
|
||||
Pick<Query, 'player'>,
|
||||
QueryPlayerArgs
|
||||
>(PLAYER, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
@ -30,7 +30,7 @@ function Provider({ children }: Props) {
|
|||
},
|
||||
});
|
||||
const player = data?.player ? data.player : undefined;
|
||||
const loading = loadingServers && !player;
|
||||
const loading = loadingPlayer && !player;
|
||||
|
||||
if (loading) {
|
||||
const centerFlex = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { createContext } from 'react';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
const ctx = createContext<Player>({
|
||||
id: 0,
|
||||
|
|
|
@ -1,47 +1,3 @@
|
|||
export type NameChange = {
|
||||
oldName: string;
|
||||
newName: string;
|
||||
changeDate: Date | string;
|
||||
};
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
exists: boolean;
|
||||
rank: number;
|
||||
points: number;
|
||||
totalVillages: number;
|
||||
dailyGrowth: number;
|
||||
scoreAtt: number;
|
||||
rankAtt: number;
|
||||
scoreDef: number;
|
||||
rankDef: number;
|
||||
scoreSup: number;
|
||||
rankSup: number;
|
||||
scoreTotal: number;
|
||||
rankTotal: number;
|
||||
mostPoints: number;
|
||||
mostPointsAt: Date | string;
|
||||
mostVillages: number;
|
||||
mostVillagesAt: Date | string;
|
||||
bestRank: number;
|
||||
bestRankAt: Date | string;
|
||||
joinedAt: Date | string;
|
||||
deletedAt?: Date | string;
|
||||
lastActivityAt: Date | string;
|
||||
servers: string[];
|
||||
nameChanges: NameChange[];
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
name: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type PlayerQueryResult = {
|
||||
player?: Player;
|
||||
};
|
||||
|
||||
export type Params = {
|
||||
key: string;
|
||||
id: string;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { useContext } from 'react';
|
||||
import ctx from './context';
|
||||
import { Player } from './types';
|
||||
|
||||
const usePlayer = (): Player => {
|
||||
const usePlayer = () => {
|
||||
return useContext(ctx);
|
||||
};
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import SearchInput from 'common/Form/SearchInput';
|
|||
import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/PlayerProfileLink';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
mostPoints: number;
|
||||
bestRank: number;
|
||||
mostVillages: number;
|
||||
deletedAt: string | Date;
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { PLAYERS } from './queries';
|
||||
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { Player, PlayerList } from './types';
|
||||
import { QueryPlayersArgs, Player, Query } from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
players: Player[];
|
||||
|
@ -17,8 +16,8 @@ const usePlayers = (
|
|||
q: string
|
||||
): QueryResult => {
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -25,7 +25,7 @@ import DatePicker from 'common/Picker/DatePicker';
|
|||
import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/PlayerProfileLink';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { DailyPlayerStatsRecord } from './types';
|
||||
import { DailyPlayerStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -108,15 +108,20 @@ function Ranking({ t }: Props) {
|
|||
};
|
||||
}
|
||||
if (index === 1) {
|
||||
newCol.valueFormatter = (record: DailyPlayerStatsRecord) => (
|
||||
<PlayerProfileLink player={record.player} server={server.key} />
|
||||
);
|
||||
newCol.valueFormatter = (record: DailyPlayerStatsRecord) =>
|
||||
record.player ? (
|
||||
<PlayerProfileLink player={record.player} server={server.key} />
|
||||
) : (
|
||||
'-'
|
||||
);
|
||||
}
|
||||
return newCol;
|
||||
})}
|
||||
loading={loading}
|
||||
data={dailyStats}
|
||||
getRowKey={(record: DailyPlayerStatsRecord) => record.player.id}
|
||||
getIDFieldName={(record: DailyPlayerStatsRecord, index) =>
|
||||
record.player?.id ?? index
|
||||
}
|
||||
size="small"
|
||||
orderBy={query.sort.orderBy}
|
||||
orderDirection={query.sort.orderDirection}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { decodeSort } from 'libs/serialize-query-params/SortParam';
|
||||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { DailyPlayerStatsRecord } from './types';
|
||||
import { DailyPlayerStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<DailyPlayerStatsRecord>[] = [
|
||||
{
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type DailyPlayerStatsRecord = {
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreSup: number;
|
||||
scoreTotal: number;
|
||||
points: number;
|
||||
villages: number;
|
||||
createDate: string;
|
||||
player: Player;
|
||||
};
|
||||
|
||||
export type DailyStats = {
|
||||
dailyPlayerStats?: List<DailyPlayerStatsRecord[]>;
|
||||
};
|
|
@ -1,8 +1,11 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { DAILY_PLAYER_STATS } from './queries';
|
||||
|
||||
import { DailyPlayerStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { DailyPlayerStatsRecord, DailyStats } from './types';
|
||||
import {
|
||||
QueryDailyPlayerStatsArgs,
|
||||
DailyPlayerStatsRecord,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
dailyStats: DailyPlayerStatsRecord[];
|
||||
|
@ -19,8 +22,8 @@ const usePlayers = (
|
|||
createDate: Date | string
|
||||
): QueryResult => {
|
||||
const { loading: loadingStats, data } = useQuery<
|
||||
DailyStats,
|
||||
DailyPlayerStatsQueryVariables
|
||||
Pick<Query, 'dailyPlayerStats'>,
|
||||
QueryDailyPlayerStatsArgs
|
||||
>(DAILY_PLAYER_STATS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -19,7 +19,7 @@ import SearchInput from 'common/Form/SearchInput';
|
|||
import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/PlayerProfileLink';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
points: number;
|
||||
rank: number;
|
||||
dailyGrowth: number;
|
||||
totalVillages: number;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { PLAYERS } from './queries';
|
||||
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { Player, PlayerList } from './types';
|
||||
import { QueryPlayersArgs, Player, Query } from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
players: Player[];
|
||||
|
@ -17,8 +16,8 @@ const usePlayers = (
|
|||
q: string
|
||||
): QueryResult => {
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -20,7 +20,7 @@ import SearchInput from 'common/Form/SearchInput';
|
|||
import PlayerProfileLink from 'features/ServerPage/common/PlayerProfileLink/PlayerProfileLink';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { decodeSort } from 'libs/serialize-query-params/SortParam';
|
||||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Player } from './types';
|
||||
import { Player } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Player>[] = [
|
||||
{
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Player = {
|
||||
id: number;
|
||||
name: string;
|
||||
scoreAtt: number;
|
||||
rankAtt: number;
|
||||
scoreDef: number;
|
||||
rankDef: number;
|
||||
scoreSup: number;
|
||||
rankSup: number;
|
||||
scoreTotal: number;
|
||||
rankTotal: number;
|
||||
tribe?: {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
};
|
||||
|
||||
export type PlayerList = {
|
||||
players?: List<Player[]>;
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { PLAYERS } from './queries';
|
||||
|
||||
import { PlayersQueryVariables } from 'libs/graphql/types';
|
||||
import { Player, PlayerList } from './types';
|
||||
import { QueryPlayersArgs, Player, Query } from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
players: Player[];
|
||||
|
@ -18,8 +17,8 @@ const usePlayers = (
|
|||
sort: string
|
||||
): QueryResult => {
|
||||
const { loading: loadingPlayers, data } = useQuery<
|
||||
PlayerList,
|
||||
PlayersQueryVariables
|
||||
Pick<Query, 'players'>,
|
||||
QueryPlayersArgs
|
||||
>(PLAYERS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -20,7 +20,7 @@ import SearchInput from 'common/Form/SearchInput';
|
|||
import Link from 'common/Link/Link';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
{
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
mostPoints: number;
|
||||
bestRank: number;
|
||||
mostVillages: number;
|
||||
deletedAt: string | Date;
|
||||
};
|
||||
|
||||
export type TribeList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { TRIBES } from './queries';
|
||||
|
||||
import { TribesQueryVariables } from 'libs/graphql/types';
|
||||
import { Tribe, TribeList } from './types';
|
||||
import { QueryTribesArgs, Tribe, Query } from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
tribes: Tribe[];
|
||||
|
@ -17,8 +16,8 @@ const useTribes = (
|
|||
q: string
|
||||
): QueryResult => {
|
||||
const { loading: loadingTribes, data } = useQuery<
|
||||
TribeList,
|
||||
TribesQueryVariables
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>(TRIBES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -26,7 +26,7 @@ import DatePicker from 'common/Picker/DatePicker';
|
|||
import Link from 'common/Link/Link';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { DailyTribeStatsRecord } from './types';
|
||||
import { DailyTribeStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
t: TFunction;
|
||||
|
@ -112,9 +112,9 @@ function Ranking({ t }: Props) {
|
|||
newCol.valueFormatter = (record: DailyTribeStatsRecord) => (
|
||||
<Link
|
||||
to={ROUTES.SERVER_PAGE.TRIBE_PAGE.INDEX_PAGE}
|
||||
params={{ id: record.tribe.id, key: server.key }}
|
||||
params={{ id: record.tribe?.id, key: server.key }}
|
||||
>
|
||||
{record.tribe.tag}
|
||||
{record.tribe?.tag ?? '-'}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
@ -122,7 +122,9 @@ function Ranking({ t }: Props) {
|
|||
})}
|
||||
loading={loading}
|
||||
data={dailyStats}
|
||||
getRowKey={(record: DailyTribeStatsRecord) => record.tribe.id}
|
||||
getIDFieldName={(record: DailyTribeStatsRecord, index) =>
|
||||
record.tribe?.id ?? index
|
||||
}
|
||||
size="small"
|
||||
orderBy={query.sort.orderBy}
|
||||
orderDirection={query.sort.orderDirection}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { decodeSort } from 'libs/serialize-query-params/SortParam';
|
||||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { DailyTribeStatsRecord } from './types';
|
||||
import { DailyTribeStatsRecord } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<DailyTribeStatsRecord>[] = [
|
||||
{
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
};
|
||||
|
||||
export type DailyTribeStatsRecord = {
|
||||
scoreAtt: number;
|
||||
scoreDef: number;
|
||||
scoreTotal: number;
|
||||
points: number;
|
||||
villages: number;
|
||||
createDate: string;
|
||||
tribe: Tribe;
|
||||
};
|
||||
|
||||
export type DailyStats = {
|
||||
dailyTribeStats?: List<DailyTribeStatsRecord[]>;
|
||||
};
|
|
@ -1,8 +1,11 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { DAILY_TRIBE_STATS } from './queries';
|
||||
|
||||
import { DailyTribeStatsQueryVariables } from 'libs/graphql/types';
|
||||
import { DailyTribeStatsRecord, DailyStats } from './types';
|
||||
import {
|
||||
QueryDailyTribeStatsArgs,
|
||||
DailyTribeStatsRecord,
|
||||
Query,
|
||||
} from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
dailyStats: DailyTribeStatsRecord[];
|
||||
|
@ -19,8 +22,8 @@ const useTribes = (
|
|||
createDate: Date | string
|
||||
): QueryResult => {
|
||||
const { loading: loadingStats, data } = useQuery<
|
||||
DailyStats,
|
||||
DailyTribeStatsQueryVariables
|
||||
Pick<Query, 'dailyTribeStats'>,
|
||||
QueryDailyTribeStatsArgs
|
||||
>(DAILY_TRIBE_STATS, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
|
@ -20,7 +20,7 @@ import SearchInput from 'common/Form/SearchInput';
|
|||
import Link from 'common/Link/Link';
|
||||
|
||||
import { TFunction } from 'i18next';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export interface Props {
|
||||
server: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import formatNumber from 'utils/formatNumber';
|
||||
import { Column } from 'common/Table/types';
|
||||
import { Tribe } from './types';
|
||||
import { Tribe } from 'libs/graphql/types';
|
||||
|
||||
export const COLUMNS: Column<Tribe>[] = [
|
||||
{
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import { List } from 'libs/graphql/types';
|
||||
|
||||
export type Tribe = {
|
||||
id: number;
|
||||
tag: string;
|
||||
points: number;
|
||||
rank: number;
|
||||
dominance: number;
|
||||
totalVillages: number;
|
||||
};
|
||||
|
||||
export type TribeList = {
|
||||
tribes?: List<Tribe[]>;
|
||||
};
|
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from '@apollo/client';
|
||||
import { TRIBES } from './queries';
|
||||
|
||||
import { TribesQueryVariables } from 'libs/graphql/types';
|
||||
import { Tribe, TribeList } from './types';
|
||||
import { QueryTribesArgs, Query, Tribe } from 'libs/graphql/types';
|
||||
|
||||
export type QueryResult = {
|
||||
tribes: Tribe[];
|
||||
|
@ -17,8 +16,8 @@ const useTribes = (
|
|||
q: string
|
||||
): QueryResult => {
|
||||
const { loading: loadingTribes, data } = useQuery<
|
||||
TribeList,
|
||||
TribesQueryVariables
|
||||
Pick<Query, 'tribes'>,
|
||||
QueryTribesArgs
|
||||
>(TRIBES, {
|
||||
fetchPolicy: 'cache-and-network',
|
||||
variables: {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue