@@ -6,94 +6,57 @@ import mongoose from 'mongoose';
66import { TeamType } from '@/models/teamModel' ;
77import Toaster from '@/utils/toaster' ;
88import ViewSubmission from '@/sections/admin-page-sections/admin-view-submission' ;
9- import EditSubmission from '@/sections/admin-page-sections/admin-edit-submission' ;
109import Header from '@/components/common/header' ;
1110import { useRouter } from 'next/router' ;
1211import { GetServerSidePropsContext } from 'next' ;
1312import getHandler from '@/handlers/getHandler' ;
1413import patchHandler from '@/handlers/patchHandler' ;
15- import InputField from '@/components/common/InputField' ;
1614import { CURRENT_ROUND } from '@/constants' ;
15+ import CommentView from '@/sections/admin-page-sections/admin-view-comment' ;
16+ import CommentEdit from '@/sections/admin-page-sections/admin-edit-comment copy' ;
1717
1818interface Props {
1919 id : string ;
2020}
21- interface RoundType {
22- round : string ;
23- checked : boolean ;
24- score : number ;
25- judge : string ;
26- }
2721
2822const ProjectReviewPage = ( { id } : Props ) => {
2923 const { data : session } = useSession ( ) ;
3024
3125 const router = useRouter ( ) ;
32- // ROUND PASSING LOGIC
33- const [ rounds , setRounds ] = useState < RoundType [ ] > ( [
34- { round : 'Round 1' , checked : false , score : 0 , judge : '' } ,
35- { round : 'Round 2' , checked : false , score : 0 , judge : '' } ,
36- { round : 'Round 3' , checked : false , score : 0 , judge : '' } ,
37- ] ) ;
3826
39- const handleCheckboxChange = ( index : number ) => {
40- const updatedRounds = rounds . map ( ( round , roundIndex ) => {
41- if ( roundIndex < index ) {
42- return {
43- ...round ,
44- checked : true ,
45- } ;
46- } else if ( roundIndex === index ) {
47- return {
48- ...round ,
49- checked : ! round . checked ,
50- } ;
51- } else {
52- return {
53- ...round ,
54- checked : false ,
55- } ;
56- }
57- } ) ;
58- setRounds ( updatedRounds ) ;
59- } ;
27+ const [ comment , setComment ] = useState ( '' ) ;
28+
29+ const [ score , setScore ] = useState ( 0 ) ;
6030
6131 const SaveRoundChangesHandler = async ( ) => {
32+ if ( score > 10 ) Toaster . error ( 'Score cannot be more than 10' ) ;
6233 let formData = { } ;
63- if ( CURRENT_ROUND === 1 ) {
34+
35+ if ( CURRENT_ROUND === 1 )
6436 formData = {
65- round1Score : rounds [ 0 ] . score ,
37+ round1Score : score ,
38+ round1Comment : comment ,
6639 round1Judge : session ?. user . name ,
6740 } ;
68- } else if ( CURRENT_ROUND === 2 ) {
41+ else if ( CURRENT_ROUND === 2 )
6942 formData = {
70- round2Score : rounds [ 1 ] . score ,
43+ round2Score : score ,
44+ round2Comment : comment ,
7145 round2Judge : session ?. user . name ,
7246 } ;
73- } else if ( CURRENT_ROUND === 3 ) {
47+ else if ( CURRENT_ROUND === 3 )
7448 formData = {
75- round3Score : rounds [ 2 ] . score ,
49+ round3Score : score ,
50+ round3Comment : comment ,
7651 round3Judge : session ?. user . name ,
7752 } ;
78- }
7953
80- const data = await patchHandler (
81- `${ process . env . NEXT_PUBLIC_BASE_URL } /api/admin/submission/${ id } ` ,
82- formData
83- ) ;
84- } ;
54+ console . log ( formData ) ;
8555
86- const handleScoreChange = ( index : number , value : number ) => {
87- const updatedRounds = rounds . map ( ( round , roundIndex ) => {
88- if ( roundIndex === index ) {
89- return {
90- ...round ,
91- score : value ,
92- } ;
93- }
94- return round ;
95- } ) ;
96- setRounds ( updatedRounds ) ;
56+ // const data = await patchHandler(
57+ // `${process.env.NEXT_PUBLIC_BASE_URL}/api/admin/submission/${id}`,
58+ // formData
59+ // );
9760 } ;
9861
9962 // FETCHING TEAM / PROJECT LOGIC
@@ -104,10 +67,6 @@ const ProjectReviewPage = ({ id }: Props) => {
10467 submission : new mongoose . Schema . Types . ObjectId ( '' ) ,
10568 } ) ;
10669 const [ loading , setLoading ] = useState ( true ) ;
107- const [ changeTitle , setChangeTitle ] = useState ( false ) ;
108- const [ newTitle , setNewTitle ] = useState ( '' ) ;
109- const [ isSubmission , setIsSubmission ] = useState ( false ) ;
110- const [ toggleEdit , setToggleEdit ] = useState ( 0 ) ;
11170
11271 useEffect ( ( ) => {
11372 getHandler ( `${ process . env . NEXT_PUBLIC_BASE_URL } /api/admin/team/${ id } ` )
@@ -121,6 +80,7 @@ const ProjectReviewPage = ({ id }: Props) => {
12180 console . log ( err ) ;
12281 } ) ;
12382 } , [ ] ) ;
83+
12484 return (
12585 < >
12686 < Header />
@@ -190,42 +150,87 @@ const ProjectReviewPage = ({ id }: Props) => {
190150 </ div >
191151 </ div >
192152 { teamDetails . submission ? (
193- < div className = "flex md:flex-col gap-4 max-md:w-full max-md:justify-between pt-6" >
194- { rounds . map ( ( round , index ) => (
195- < >
196- < div
197- key = { index }
198- className = "text-xl py-1 flex justify-start items-center gap-x-2 font-spaceGrotesk"
199- >
200- { round . round }
201- < label className = "ml-2" >
202- < input
203- type = "checkbox"
204- checked = { round . checked }
205- onChange = { ( ) =>
206- handleCheckboxChange (
207- index
208- )
209- }
210- />
211- Checked
212- </ label >
213- < div > - Score : </ div >
214- < InputField
215- label = ""
216- value = { round . score . toString ( ) }
217- type = "number"
218- canEdit = { true }
219- onChange = { ( value ) =>
220- handleScoreChange (
221- index ,
222- Number ( value )
223- )
224- }
225- />
226- </ div >
227- </ >
228- ) ) }
153+ < div className = "flex flex-col gap-4 max-md:w-full max-md:justify-between pt-6" >
154+ < div className = "w-full flex flex-col pr-20 gap-12 max-md:pr-2" >
155+ { CURRENT_ROUND === 1 ? (
156+ < CommentEdit
157+ score = { score }
158+ setScore = { setScore }
159+ comment = { comment }
160+ setComment = { setComment }
161+ />
162+ ) : (
163+ < >
164+ { CURRENT_ROUND === 2 ? (
165+ < >
166+ < CommentView
167+ roundNumber = { 1 }
168+ score = { 9 }
169+ judge = { 'someone' }
170+ comment = {
171+ 'iawjdhuihwaduahi'
172+ }
173+ />
174+ < CommentEdit
175+ score = { score }
176+ setScore = { setScore }
177+ comment = { comment }
178+ setComment = {
179+ setComment
180+ }
181+ />
182+ </ >
183+ ) : (
184+ < >
185+ { CURRENT_ROUND === 3 ? (
186+ < >
187+ < CommentView
188+ roundNumber = {
189+ 1
190+ }
191+ score = { 9 }
192+ judge = {
193+ 'someone'
194+ }
195+ comment = {
196+ 'iawjdhuihwaduahi'
197+ }
198+ />
199+ < CommentView
200+ roundNumber = {
201+ 1
202+ }
203+ score = { 9 }
204+ judge = {
205+ 'someone'
206+ }
207+ comment = {
208+ 'iawjdhuihwaduahi'
209+ }
210+ />
211+ < CommentEdit
212+ score = {
213+ score
214+ }
215+ setScore = {
216+ setScore
217+ }
218+ comment = {
219+ comment
220+ }
221+ setComment = {
222+ setComment
223+ }
224+ />
225+ </ >
226+ ) : (
227+ < > </ >
228+ ) }
229+ </ >
230+ ) }
231+ </ >
232+ ) }
233+ </ div >
229234 < div
230235 onClick = { ( ) => {
231236 SaveRoundChangesHandler ( ) ;
@@ -251,18 +256,9 @@ const ProjectReviewPage = ({ id }: Props) => {
251256 { /* STRONGLY SUGGESTED MAKE NEW DUPLICATE 2 COMPONENTS BELOW JUST FOR ADMIN PANEL SOLO PROJECT VIEW PAGE CUZ IT WILL HAVE A NEW CHECK KI EVEN SUPER USER CAN VIEW ALL */ }
252257
253258 < div className = "w-full lg:w-[50%] h-full" >
254- { /* {toggleEdit === 0 ? (
255- <ViewSubmission
256- id={id}
257- toggleEdit={setToggleEdit}
258- />
259- ) : (
260- <EditSubmission id={id} />
261- )} */ }
262259 { teamDetails . submission ? (
263260 < ViewSubmission
264261 id = { teamDetails . submission . _id }
265- toggleEdit = { setToggleEdit }
266262 />
267263 ) : (
268264 < > </ >
0 commit comments