import subDays from 'date-fns/subDays'; import getTranslations from '../i18n/showHistoryPopup'; import showPopup from '../utils/showPopup'; import { generatePaginationItems, getContainerStyles, } from '../utils/pagination'; import { formatDate } from '../utils/date'; import * as twutils from '../utils/tribalwars'; const PAGINATION_CONTAINER_ID = 'historyPagination'; const translations = getTranslations(); const addMathSymbol = v => { return v > 0 ? '+' + v : v; }; export default ( e, history, daily, { currentPage = 1, limit = 0, onPageChange = () => {}, tribe = false } = {} ) => { const paginationItems = generatePaginationItems({ total: history.total, limit, currentPage, }); const html = `
${translations.date} | ${tribe ? '' : `${translations.tribe} | `}${translations.points} | ${translations.villages} | ${tribe ? `${translations.members} | ` : ''}${translations.od} | ${translations.oda} | ${translations.odd} | ${tribe ? '' : `${translations.ods} | `}|
---|---|---|---|---|---|---|---|---|---|
${formatDate(history.createDate, { year: 'numeric', month: '2-digit', day: '2-digit', })} | `; if (!tribe && history.tribe) { rowHTML += `${history.tribe.tag} | `; } else if (!tribe) { rowHTML += '- | '; } rowHTML += `${history.points.toLocaleString()} (${ history.rank }) | ${history.totalVillages.toLocaleString()} | ${ !tribe ? '' : `${history.totalMembers} | ` }${history.scoreTotal.toLocaleString()} (${ history.rankTotal }) | ${history.scoreAtt.toLocaleString()} (${ history.rankAtt }) | ${history.scoreDef.toLocaleString()} (${ history.rankDef }) | ${ tribe ? '' : `${history.scoreSup.toLocaleString()} (${ history.rankSup }) | ` } ` + '