Skip to content

Commit

Permalink
Merge pull request #881 from the-hideout/feature/better_acievements
Browse files Browse the repository at this point in the history
Better acievements
  • Loading branch information
Razzmatazzz authored Mar 14, 2024
2 parents 5dc4a81 + e0acc44 commit 99e6012
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 23 deletions.
2 changes: 2 additions & 0 deletions src/features/achievements/do-fetch-achievements.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class AchievementsQuery extends APIQuery {
description
hidden
playersCompletedPercent
normalizedRarity
rarity
}
}`;

Expand Down
7 changes: 7 additions & 0 deletions src/pages/achievements/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.rare {
color: #8c6edf;
}

.legendary {
color: #ffe084;
}
51 changes: 40 additions & 11 deletions src/pages/achievements/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import DataTable from '../../components/data-table/index.js';

import useAchievementsData from '../../features/achievements/index.js';

import './index.css';

const raritySort = {
"common": 0,
"rare": 1,
"legendary": 2
}

function Achievements() {
const { t } = useTranslation();

Expand All @@ -23,21 +31,17 @@ function Achievements() {
() => [
{
Header: () => (
<div
style={{
textAlign:'left'
}}
>{t('Name')}</div>),
<div style={{textAlign:'left', paddingLeft:'10px'}}>
{t('Name')}
</div>),
id: 'name',
accessor: 'name',
},
{
Header: () => (
<div
style={{
textAlign:'left'
}}
>{t('Description')}</div>),
<div style={{textAlign:'left', paddingLeft:'10px'}}>
{t('Description')}
</div>),
id: 'description',
accessor: 'description',
},
Expand All @@ -51,7 +55,12 @@ function Achievements() {
);
},
sortType: (rowA, rowB) => {
return (+ rowA.values.hidden) - (+ rowB.values.hidden);
let rowAhidden = rowA.original.hidden ? 1 : 0
let rowBhidden = rowB.original.hidden ? 1 : 0
if (rowAhidden === rowBhidden) {
return rowB.original.playersCompletedPercent - rowA.original.playersCompletedPercent
}
return rowAhidden - rowBhidden;
},
},
{
Expand All @@ -66,6 +75,26 @@ function Achievements() {
);
},
},
{
Header: t('Rarity'),
id: 'rarity',
accessor: 'rarity',
Cell: (props) => {
return (
<div className={`center-content ${props.row.original.normalizedRarity}`}>
{props.value}
</div>
);
},
sortType: (rowA, rowB) => {
let rowAr = raritySort[rowA.original.normalizedRarity];
let rowBr = raritySort[rowB.original.normalizedRarity];
if (rowAr === rowBr) {
return rowB.original.playersCompletedPercent - rowA.original.playersCompletedPercent
}
return rowAr - rowBr;
},
}
],
[t],
);
Expand Down
8 changes: 8 additions & 0 deletions src/pages/player/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,11 @@ ul.favorite-item-list li {
display: inline-block;
padding-left: 2px;
}

.rare {
color: #8c6edf;
}

.legendary {
color: #ffe084;
}
42 changes: 32 additions & 10 deletions src/pages/player/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ function getDHMS(seconds) {
}
}

const raritySort = {
"common": 0,
"rare": 1,
"legendary": 2
}

function Player() {
const { t } = useTranslation();
const params = useParams();
Expand Down Expand Up @@ -163,21 +169,17 @@ function Player() {
() => [
{
Header: () => (
<div
style={{
textAlign:'left'
}}
>{t('Name')}</div>),
<div style={{textAlign:'left', paddingLeft:'10px'}}>
{t('Name')}
</div>),
id: 'name',
accessor: 'name',
},
{
Header: () => (
<div
style={{
textAlign:'left'
}}
>{t('Description')}</div>),
<div style={{textAlign:'left', paddingLeft:'10px'}}>
{t('Description')}
</div>),
id: 'description',
accessor: 'description',
},
Expand Down Expand Up @@ -205,6 +207,26 @@ function Player() {
);
},
},
{
Header: t('Rarity'),
id: 'rarity',
accessor: 'rarity',
Cell: (props) => {
return (
<div className={`center-content ${props.row.original.normalizedRarity}`}>
{props.value}
</div>
);
},
sortType: (rowA, rowB) => {
let rowAr = raritySort[rowA.original.normalizedRarity];
let rowBr = raritySort[rowB.original.normalizedRarity];
if (rowAr === rowBr) {
return rowB.original.playersCompletedPercent - rowA.original.playersCompletedPercent
}
return rowAr - rowBr;
},
},
],
[t],
);
Expand Down
8 changes: 6 additions & 2 deletions src/pages/wipe-length/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ const WipeLength = (props) => {
return [
{
Header: t('Patch'),
id: 'name',
accessor: 'name',
},
{
Header: t('Wipe start'),
id: 'start',
accessor: ({ start }) => {
if (start) {
return dayjs(start).format('YYYY-MM-DD');
Expand All @@ -33,10 +35,10 @@ const WipeLength = (props) => {
return '';
},
Cell: CenterCell,
id: 'start',
},
{
Header: t('Wipe end'),
id: 'end',
accessor: ({ end, ongoing }) => {
if (ongoing) {
return t('Ongoing wipe');
Expand All @@ -47,10 +49,10 @@ const WipeLength = (props) => {
return '';
},
Cell: CenterCell,
id: 'end',
},
{
Header: t('Wipe length'),
id: 'wipeLength',
accessor: 'lengthDays',
Cell: (props) => {
const { value } = props;
Expand Down Expand Up @@ -104,6 +106,8 @@ const WipeLength = (props) => {
columns={columns}
data={data}
disableSortBy={false}
sortBy={'start'}
sortByDesc={true}
/>
{}
</div>
Expand Down

0 comments on commit 99e6012

Please sign in to comment.