From b8cd357a9fc30798ebbb6a37c5d1403af7e27f43 Mon Sep 17 00:00:00 2001 From: suzinxix Date: Sun, 12 Mar 2023 19:00:22 +0900 Subject: [PATCH 1/5] [#86] feat: implement user GET api --- bowwowcare/src/views/UserPage/UserPage.js | 32 +++++++++++++++++++---- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/bowwowcare/src/views/UserPage/UserPage.js b/bowwowcare/src/views/UserPage/UserPage.js index 2b72844..92a1743 100644 --- a/bowwowcare/src/views/UserPage/UserPage.js +++ b/bowwowcare/src/views/UserPage/UserPage.js @@ -1,12 +1,36 @@ -import React ,{ useState }from "react"; +import React ,{ useEffect, useState }from "react"; +import axios from "axios"; import Header from "../../components/Header"; import ThemeSwitcher from "../../components/ThemeSwitcher"; import HAPPY from "../../assets/images/happy.png" +import { API_URL } from "../../Config"; +import authHeader from "../../services/auth-header"; function UserPage() { const [rewards, setRewards] = useState(0); - const [fileImg, setFileImg] = useState("string"); - const [userName, setUserName] = useState("짱구"); + const [fileImg, setFileImg] = useState(""); + const [userName, setUserName] = useState(""); + + useEffect(() => { + getUser(); + }, []) + + const getUser = () => { + axios({ + method: 'GET', + url: `${API_URL}/user`, + headers: authHeader(), + }) + .then( (response) => { + if(response.status === 200) { + const user = response.data; + setUserName(user.username); + setRewards(user.reward); + setFileImg(user.profileImage); + } + } + ).catch((e) => {console.log(e.response.data)}) + } return (
@@ -20,8 +44,6 @@ function UserPage() {
{userName}
- -
내 리워드 From 47ca16105e55dd557260299ef1533e65393f9c96 Mon Sep 17 00:00:00 2001 From: suzinxix Date: Sun, 12 Mar 2023 19:06:44 +0900 Subject: [PATCH 2/5] [#86] feat: implement disabled theme button --- bowwowcare/src/components/ThemeBox.js | 8 ++++---- bowwowcare/src/components/ThemeSwitcher.js | 16 ++++++++++------ bowwowcare/src/views/UserPage/UserPage.js | 5 ++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/bowwowcare/src/components/ThemeBox.js b/bowwowcare/src/components/ThemeBox.js index 16f11c7..b85c498 100644 --- a/bowwowcare/src/components/ThemeBox.js +++ b/bowwowcare/src/components/ThemeBox.js @@ -1,15 +1,15 @@ -import styled from "styled-components"; import { useContext } from 'react' import { ThemeContext } from './../context/ThemeProvider.js'; import { colorVariants } from "../utils/Dictionary"; -function ThemeBox({onClick, title, status, rewards, mainColor, subColor}) { +function ThemeBox({onClick, title, status, rewards, mainColor, subColor, disabled, id}) { const [themeMode, setThemeMode] = useContext(ThemeContext); return ( - : window.location.pathname === "/" ? : null diff --git a/bowwowcare/src/components/ThemeBox.js b/bowwowcare/src/components/ThemeBox.js index 79eac76..1977647 100644 --- a/bowwowcare/src/components/ThemeBox.js +++ b/bowwowcare/src/components/ThemeBox.js @@ -2,10 +2,10 @@ import { useContext } from 'react' import { ThemeContext } from './../context/ThemeProvider.js'; import { colorVariants } from "../utils/Dictionary"; -function ThemeBox({onClick, title, status, rewards, mainColor, subColor, disabled, locked}) { +function ThemeBox({onClick, title, status, rewards, mainColor, subColor, locked}) { const [themeMode, setThemeMode] = useContext(ThemeContext); return ( -