Skip to content

Commit

Permalink
Final PR (KEA-ACCELER#115)
Browse files Browse the repository at this point in the history
* App.js for search

* Fix popular list
  • Loading branch information
SevngIl authored Jun 8, 2023
1 parent 18569f6 commit f26daa5
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 190 deletions.
90 changes: 45 additions & 45 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,51 +36,51 @@ export const FormHandlingContext = React.createContext();
export const AuthContext = React.createContext();

function App() {
return (
<AuthenticationContextProvider>
<SurveyContextProvider>
<PostContextProvider>
<AIContextProvider>
<ToastContainer
className="Toast"
closeButton={false}
position={toast.POSITION.TOP_CENTER}
icon={false}
pauseOnFocusLoss={false}
autoClose={1000}
pauseOnHover={false}
hideProgressBar={true}
/>
<BrowserRouter>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="mypage" element={<Mypage />}>
<Route index element={<MyTemplatePage />} />
<Route path="template" element={<MyTemplatePage />} />
<Route path="posted" element={<MyPostedSurveysPage />} />
<Route path="answered" element={<MyAnsweredSurveysPage />} />
</Route>
<Route path="create" element={<CreateSurvey />} />
<Route path="survey/:id" element={<Survey />} />
<Route path="register" element={<RegisterForm />} />
<Route path="login" element={<LoginForm />} />
<Route path="community" element={<Community />} />
<Route path="search/:keyword" element={<Search />} />
<Route path="community/allpostlist" element={<AllPostList />} />
<Route path="createAvsB" element={<CreateAvsB />} />
<Route path="mypage_setting" element={<Mypage_setting />} />
<Route path="post/:postPk" element={<Post />} />
<Route path="post/:postPk/statistics" element={<Statistics />} />
</Route>
</Routes>
</BrowserRouter>
</AIContextProvider>
</PostContextProvider>
</SurveyContextProvider>
</AuthenticationContextProvider>
);
return (
<AuthenticationContextProvider>
<SurveyContextProvider>
<PostContextProvider>
<AIContextProvider>
<ToastContainer
className="Toast"
closeButton={false}
position={toast.POSITION.TOP_CENTER}
icon={false}
pauseOnFocusLoss={false}
autoClose={1000}
pauseOnHover={false}
hideProgressBar={true}
/>
<BrowserRouter>
<Routes>
<Route path="/" element={<Layout />}>
<Route index element={<Home />} />
<Route path="about" element={<About />} />
<Route path="mypage" element={<Mypage />}>
<Route index element={<MyTemplatePage />} />
<Route path="template" element={<MyTemplatePage />} />
<Route path="posted" element={<MyPostedSurveysPage />} />
<Route path="answered" element={<MyAnsweredSurveysPage />} />
</Route>
<Route path="create" element={<CreateSurvey />} />
<Route path="survey/:id" element={<Survey />} />
<Route path="register" element={<RegisterForm />} />
<Route path="login" element={<LoginForm />} />
<Route path="community" element={<Community />} />
<Route path="search/:keyword" element={<Search />} />
<Route path="community/allpostlist" element={<AllPostList />} />
<Route path="createAvsB" element={<CreateAvsB />} />
<Route path="mypage_setting" element={<Mypage_setting />} />
<Route path="post/:postPk" element={<Post />} />
<Route path="post/:postPk/statistics" element={<Statistics />} />
</Route>
</Routes>
</BrowserRouter>
</AIContextProvider>
</PostContextProvider>
</SurveyContextProvider>
</AuthenticationContextProvider>
);
}

export default App;
134 changes: 67 additions & 67 deletions src/components/SurveyList/SurveyListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,82 +7,82 @@ import { SurveyContext } from "../../services/survey/survey.context";
import { AuthenticationContext } from "../../services/authentication/authentication.context";

export const SurveyListItem = (props) => {
const navigate = useNavigate();
// console.log(props);
const { GetMyAnswer } = useContext(SurveyContext);
const { userData, userToken } = useContext(AuthenticationContext);
const navigate = useNavigate();
// console.log(props);
const { GetMyAnswer } = useContext(SurveyContext);
const { userData, userToken } = useContext(AuthenticationContext);

const handleClick = async () => {
if (props.surveyType === "AB" && (props.type === "post" || props.type === "allpost")) {
navigate(`/post/${props.id}`, { state: { id: props.id } });
} else if (props.surveyType === "AB") {
navigate(`/createAvsB/`, { state: { id: props.id } });
} else if (props.type === "answered") {
const myAnswer = await GetMyAnswer(props.id, userToken);
console.log("my answer: ", myAnswer);
navigate(`/survey/${props.id}`, { state: { forCheck: true, myAnswer: myAnswer } });
} else if (props.type === "popular") {
navigate(`/survey/${props.id}`, { state: { id: props.id } });
} else if (props.type === "post" || props.type === "allpost") {
navigate(`/post/${props.id}`);
console.log(props);
} else {
navigate(`/create/`, { state: { id: props.id } });
}
};
const handleClick = async () => {
if (props.surveyType === "AB" && (props.type === "post" || props.type === "allpost")) {
navigate(`/post/${props.id}`, { state: { id: props.id } });
} else if (props.surveyType === "AB") {
navigate(`/createAvsB/`, { state: { id: props.id } });
} else if (props.type === "answered") {
const myAnswer = await GetMyAnswer(props.id, userToken);
console.log("my answer: ", myAnswer);
navigate(`/survey/${props.id}`, { state: { forCheck: true, myAnswer: myAnswer } });
} else if (props.type === "popular") {
navigate(`/post/${props.id}`, { state: { id: props.id } });
} else if (props.type === "post" || props.type === "allpost") {
navigate(`/post/${props.id}`);
console.log(props);
} else {
navigate(`/create/`, { state: { id: props.id } });
}
};

return (
<div className="SurveyListItem" onClick={handleClick}>
<div className="itemLeftWrapper">
<div className="badgeWrapper">
<Badge className="categoryBadge" bg={props.surveyType === "AB" ? "info" : "primary"} key={1234}>
{props.surveyType === "AB" ? "AvsB" : props.surveyType === "NORMAL" ? "Normal" : null}
</Badge>
</div>
<span className="surveyTitle">{props.title}</span>
</div>
<div className="itemRightWrapper">
{props.type === "post" ? <span className="author">작성자 : {props.author}</span> : <span className="author">작성자 : {props.author}</span>}

{props.type === "post" && (
<div className="dateWrapper">
<span className="postStartDate">
<div className="startdate">시작날짜</div>
<div>
{props.postStartDate[0]}{props.postStartDate[1]}{props.postStartDate[2]}
</div>
<div>
{props.postStartDate[3]}{props.postStartDate[4]}
</div>
</span>
<span className="postDueDate">
<div className="duedate">마감날짜</div>
<div>
{props.postDueDate[0]}{props.postDueDate[1]}{props.postDueDate[2]}
</div>
<div>
{props.postDueDate[3]}{props.postDueDate[4]}
</div>
</span>
</div>
)}
</div>
return (
<div className="SurveyListItem" onClick={handleClick}>
<div className="itemLeftWrapper">
<div className="badgeWrapper">
<Badge className="categoryBadge" bg={props.surveyType === "AB" ? "info" : "primary"} key={1234}>
{props.surveyType === "AB" ? "AvsB" : props.surveyType === "NORMAL" ? "Normal" : null}
</Badge>
</div>
);
<span className="surveyTitle">{props.title}</span>
</div>
<div className="itemRightWrapper">
{props.type === "post" ? <span className="author">작성자 : {props.author}</span> : <span className="author">작성자 : {props.author}</span>}

{props.type === "post" && (
<div className="dateWrapper">
<span className="postStartDate">
<div className="startdate">시작날짜</div>
<div>
{props.postStartDate[0]}{props.postStartDate[1]}{props.postStartDate[2]}
</div>
<div>
{props.postStartDate[3]}{props.postStartDate[4]}
</div>
</span>
<span className="postDueDate">
<div className="duedate">마감날짜</div>
<div>
{props.postDueDate[0]}{props.postDueDate[1]}{props.postDueDate[2]}
</div>
<div>
{props.postDueDate[3]}{props.postDueDate[4]}
</div>
</span>
</div>
)}
</div>
</div>
);
};

export const HotCategory = (props) => {
return (
<div className="SurveyListItem">
<span className="surveyTitle">{props.category == "" ? "빈칸" : props.category}</span>
</div>
);
return (
<div className="SurveyListItem">
<span className="surveyTitle">{props.category == "" ? "빈칸" : props.category}</span>
</div>
);
};

SurveyListItem.defaultProps = {
title: "제목",
author: "작성자",
title: "제목",
author: "작성자",
};
HotCategory.defaultProps = {
category: "분야 예시 1",
category: "분야 예시 1",
};
Loading

0 comments on commit f26daa5

Please sign in to comment.