Skip to content

Commit

Permalink
feat(fe): implement contest code editor page (#1423)
Browse files Browse the repository at this point in the history
feat(fe): contest code editor page
  • Loading branch information
dayongkr authored Feb 19, 2024
1 parent 2da2547 commit ccebc36
Show file tree
Hide file tree
Showing 34 changed files with 457 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import type { ContestAnnouncement } from '@/types/type'
import { columns } from './_components/Columns'

interface ContestAnnouncementProps {
params: { id: string }
params: { contestId: string }
}

export default async function ContestAnnouncement({
params
}: ContestAnnouncementProps) {
const { id } = params
const { contestId } = params
const contestAnnouncements: ContestAnnouncement[] = await fetcher
.get('announcement', {
searchParams: {
contestId: id
contestId
}
})
.json()
Expand All @@ -28,7 +28,6 @@ export default async function ContestAnnouncement({
content: 'w-[70%]',
updateTime: 'w-[18%]'
}}
name=""
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ interface ContestTop {

interface ContestTopProps {
params: {
id: string
contestId: string
}
}

export default async function ContestTop({ params }: ContestTopProps) {
const session = await auth()
const { id } = params
const data: ContestTop = await fetcher.get(`contest/${id}`).json()
const { contestId } = params
const data: ContestTop = await fetcher.get(`contest/${contestId}`).json()
const startTime = new Date(data.startTime)
const currentTime = new Date()

Expand All @@ -29,7 +29,7 @@ export default async function ContestTop({ params }: ContestTopProps) {
/>
{session && currentTime < startTime && (
<div className="mt-10 flex justify-center">
<ParticipateButton id={id} />
<ParticipateButton id={contestId} />
</div>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,20 @@ import type { ContestProblem } from '@/types/type'
import { columns } from './_components/Columns'

interface ContestProblemProps {
params: { id: string }
params: { contestId: string }
}

export default async function ContestProblem({ params }: ContestProblemProps) {
const { id } = params
const { contestId } = params
const { problems }: { problems: ContestProblem[] } = await fetcher
.get('problem', {
searchParams: {
take: 10,
contestId: id
contestId
}
})
.json()

problems.forEach((problem) => {
problem.id = problem.problemId
})

return (
<DataTable
data={problems}
Expand All @@ -33,7 +29,7 @@ export default async function ContestProblem({ params }: ContestProblemProps) {
submissionCount: 'w-[14%]',
acceptedRate: 'w-[14%]'
}}
name="problem"
linked
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ContestTabs from '../_components/ContestTabs'

interface ContestDetailProps {
params: {
id: string
contestId: string
}
}

Expand All @@ -24,8 +24,8 @@ export default async function Layout({
params: ContestDetailProps['params']
tabs: React.ReactNode
}) {
const { id } = params
const res = await fetcher.get(`contest/${id}`)
const { contestId } = params
const res = await fetcher.get(`contest/${contestId}`)
if (res.ok) {
const data: Contest = await res.json()
const currentTime = new Date()
Expand Down Expand Up @@ -74,7 +74,7 @@ export default async function Layout({
</div>
)}
</header>
<ContestTabs contestId={id} />
<ContestTabs contestId={contestId} />
{tabs}
</article>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { sanitize } from 'isomorphic-dompurify'

interface ContestDetailProps {
params: {
id: string
contestId: string
}
}

export default async function ContestDetail({ params }: ContestDetailProps) {
const { id } = params
const { contestId } = params
const { title, startTime, endTime, description } = await fetch(
baseUrl + `/contest/${id}`
baseUrl + `/contest/${contestId}`
).then((res) => res.json())
return (
<article>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default async function FinishedContestTable() {
participants: 'w-1/5 md:w-1/6',
status: 'w-1/4 md:w-1/6'
}}
name="contest"
linked
/>
</>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function NoticeTable({ search }: Props) {
createdBy: 'w-1/4 md:w-1/6',
createTime: 'w-1/4 md:w-1/6'
}}
name="notice"
linked
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default async function ProblemTable({ search, order }: Props) {
acceptedRate: 'w-2/12',
info: 'w-1/12'
}}
name="problem"
linked
/>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import EditorLayout from '@/components/EditorLayout'

export default async function layout({
params,
children
}: {
params: { problemId: string; contestId: string }
children: React.ReactNode
}) {
const { problemId, contestId } = params

return (
<EditorLayout problemId={problemId} contestId={contestId}>
{children}
</EditorLayout>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { EditorDescription } from '@/components/EditorDescription'
import { fetcher } from '@/lib/utils'
import type { ProblemDetail } from '@/types/type'

export default async function DescriptionPage({
params
}: {
params: { problemId: number }
}) {
const { problemId } = params
const problem: ProblemDetail = await fetcher(`problem/${problemId}`).json()

return <EditorDescription problem={problem} />
}
59 changes: 0 additions & 59 deletions frontend-client/app/problem/[id]/_components/EditorHeader.tsx

This file was deleted.

This file was deleted.

50 changes: 0 additions & 50 deletions frontend-client/app/problem/[id]/_components/SelectScrollable.tsx

This file was deleted.

Loading

0 comments on commit ccebc36

Please sign in to comment.