Skip to content

Commit f428ebc

Browse files
committed
display fix completedGames and button condition show more
1 parent b724fcd commit f428ebc

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

services/app/assets/js/widgets/components/Game/CompletedGames.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const CompletedGames = ({ games, loadNextPage = null }) => {
5050
))}
5151
</tbody>
5252
</table>
53-
{ loadNextPage !== null && nextPage < totalPages
53+
{ loadNextPage !== null && nextPage <= totalPages
5454
? (
5555
<button type="button" className="mt-2 btn btn-light" onClick={() => dispatch(loadNextPage(nextPage))}>
5656
Show More

services/app/assets/js/widgets/containers/UserProfile.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ const UserProfile = () => {
122122

123123
const renderCompletedGames = () => (
124124
<div className="row justify-content-center">
125-
<div className="col-11">
126-
<div className="text-left my-5">
125+
<div className="col-12">
126+
<div className="text-left">
127127
{completedGames && completedGames.length > 0 && (
128128
<>
129129
<CompletedGames
@@ -134,7 +134,7 @@ const UserProfile = () => {
134134
)}
135135
{completedGames && completedGames.length === 0 && (
136136
<>
137-
<div className="text-center text-muted">
137+
<div style={{ height: 498 }} className="d-flex align-items-center justify-content-center border text-muted">
138138
No completed games
139139
</div>
140140
</>
@@ -145,7 +145,7 @@ const UserProfile = () => {
145145
);
146146

147147
const statContainers = () => (
148-
<div className="border">
148+
<div>
149149
<nav>
150150
<div className="nav nav-tabs bg-gray" id="nav-tab" role="tablist">
151151
<a
@@ -174,7 +174,7 @@ const UserProfile = () => {
174174
</nav>
175175
<div className="tab-content" id="nav-tabContent">
176176
<div
177-
className="tab-pane fade show active"
177+
className="tab-pane fade border show active"
178178
id="statistics"
179179
role="tabpanel"
180180
aria-labelledby="statistics-tab"

services/app/assets/js/widgets/slices/completedGames.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
22
import axios from 'axios';
3+
import { camelizeKeys } from 'humps';
34

45
export const fetchCompletedGames = createAsyncThunk(
56
'completedGames/fetchCompletedGames',
@@ -8,7 +9,7 @@ export const fetchCompletedGames = createAsyncThunk(
89

910
const response = await axios.get(`/api/v1/user/${userId}/completed_games?page_size=7`);
1011

11-
return response.data;
12+
return camelizeKeys(response.data);
1213
},
1314
);
1415

@@ -19,7 +20,7 @@ export const loadNextPage = createAsyncThunk(
1920

2021
const response = await axios.get(`/api/v1/user/${userId}/completed_games?page_size=7&page=${page}`);
2122

22-
return response.data;
23+
return camelizeKeys(response.data);
2324
},
2425
);
2526

@@ -41,8 +42,8 @@ const completedGames = createSlice({
4142
[fetchCompletedGames.fulfilled]: (state, { payload }) => {
4243
state.status = 'loaded';
4344
state.completedGames = payload.games;
44-
state.totalPages = payload.page_info.total_pages;
45-
state.nextPage = payload.page_info.page_number + 1;
45+
state.totalPages = payload.pageInfo.totalPages;
46+
state.nextPage = payload.pageInfo.pageNumber + 1;
4647
},
4748
[fetchCompletedGames.rejected]: (state, action) => {
4849
state.status = 'rejected';

0 commit comments

Comments
 (0)