Skip to content

Commit

Permalink
Fix date selector and empty data in the stats
Browse files Browse the repository at this point in the history
  • Loading branch information
petrvecera committed Oct 4, 2023
1 parent ba52417 commit faa7bb7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion components/screens/stats/game/inner-game-stats-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const InnerGameStatsPage = ({
);
}

if (data) {
if (data?.analysis["1v1"]) {
const analysis = data.analysis as StatsDataObject;

const matchCount = (() => {
Expand Down Expand Up @@ -234,6 +234,12 @@ const InnerGameStatsPage = ({
</Text>
</>
);
} else {
content = (
<Center maw={400} h={250} mx="auto">
<h3>No data for the selected period</h3>
</Center>
);
}

return <div style={{ minHeight: 1600 }}>{content}</div>;
Expand Down
2 changes: 1 addition & 1 deletion components/screens/stats/stats-container-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const StatsContainerSelector = ({ statsType }: { statsType: "gameStats" | "mapSt
useEffect(() => {
if (!valueDatePicker?.[0] || !valueDatePicker?.[1]) return;

const fromTimeStamp = convertToDateString(valueDatePicker[0]);
const fromTimeStamp = convertToDateString(valueDatePicker[0], false);
// getDateTimestamp(valueDatePicker[0] || new Date() );
const toTimeStamp = convertToDateString(valueDatePicker[1]); // getDateTimestamp(valueDatePicker[1] || new Date());
push({ query: { ...query, from: fromTimeStamp, to: toTimeStamp } }, undefined, {
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export const getGMTTimeStamp = (date = new Date()) => {
);
};

export const convertToDateString = (date = new Date()) => {
export const convertToDateString = (date = new Date(), allowNow = true) => {
const oldDate = dayjs(date);
const today = dayjs(new Date());

// They are the same, it's today
if (oldDate.diff(today, "day") === 0) {
if (oldDate.diff(today, "day") === 0 && allowNow) {
return "now";
} else {
return dayjs(date).format("YYYY-MM-DD");
Expand Down

0 comments on commit faa7bb7

Please sign in to comment.