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

feat(fe): change to contest submit #1537

Merged
merged 4 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions frontend-client/components/EditorHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ import { toast } from 'sonner'

interface ProblemEditorProps {
problem: ProblemDetail
contestId?: string | null
}

export default function Editor({ problem }: ProblemEditorProps) {
export default function Editor({ problem, contestId }: ProblemEditorProps) {
const { code, language, clearCode, setLanguage } = useEditorStore()
const [loading, setLoading] = useState(false)
const [submissionId, setSubmissionId] = useState<number | null>(null)
Expand Down Expand Up @@ -95,7 +96,8 @@ export default function Editor({ problem }: ProblemEditorProps) {
]
},
searchParams: {
problemId: problem.id
problemId: problem.id,
...(contestId && { contestId })
},
next: {
revalidate: 0
Expand Down
6 changes: 4 additions & 2 deletions frontend-client/components/EditorLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from './ui/dropdown-menu'

interface EditorLayoutProps {
contestId?: string
contestId?: string | null
problemId: string
children: React.ReactNode
}
Expand Down Expand Up @@ -75,7 +75,9 @@ export default async function EditorLayout({
</div>
</div>
</header>
<EditorResizablePanel problem={problem}>{children}</EditorResizablePanel>
<EditorResizablePanel problem={problem} contestId={contestId}>
{children}
</EditorResizablePanel>
</div>
)
}
4 changes: 3 additions & 1 deletion frontend-client/components/EditorResizablePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ import Loading from '../app/problem/[problemId]/loading'
import EditorHeader from './EditorHeader'

interface ProblemEditorProps {
contestId?: string | null
problem: ProblemDetail
children: React.ReactNode
}

export default function EditorMainResizablePanel({
problem,
contestId,
children
}: ProblemEditorProps) {
// get programming language from localStorage for default value
Expand Down Expand Up @@ -93,7 +95,7 @@ export default function EditorMainResizablePanel({

<ResizablePanel defaultSize={65} className="bg-slate-900">
<div className="grid-rows-editor grid h-full">
<EditorHeader problem={problem} />
<EditorHeader problem={problem} contestId={contestId} />
<CodeEditor
value={code}
language={language as Language}
Expand Down