add social friend with redirection to personnal profile page and show personnal match log
This commit is contained in:
parent
61ed18f5c7
commit
450ece5393
@ -45,8 +45,9 @@ export class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Get('/user')
|
@Post('/user')
|
||||||
async getUser( @Body() data: any) {
|
async getUser( @Body() data: any) {
|
||||||
|
console.log(`usernamewwww= ${data.username}`)
|
||||||
return await this.userService.findOne(data.username);
|
return await this.userService.findOne(data.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,12 +126,12 @@ export class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@UseGuards(JwtAuthGuard)
|
@UseGuards(JwtAuthGuard)
|
||||||
@Get('/history')
|
@Post('/history')
|
||||||
async getHistory(@Request() req)
|
async getHistory(@Body() data: any)
|
||||||
{
|
{
|
||||||
// const user = await this.userService.findOne(req.user.username);
|
// const user = await this.userService.findOne(req.user.username);
|
||||||
// return user.rank;
|
// return user.rank;
|
||||||
return await this.userService.getHistory(req.user.username);
|
return await this.userService.getHistory(data.username);
|
||||||
|
|
||||||
// if (user) {
|
// if (user) {
|
||||||
// const children = user.children;
|
// const children = user.children;
|
||||||
|
|||||||
@ -43,7 +43,7 @@ export class UsersService {
|
|||||||
const user = await this.findOne(username)
|
const user = await this.findOne(username)
|
||||||
let friendsTab = user.friends
|
let friendsTab = user.friends
|
||||||
console.log(friendsTab)
|
console.log(friendsTab)
|
||||||
friendsTab = ['apommier']
|
friendsTab = ['apommier', 'syd']
|
||||||
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
const friends = await this.userRepository.query("SELECT * FROM \"User\" WHERE username = ANY ($1);", [friendsTab]);
|
||||||
console.log(friends)
|
console.log(friends)
|
||||||
return (friends)
|
return (friends)
|
||||||
|
|||||||
@ -45,19 +45,24 @@ import '../../styles/Win_Loss.css'
|
|||||||
// `
|
// `
|
||||||
|
|
||||||
import React, { useState, useEffect, useRef } from "react";
|
import React, { useState, useEffect, useRef } from "react";
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
import api from '../../script/axiosApi';
|
import api from '../../script/axiosApi';
|
||||||
|
|
||||||
function WinLoss() {
|
|
||||||
|
|
||||||
|
function WinLoss() {
|
||||||
|
|
||||||
const [user, setUser] = useState(null);
|
const [user, setUser] = useState(null);
|
||||||
const [history, setHistory] = useState([]);
|
const [history, setHistory] = useState([]);
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
|
||||||
|
const { username } = useParams();
|
||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
const getUser = async ()=>{
|
const getUser = async ()=>{
|
||||||
try{
|
try{
|
||||||
const tmpUser = await api.get("/profile")
|
// const tmpUser = await api.get("/profile")
|
||||||
const tmpHistory = await api.get("/history")
|
const tmpUser = await api.post("/user", {username: username})
|
||||||
|
const tmpHistory = await api.post("/history", {username: username})
|
||||||
setHistory(tmpHistory.data);
|
setHistory(tmpHistory.data);
|
||||||
setUser(tmpUser.data);
|
setUser(tmpUser.data);
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|||||||
@ -41,9 +41,11 @@ function Profile () {
|
|||||||
|
|
||||||
useEffect(()=> {
|
useEffect(()=> {
|
||||||
const getUser = async ()=>{
|
const getUser = async ()=>{
|
||||||
|
console.log(`username= ${username}`)
|
||||||
try{
|
try{
|
||||||
const tmpUser = await api.get("/user", {username: username})
|
const tmpUser = await api.post("/user", {username: username})
|
||||||
setUser(tmpUser.data);
|
setUser(tmpUser.data);
|
||||||
|
console.log(`user= ${tmpUser.data.username}`)
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
}
|
}
|
||||||
catch(err){
|
catch(err){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user