Skip to content

Commit

Permalink
header bug fix
Browse files Browse the repository at this point in the history
header bug fix
  • Loading branch information
dplamenov committed Mar 21, 2021
1 parent 7d44fd4 commit d65f2ed
Showing 3 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions project/api/app/Http/Controllers/User.php
Original file line number Diff line number Diff line change
@@ -30,6 +30,13 @@ public function login(Request $request): \Illuminate\Http\JsonResponse
$request->user()->isOnline = 1;
$request->user()->save();

$request->user()->points = [
'userPoints' => $request->user()->xp,
'level' => $request->user()->level,
'fromCurrentLevel' => $request->user()->xp - ($request->user()->level - 1) * 100,
'toNextLevel' => $request->user()->level * 100 - $request->user()->xp
];

return response()->json($request->user())->cookie('auth-token', $request->user()->auth_token, 'session', null, '.sharkdev.eu', 'none');
}

2 changes: 2 additions & 0 deletions project/react/src/App.js
Original file line number Diff line number Diff line change
@@ -51,6 +51,8 @@ class App extends React.Component {
const {user} = state;
const isLogged = !!state.user;

console.log(user);

return user === undefined ? (
<Loader/>
) : (
2 changes: 2 additions & 0 deletions project/react/src/Core/Header/Header.js
Original file line number Diff line number Diff line change
@@ -30,6 +30,8 @@ function Header(props) {
</>
);

console.log(state.user?.points?.fromCurrentLevel);

const stats = (
<article className={state.user?.points?.fromCurrentLevel === 0 ? 'stats no-xp' : 'stats'}>
<article className="stats-bar" style={{width: `${state.user?.points?.fromCurrentLevel}%`}}/>

0 comments on commit d65f2ed

Please sign in to comment.