Skip to content

Commit

Permalink
fix error on user page
Browse files Browse the repository at this point in the history
  • Loading branch information
leobesnard committed Nov 27, 2023
1 parent 5166867 commit 820a7bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion front/src/components/TwoFaActivationInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const TwoFACode: React.FC<TwoFACodeProps> = ({ setShowInvalidate }) => {
};

return (
<form onSubmit={() => mutation.mutate(code)} className="flex flex-col items-center">
<form onSubmit={() => mutation.mutate(code)} className="flex flex-col items-center gap-3">
<input
className="rounded-md border border-dark-3 bg-white-3 p-1 invalid:border-red focus:border-blue focus:outline-none"
name="2FAcode"
Expand Down
26 changes: 15 additions & 11 deletions front/src/pages/User.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,35 @@ import { userDto } from '@/dto/userDto';
import { useApi } from '@/hooks/useApi';

function User() {
const routeParams = useParams();
const { login } = useParams();

const { data: games } = useApi().get(
'get user win',
`game/all/${routeParams.login}`,
) as UseQueryResult<gameDto[]>;
const {
data: games,
isLoading: load,
isError: error,
} = useApi().get('get user win', `game/all/${login}`) as UseQueryResult<gameDto[]>;

const {
data: user,
isLoading,
isError,
} = useApi().get(
'get user profile',
`user/profile/${routeParams.login}`,
) as UseQueryResult<userDto>;
} = useApi().get('get user profile', `user/profile/${login}`) as UseQueryResult<userDto>;

if (isLoading) {
return <div>Loading...</div>;
}
if (isError) {
return <div>Error...</div>;
}
if (load) {
return <div>Loading...</div>;
}
if (error) {
return <div>Error...</div>;
}

const win = games?.filter((g) => g.winner.login === routeParams.login).length;
const lose = games?.filter((g) => g.loser.login === routeParams.login).length;
const win = games?.filter((g) => g.winner.login === login).length;
const lose = games?.filter((g) => g.loser.login === login).length;

return (
<>
Expand Down

0 comments on commit 820a7bc

Please sign in to comment.