11import React , { useEffect , useState } from "react" ;
22import { recentSolved } from "./recentSolved" ;
33
4- const LEETCODE_USERNAME = "Sunil-Kumar-K-V " ;
4+ const LEETCODE_USERNAME = "YOUR_LEETCODE_USERNAME " ;
55
66export default function LeetCodeProblems ( ) {
77 const [ stats , setStats ] = useState ( null ) ;
8+ const [ query , setQuery ] = useState ( "" ) ;
9+ const [ difficulty , setDifficulty ] = useState ( "All" ) ;
810
911 useEffect ( ( ) => {
1012 fetch ( `https://leetcode-stats-api.herokuapp.com/${ LEETCODE_USERNAME } ` )
1113 . then ( ( res ) => res . json ( ) )
1214 . then ( setStats )
1315 . catch ( console . error ) ;
1416 } , [ ] ) ;
15-
16- < section className = "section-panel" >
17- < span className = "section-eyebrow" > Recent Practice</ span >
18- < h2 > Recently Solved Problems</ h2 >
1917
20- < div className = "feature-grid" >
21- { recentSolved . map ( ( problem ) => (
22- < article className = "glass-card" key = { problem . title } >
23- < h3 > { problem . title } </ h3 >
24- < p > { problem . platform } • { problem . difficulty } </ p >
25- < a href = { problem . url } target = "_blank" rel = "noreferrer" >
26- View Problem →
27- </ a >
28- </ article >
29- ) ) }
30- </ div >
31- </ section >
18+ const filteredProblems = recentSolved . filter ( ( problem ) => {
19+ const matchesSearch = problem . title
20+ . toLowerCase ( )
21+ . includes ( query . toLowerCase ( ) ) ;
22+
23+ const matchesDifficulty =
24+ difficulty === "All" || problem . difficulty === difficulty ;
25+
26+ return matchesSearch && matchesDifficulty ;
27+ } ) ;
3228
3329 return (
3430 < main className = "page-shell" >
@@ -66,6 +62,58 @@ export default function LeetCodeProblems() {
6662 < p > Advanced problem-solving challenges.</ p >
6763 </ article >
6864 </ div >
65+
66+ < section className = "section-panel" >
67+ < span className = "section-eyebrow" > Recent Practice</ span >
68+ < h2 > Recently Solved Problems</ h2 >
69+
70+ < div className = "problem-grid" >
71+ < input
72+ type = "text"
73+ placeholder = "Search problems..."
74+ value = { query }
75+ onChange = { ( e ) => setQuery ( e . target . value ) }
76+ style = { {
77+ padding : "14px" ,
78+ borderRadius : "12px" ,
79+ border : "1px solid rgba(255,255,255,0.2)" ,
80+ background : "transparent" ,
81+ color : "inherit" ,
82+ } }
83+ />
84+
85+ < select
86+ value = { difficulty }
87+ onChange = { ( e ) => setDifficulty ( e . target . value ) }
88+ style = { {
89+ padding : "14px" ,
90+ borderRadius : "12px" ,
91+ border : "1px solid rgba(255,255,255,0.2)" ,
92+ background : "transparent" ,
93+ color : "inherit" ,
94+ } }
95+ >
96+ < option > All</ option >
97+ < option > Easy</ option >
98+ < option > Medium</ option >
99+ < option > Hard</ option >
100+ </ select >
101+ </ div >
102+
103+ < div className = "feature-grid" >
104+ { filteredProblems . map ( ( problem ) => (
105+ < article className = "glass-card" key = { problem . title } >
106+ < h3 > { problem . title } </ h3 >
107+ < p >
108+ { problem . platform } • { problem . difficulty }
109+ </ p >
110+ < a href = { problem . url } target = "_blank" rel = "noreferrer" >
111+ View Problem →
112+ </ a >
113+ </ article >
114+ ) ) }
115+ </ div >
116+ </ section >
69117 </ main >
70118 ) ;
71119}
0 commit comments