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: add practice action button #592

Merged
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
41 changes: 22 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions services/ecran/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"@tanstack/react-query": "5.62.0",
"@tanstack/react-query-devtools": "5.62.0",
"@tanstack/react-table": "8.20.5",
"@tanstack/react-virtual": "3.10.9",
"@temporalio/activity": "1.11.5",
"@temporalio/client": "1.11.5",
"@temporalio/worker": "1.11.5",
Expand Down
26 changes: 13 additions & 13 deletions services/ecran/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,45 +78,45 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<html lang="en" suppressHydrationWarning>
<head />
<body
className={`${jetbrains.variable} font-mono tracking-normal antialiased leading-6 text-base bg-gradient-to-b from-zinc-900 to-zinc-950 text-zinc-300 min-h-screen`}
className={`${jetbrains.variable} min-h-screen bg-gradient-to-b from-zinc-900 to-zinc-950 font-mono text-base leading-6 tracking-normal text-zinc-300 antialiased`}
suppressHydrationWarning
>
<Providers>
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem disableTransitionOnChange>
<header className="flex items-center space-x-10 px-10 py-6 border-b border-zinc-800/50 justify-center backdrop-blur-sm bg-zinc-900/30 relative">
<header className="relative flex items-center justify-center space-x-10 border-b border-zinc-800/50 bg-zinc-900/30 px-10 py-6 backdrop-blur-sm">
<div
className="absolute inset-x-0 -top-40 -z-10 transform-gpu overflow-hidden blur-3xl sm:-top-80"
aria-hidden="true"
>
<div className="relative left-[50%] aspect-[1155/678] w-[36.125rem] -translate-x-1/2 rotate-[45deg] bg-gradient-to-br from-indigo-400 to-pink-400 opacity-20" />
</div>
<div className="text-2xl uppercase font-bold group">
<Link href="/" className="hover:text-indigo-400 transition-all duration-300 relative">
<div className="group text-2xl font-bold uppercase">
<Link href="/" className="relative transition-all duration-300 hover:text-indigo-400">
proompteng
<span className="text-indigo-400 group-hover:text-rose-400 inline-block transition-all duration-300 group-hover:animate-pulse">
<span className="inline-block text-indigo-400 transition-all duration-300 group-hover:animate-pulse group-hover:text-rose-400">
</span>
ai
<span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-indigo-400 group-hover:w-full transition-all duration-300" />
<span className="absolute -bottom-1 left-0 h-0.5 w-0 bg-indigo-400 transition-all duration-300 group-hover:w-full" />
</Link>
</div>
<Link href="/problems" className="relative group hover:text-indigo-400 transition-colors duration-200">
<Link href="/problems" className="group relative transition-colors duration-200 hover:text-indigo-400">
Problems
<span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-indigo-400 group-hover:w-full transition-all duration-300" />
<span className="absolute -bottom-1 left-0 h-0.5 w-0 bg-indigo-400 transition-all duration-300 group-hover:w-full" />
</Link>
<Link href="/practice" className="relative group hover:text-indigo-400 transition-colors duration-200">
<Link href="/practice" className="group relative transition-colors duration-200 hover:text-indigo-400">
Practice
<span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-indigo-400 group-hover:w-full transition-all duration-300" />
<span className="absolute -bottom-1 left-0 h-0.5 w-0 bg-indigo-400 transition-all duration-300 group-hover:w-full" />
</Link>
{session?.user ? (
<UserMenu />
) : (
<Link href="/sign-in" className="relative group hover:text-indigo-400 transition-colors duration-200">
<Link href="/sign-in" className="group relative transition-colors duration-200 hover:text-indigo-400">
Sign In
<span className="absolute -bottom-1 left-0 w-0 h-0.5 bg-indigo-400 group-hover:w-full transition-all duration-300" />
<span className="absolute -bottom-1 left-0 h-0.5 w-0 bg-indigo-400 transition-all duration-300 group-hover:w-full" />
</Link>
)}
<div className="text-zinc-400 absolute right-5 text-sm">Version: {version}</div>
<div className="absolute right-5 text-sm text-zinc-400">Version: {version}</div>
</header>
<main className="container py-5">{children}</main>
<FeedbackButton />
Expand Down
46 changes: 1 addition & 45 deletions services/ecran/src/app/practice/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useReducer, useCallback, useEffect, useMemo } from 'react'
import { useReducer, useCallback, useEffect } from 'react'
import { useQuery } from '@tanstack/react-query'
import { useRouter, useSearchParams } from 'next/navigation'
import PracticeView from '@/components/practice-view'
Expand Down Expand Up @@ -36,38 +36,6 @@ def greet(name):
print(greet("World"))
`.trim()

const defaultProblem =
`Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

You can return the answer in any order.



Example 1:

Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Example 2:

Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:

Input: nums = [3,3], target = 6
Output: [0,1]


Constraints:

2 <= nums.length <= 104
-109 <= nums[i] <= 109
-109 <= target <= 109
Only one valid answer exists.
`.trim()

type State = {
code: string
language: string
Expand All @@ -76,7 +44,6 @@ type State = {
isHovered: boolean
hint: string
isLoadingHint: boolean
activeTab: string
selectedProblem: Problem | null
error: string | null
}
Expand All @@ -89,7 +56,6 @@ type Action =
| { type: 'SET_IS_HOVERED'; payload: boolean }
| { type: 'SET_HINT'; payload: string }
| { type: 'SET_IS_LOADING_HINT'; payload: boolean }
| { type: 'SET_ACTIVE_TAB'; payload: string }
| { type: 'SET_SELECTED_PROBLEM'; payload: Problem | null }
| { type: 'SET_ERROR'; payload: string | null }

Expand All @@ -101,7 +67,6 @@ const initialState: State = {
isHovered: false,
hint: '',
isLoadingHint: false,
activeTab: 'description',
selectedProblem: null,
error: null,
}
Expand All @@ -122,8 +87,6 @@ function reducer(state: State, action: Action): State {
return { ...state, hint: action.payload }
case 'SET_IS_LOADING_HINT':
return { ...state, isLoadingHint: action.payload }
case 'SET_ACTIVE_TAB':
return { ...state, activeTab: action.payload }
case 'SET_SELECTED_PROBLEM':
return { ...state, selectedProblem: action.payload }
case 'SET_ERROR':
Expand Down Expand Up @@ -237,7 +200,6 @@ export default function PracticeContainer() {
const problem = problemId ? problems.find((p: Problem) => p.id === problemId) || problems[0] : problems[0]

dispatch({ type: 'SET_SELECTED_PROBLEM', payload: problem })
dispatch({ type: 'SET_ACTIVE_TAB', payload: 'description' })
dispatch({
type: 'SET_CODE',
payload: problem.codeTemplates[state.language] || getDefaultCode(state.language),
Expand All @@ -248,7 +210,6 @@ export default function PracticeContainer() {
const handleProblemChange = useCallback(
(problem: Problem) => {
dispatch({ type: 'SET_SELECTED_PROBLEM', payload: problem })
dispatch({ type: 'SET_ACTIVE_TAB', payload: 'description' })
dispatch({
type: 'SET_CODE',
payload: problem.codeTemplates[state.language] || getDefaultCode(state.language),
Expand All @@ -266,10 +227,6 @@ export default function PracticeContainer() {
dispatch({ type: 'SET_IS_HOVERED', payload: false })
}, [])

const onActiveTabChange = useCallback((tab: string) => {
dispatch({ type: 'SET_ACTIVE_TAB', payload: tab })
}, [])

return (
<PracticeView
{...state}
Expand All @@ -282,7 +239,6 @@ export default function PracticeContainer() {
onProblemChange={handleProblemChange}
onHoverStart={onHoverStart}
onHoverEnd={onHoverEnd}
onActiveTabChange={onActiveTabChange}
/>
)
}
Expand Down
Loading