add social friend with redirection to personnal profile page and show personnal match log

This commit is contained in:
kinou-p 2023-06-07 17:58:27 +02:00
parent 61ed18f5c7
commit 450ece5393
4 changed files with 17 additions and 9 deletions

View File

@ -45,8 +45,9 @@ export class AppController {
}
@UseGuards(JwtAuthGuard)
@Get('/user')
@Post('/user')
async getUser( @Body() data: any) {
console.log(`usernamewwww= ${data.username}`)
return await this.userService.findOne(data.username);
}
@ -125,12 +126,12 @@ export class AppController {
}
@UseGuards(JwtAuthGuard)
@Get('/history')
async getHistory(@Request() req)
@Post('/history')
async getHistory(@Body() data: any)
{
// const user = await this.userService.findOne(req.user.username);
// return user.rank;
return await this.userService.getHistory(req.user.username);
return await this.userService.getHistory(data.username);
// if (user) {
// const children = user.children;

View File

@ -43,7 +43,7 @@ export class UsersService {
const user = await this.findOne(username)
let friendsTab = user.friends
console.log(friendsTab)
friendsTab = ['apommier']
friendsTab = ['apommier', 'syd']
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
console.log(friends)
return (friends)

View File

@ -45,19 +45,24 @@ import '../../styles/Win_Loss.css'
// `
import React, { useState, useEffect, useRef } from "react";
import { useParams } from 'react-router-dom';
import api from '../../script/axiosApi';
function WinLoss() {
const [user, setUser] = useState(null);
const [history, setHistory] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const { username } = useParams();
useEffect(()=> {
const getUser = async ()=>{
try{
const tmpUser = await api.get("/profile")
const tmpHistory = await api.get("/history")
// const tmpUser = await api.get("/profile")
const tmpUser = await api.post("/user", {username: username})
const tmpHistory = await api.post("/history", {username: username})
setHistory(tmpHistory.data);
setUser(tmpUser.data);
setIsLoading(false)

View File

@ -41,9 +41,11 @@ function Profile () {
useEffect(()=> {
const getUser = async ()=>{
console.log(`username= ${username}`)
try{
const tmpUser = await api.get("/user", {username: username})
const tmpUser = await api.post("/user", {username: username})
setUser(tmpUser.data);
console.log(`user= ${tmpUser.data.username}`)
setIsLoading(false)
}
catch(err){