Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#85] 문제 보기 #86

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions frontend/src/components/Contest/ContestBreadCrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export default function ContestBreadCrumb(props: Props) {
return (
<header>
<div className={titleContainerStyle}>
{crumbs.map((crumb) => {
return <span className={crumbStyle}>{crumb}</span>;
})}
{crumbs.map((crumb, index) => (
<span key={index} className={crumbStyle}>
{crumb}
</span>
))}
</div>
</header>
);
Expand Down
45 changes: 45 additions & 0 deletions frontend/src/pages/ProblemPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { css } from '@style/css';

import { useState } from 'react';

import ProblemViewer from '@/components/Problem/ProblemViewer';
import mockData from '@/mockData.json';

const notFoundProblem = {
title: 'Problem Not Found',
timeLimit: 0,
memoryLimit: 0,
content: 'The requested problem could not be found.',
solutionCode: '',
testcases: [],
createdAt: new Date().toISOString(),
};

const INITIAL_PROBLEM_ID = 6;

function ProblemPage() {
const [currentProblemId] = useState(INITIAL_PROBLEM_ID);
const targetProblem =
mockData.problems.find((problem) => problem.id === currentProblemId) || notFoundProblem;

return (
<main className={style}>
<span className={problemTitleStyle}>{targetProblem.title}</span>
<ProblemViewer content={targetProblem.content} />
</main>
);
}

export default ProblemPage;

const style = css({
backgroundColor: '#1e1e1e',
color: '#ffffff',
});

const problemTitleStyle = css({
display: 'inline-block',
height: '50px',
padding: '10px',
borderBottom: '2px solid white',
});
5 changes: 5 additions & 0 deletions frontend/src/router.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createBrowserRouter } from 'react-router-dom';

import ContestPage from '@/pages/ContestPage';
import ProblemPage from '@/pages/ProblemPage';

import App from './App';

Expand All @@ -13,6 +14,10 @@ const router = createBrowserRouter([
index: true,
element: <ContestPage />,
},
{
path: '/problem/:id', // TODO: api 연동 후 수정
element: <ProblemPage />,
},
],
},
]);
Expand Down
Loading