11'use client' ;
22
3- import { useState } from 'react' ;
3+ import React , { useState } from 'react' ;
44import { FaBook , FaFlask } from 'react-icons/fa' ;
55import {
66 MdApproval ,
77 MdEmojiEvents ,
88 MdGroups ,
9+ MdOutlineAdd ,
10+ MdOutlineArrowBack ,
11+ MdOutlineEdit ,
912 MdSchool ,
1013 MdWork ,
1114} from 'react-icons/md' ;
@@ -62,13 +65,55 @@ const profileTabs = [
6265 {
6366 label : 'Publications' ,
6467 icon : MdApproval ,
68+ filter : true ,
6569 items : [
6670 {
6771 name : 'Sustainable finishes in textiles, Conference Proceedings' ,
6872 value :
6973 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
7074 caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
7175 year : 'August 2023' ,
76+ tag : 'Conference' ,
77+ } ,
78+ {
79+ name : 'Sustainable finishes in textiles, Conference Proceedings' ,
80+ value :
81+ 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
82+ caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
83+ year : 'August 2023' ,
84+ tag : 'Conference' ,
85+ } ,
86+ {
87+ name : 'Sustainable finishes in textiles, Conference Proceedings' ,
88+ value :
89+ 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
90+ caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
91+ year : 'August 2023' ,
92+ tag : 'Journal' ,
93+ } ,
94+ {
95+ name : 'Sustainable finishes in textiles, Conference Proceedings' ,
96+ value :
97+ 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
98+ caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
99+ year : 'August 2023' ,
100+ tag : 'Journal' ,
101+ } ,
102+ {
103+ name : 'Sustainable finishes in textiles, Conference Proceedings' ,
104+ value :
105+ 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
106+ caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
107+ year : 'August 2023' ,
108+ tag : 'Book/Chapter' ,
109+ } ,
110+ {
111+ name : 'Sustainable finishes in textiles, Conference Proceedings' ,
112+ value :
113+ 'International E-Conference on Sustainable Growth in Textiles (SGT-2021), Uttar Pradesh Textile Technology Institute, Kanpur' ,
114+ caption : 'RK Chhabra, Aakanksha Singh and J N Chakraborty' ,
115+ year : 'August 2023' ,
116+ tag : 'Book/Chapter' ,
72117 } ,
73118 ] ,
74119 } ,
@@ -99,16 +144,29 @@ const profileTabs = [
99144 } ,
100145] ;
101146
102- export default function FacultyDetails ( ) {
147+ export default function FacultyDetails ( { isUser } : { isUser : boolean } ) {
103148 const [ currentTab , setCurrentTab ] = useState ( 0 ) ;
149+ const [ currentFilter , setCurrentFilter ] = useState ( 0 ) ;
150+ const [ editActive , setEditActive ] = useState ( false ) ;
151+
152+ const tags = profileTabs [ currentTab ] . filter
153+ ? [
154+ ...new Set (
155+ profileTabs [ currentTab ] . items . map ( ( item ) =>
156+ 'tag' in item ? item . tag : null
157+ )
158+ ) ,
159+ ]
160+ : [ ] ;
161+
104162 return (
105163 < section className = "mt-[32px] flex w-full gap-[36px]" >
106164 < nav className = "flex w-[491px] flex-col gap-[24px]" >
107165 { profileTabs . map ( ( tab ) => (
108166 < button
109167 key = { tab . label }
110168 className = {
111- 'h-[84px] w-[491px] rounded-2xl border-[1px] border-primary-700 px-[36px] py-[24px] text-left text-xl font-bold hover:bg-primary-700 hover:text-shade-light hover:drop-shadow-2xl ' +
169+ 'h-[84px] w-[491px] rounded-2xl border-[1px] border-primary-700 px-[36px] py-[24px] text-left text-xl font-bold transition-colors hover:bg-primary-700 hover:text-shade-light hover:drop-shadow-2xl ' +
112170 ( currentTab === profileTabs . indexOf ( tab )
113171 ? 'bg-primary-700 text-shade-light'
114172 : 'bg-shade-light text-primary-700' )
@@ -120,17 +178,78 @@ export default function FacultyDetails() {
120178 </ button >
121179 ) ) }
122180 </ nav >
123- < div className = "flex h-[732px] grow flex-col gap-[24px] rounded-2xl bg-shade-light p-[24px] drop-shadow-[0_4px_24px_rgba(0,43,1,0.1)]" >
124- < header className = "flex w-full" >
125- < h4 className = "text-primary-700" > { profileTabs [ currentTab ] . label } </ h4 >
126- { /* TODO: edit button */ }
181+ < div
182+ className = {
183+ 'flex h-[732px] grow flex-col gap-[24px] rounded-2xl border-[1px] py-[24px] drop-shadow-[0_4px_24px_rgba(0,43,1,0.1)] transition-colors ' +
184+ ( editActive
185+ ? 'border-primary-700 bg-neutral-100'
186+ : 'border-shade-light bg-shade-light' )
187+ }
188+ >
189+ < header className = "mx-[24px] flex" >
190+ { editActive && (
191+ < MdOutlineArrowBack
192+ size = { 36 }
193+ onClick = { ( ) => setEditActive ( false ) }
194+ className = "my-auto mr-[16px] cursor-pointer text-primary-700"
195+ />
196+ ) }
197+ < h4 className = "my-auto text-primary-700" >
198+ { editActive ? 'Edit ' : '' }
199+ { profileTabs [ currentTab ] . label }
200+ </ h4 >
201+ { profileTabs [ currentTab ] . filter && (
202+ < ul className = "ml-[20px] mr-auto flex gap-[20px] " >
203+ { tags . map ( ( tag , index ) => (
204+ < li
205+ key = { index }
206+ value = { index + 1 }
207+ className = {
208+ 'my-auto cursor-pointer select-none rounded-s border-[1px] border-primary-700 px-[8px] py-[2px] text-primary-700 transition-colors hover:bg-primary-700 hover:text-shade-light ' +
209+ ( currentFilter === tags . indexOf ( tag )
210+ ? 'bg-primary-700 text-shade-light'
211+ : 'bg-shade-light text-primary-700' )
212+ }
213+ onClick = { ( ) =>
214+ currentFilter !== index
215+ ? setCurrentFilter ( index )
216+ : setCurrentFilter ( 0 )
217+ }
218+ >
219+ < h5 > { tag } </ h5 >
220+ </ li >
221+ ) ) }
222+ </ ul >
223+ ) }
224+ { isUser && (
225+ < button
226+ className = "ml-auto flex gap-2 rounded-s bg-primary-500 px-3 py-2 text-lg font-medium text-shade-light"
227+ onClick = { ( ) => setEditActive ( true ) }
228+ >
229+ { editActive ? (
230+ < >
231+ < MdOutlineAdd size = { 15 } className = "my-auto" /> Add
232+ </ >
233+ ) : (
234+ < >
235+ < MdOutlineEdit size = { 15 } className = "my-auto" /> Edit
236+ </ >
237+ ) }
238+ </ button >
239+ ) }
127240 </ header >
128- < article className = "mb-[12px] mr-[8px] flex h-full w -full flex-col gap-[12px] overflow-auto" >
129- { profileTabs [ currentTab ] . items . map ( ( item ) => (
241+ < article className = "mb-[12px] flex h-full flex-col gap-[12px] overflow-auto" >
242+ { profileTabs [ currentTab ] . items . map ( ( item , index ) => (
130243 < p
131- key = { item . name }
132- className = "flex w-full flex-col gap-3 rounded-xl px-6 py-[20px] shadow-[0px_4px_12px_0px_rgba(0,15,31,0.1)]"
244+ key = { index }
245+ className = "relative ml-[24px] mr-[32px] flex flex -col gap-3 rounded-xl bg-shade-light px-6 py-[20px] shadow-[0px_4px_12px_0px_rgba(0,15,31,0.1)]"
133246 >
247+ { editActive && (
248+ < MdOutlineEdit
249+ size = { 28 }
250+ className = "absolute right-[16px] top-[16px] cursor-pointer text-primary-700"
251+ />
252+ ) }
134253 < span className = "text-[24px] font-bold" > { item . name } </ span >
135254 < span className = "text-[20px]" > { item . value } </ span >
136255 < span className = "text-[20px] text-neutral-600" >
0 commit comments