Skip to content

Commit

Permalink
Merge branch 'dev/front/finalDemo' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
saa00123 committed Sep 3, 2023
2 parents 28a83a1 + d2249ee commit ce91281
Show file tree
Hide file tree
Showing 15 changed files with 451 additions and 200 deletions.
83 changes: 43 additions & 40 deletions front/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
import React from 'react';
import { BrowserRouter, Route, Routes } from 'react-router-dom';
import axios from 'axios';
import WelcomePage from './pages/main/WelcomePage';
import TeamList from './pages/main/TeamList';
import DashBoard from './pages/main/DashBoard';
import Login from './pages/main/Login';
import Project from './pages/project/Project';
import Sprint from './pages/sprint/Sprint';
import Task from './pages/task/Task';
import Members from './pages/member/MemberPage';
import Graph from './pages/graph/Graph';
import Agora from './pages/agora/Agora';
import Question from './pages/agora/Question';
import Question1 from './pages/agora/Question1';
import Question2 from './pages/agora/Question2';
import React from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import axios from "axios";
import { UserProvider } from "./components/frames/token/UserContext";
import WelcomePage from "./pages/main/WelcomePage";
import TeamList from "./pages/main/TeamList";
import DashBoard from "./pages/main/DashBoard";
import Login from "./pages/main/Login";
import Project from "./pages/project/Project";
import Sprint from "./pages/sprint/Sprint";
import Task from "./pages/task/Task";
import Members from "./pages/member/MemberPage";
import Graph from "./pages/graph/Graph";
import Agora from "./pages/agora/Agora";
import Question from "./pages/agora/Question";
import Question1 from "./pages/agora/Question1";
import Question2 from "./pages/agora/Question2";

axios.defaults.baseURL = process.env.REACT_APP_BASE_URL;
axios.defaults.withCredentials = true;
function App() {
return (
<BrowserRouter>
<Routes>
{/** 메인 페이지 및 로그인 페이지 */}
<Route path='/' element={<WelcomePage />} />
<Route path='/TeamList' element={<TeamList />} />
<Route path='/DashBoard' element={<DashBoard />} />
<Route path='/Login' element={<Login />} />
{/** 프로젝트 페이지 */}
<Route path='/Project' element={<Project />} />
{/** 스프린트 페이지 */}
<Route path='/Sprint' element={<Sprint />} />
{/** 테스크 페이지 */}
<Route path='/Task' element={<Task />} />
{/** 멤버 페이지 */}
<Route path='/Members' element={<Members />} />
{/** 성과분석 결과 페이지 */}
<Route path='/Graph' element={<Graph />} />
{/** 아고라 페이지 */}
<Route path='/Agora' element={<Agora />} />
<Route path='/Question' element={<Question />} />
<Route path='/Question1' element={<Question1 />} />
<Route path='/Question2' element={<Question2 />} />
</Routes>
</BrowserRouter>
<UserProvider>
<BrowserRouter>
<Routes>
{/** 메인 페이지 및 로그인 페이지 */}
<Route path='/' element={<WelcomePage />} />
<Route path='/TeamList' element={<TeamList />} />
<Route path='/DashBoard' element={<DashBoard />} />
<Route path='/Login' element={<Login />} />
{/** 프로젝트 페이지 */}
<Route path='/Project' element={<Project />} />
{/** 스프린트 페이지 */}
<Route path='/Sprint' element={<Sprint />} />
{/** 테스크 페이지 */}
<Route path='/Task' element={<Task />} />
{/** 멤버 페이지 */}
<Route path='/Members' element={<Members />} />
{/** 성과분석 결과 페이지 */}
<Route path='/Graph' element={<Graph />} />
{/** 아고라 페이지 */}
<Route path='/Agora' element={<Agora />} />
<Route path='/Question' element={<Question />} />
<Route path='/Question1' element={<Question1 />} />
<Route path='/Question2' element={<Question2 />} />
</Routes>
</BrowserRouter>
</UserProvider>
);
}

Expand Down
15 changes: 0 additions & 15 deletions front/src/components/frames/Cookie/useCookie.tsx

This file was deleted.

9 changes: 6 additions & 3 deletions front/src/components/frames/Side/Profile.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import ProfileImg from '../../../images/members.png';
import React from "react";
import ProfileImg from "../../../images/members.png";
import { useUser } from "../token/UserContext";

function Profile() {
const [user] = useUser();

return (
<div className='flex justify-center items-center mr-auto w-[150px] h-[50px] rounded-[30px]'>
<img
Expand All @@ -10,7 +13,7 @@ function Profile() {
src={ProfileImg}
/>
<div className='flex justify-center items-center m-auto ml-1 text-white'>
sample
{user ? user.nickname : "Guest"}
</div>
</div>
);
Expand Down
16 changes: 4 additions & 12 deletions front/src/components/frames/TeamList/FixProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import React, { useState } from 'react';
import Modal from 'react-modal';
import { useCookie } from '../Cookie/useCookie';
import rightArrow from '../../../images/rightarrow.png';
import React, { useState } from "react";
import Modal from "react-modal";
import rightArrow from "../../../images/rightarrow.png";

function FixProfile() {
const [modalIsOpen, setIsOpen] = useState(false);
const [name, setName] = useCookie('name', '');

function handleNameChange(e: React.ChangeEvent<HTMLInputElement>) {
setName(e.target.value);
}

function openModal() {
setIsOpen(true);
Expand Down Expand Up @@ -42,12 +36,10 @@ function FixProfile() {
<input
className='text-[20px] w-[430px] border-b-2'
type='text'
value={name}
onChange={handleNameChange}
placeholder='닉네임을 입력해주세요.'
/>
</label>
<p className='text-[20px] w-[430px] border-b-2'>{name}</p>

<div className='flex space-x-2'>
<button
type='submit'
Expand Down
77 changes: 77 additions & 0 deletions front/src/components/frames/token/UserContext.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import React, {
createContext,
useState,
useEffect,
useContext,
useMemo,
} from "react";

type User = {
token: string;
nickname: string;
isNewUser: boolean;
};

type UserContextType = [
User | null,
React.Dispatch<React.SetStateAction<User | null>>
];

const UserContext = createContext<UserContextType | undefined>(undefined);

export const useUser = (): UserContextType => {
const context = useContext(UserContext);
if (!context) {
throw new Error("useUser must be used within a UserProvider");
}
return context;
};

export const UserProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const [user, setUser] = useState<User | null>(null);
const [showNicknamePopup, setShowNicknamePopup] = useState(false);

useEffect(() => {
const isLoginSuccessful = true;

if (isLoginSuccessful) {
const token = "some_token";
const storedNickname = localStorage.getItem("nickname");

if (storedNickname) {
setUser({ token, nickname: storedNickname, isNewUser: false });
} else {
setShowNicknamePopup(true);
setUser({ token, nickname: "Guest", isNewUser: true });
}
}
}, []);

const setNicknameAndHidePopup = (nickname: string) => {
if (user) {
setUser({ ...user, nickname });
}
localStorage.setItem("nickname", nickname);
setShowNicknamePopup(false);
};

const value = useMemo(() => [user, setUser] as UserContextType, [user]);

return (
<UserContext.Provider value={value}>
{children}
{showNicknamePopup && (
<div>
<h2>Please set your nickname</h2>
<input
type='text'
placeholder='Enter your nickname'
onBlur={(e) => setNicknameAndHidePopup(e.target.value)}
/>
</div>
)}
</UserContext.Provider>
);
};
51 changes: 10 additions & 41 deletions front/src/components/graph/AnalysisContribute.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import React from 'react';
import React from "react";
import {
Radar,
RadarChart,
PolarGrid,
PolarAngleAxis,
ResponsiveContainer,
} from 'recharts';
import refresh from '../../images/refresh.png';

const data = [
{
subject: '커뮤니케이션',
A: 330,
fullMark: 700,
},
{
subject: '위기 대처',
A: 30,
fullMark: 700,
},
{
subject: '개발',
A: 630,
fullMark: 700,
},
{
subject: '리팩터링',
A: 240,
fullMark: 700,
},
{
subject: '기획',
A: 300,
fullMark: 700,
},
];
} from "recharts";
import refresh from "../../images/refresh.png";
import mainData from "./GraphData/mainData";

function AnaylsisContribute() {
return (
Expand All @@ -48,13 +21,9 @@ function AnaylsisContribute() {
/>
</div>
<div className='flex m-auto w-[1000px] h-[500px]'>
{' '}
{/* 부모 요소의 크기 조정 */}
<div className='m-auto w-[500px] h-[300px]'>
{' '}
{/* RadarChart 영역 */}
<ResponsiveContainer width='100%' height='100%'>
<RadarChart cx='50%' cy='50%' outerRadius='80%' data={data}>
<RadarChart cx='50%' cy='50%' outerRadius='80%' data={mainData}>
<PolarGrid />
<PolarAngleAxis dataKey='subject' />
<Radar
Expand All @@ -68,11 +37,11 @@ function AnaylsisContribute() {
</ResponsiveContainer>
</div>
<div className='flex flex-col justify-center items-start space-y-2 w-[400px] p-2 m-auto'>
<p>개발 : 630P</p>
<p>기획 : 300P</p>
<p>위기 대처 : 30P</p>
<p>커뮤니케이션 : 330P</p>
<p>리팩터링 : 240P</p>
{mainData.map((item) => (
<p key={item.subject}>
{item.subject} : {item.A}P
</p>
))}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit ce91281

Please sign in to comment.