@@ -27,7 +27,10 @@ const PlacementStudent = () => {
2727 localStorage . removeItem ( 'token' ) ;
2828 navigate ( '/placement-login' ) ;
2929 } ;
30-
30+ const getFileNameFromPath = path => {
31+ const parts = path . split ( '/' ) ;
32+ return parts [ parts . length - 1 ] ;
33+ } ;
3134 useEffect ( ( ) => {
3235 const fetchAnnouncements = async ( ) => {
3336 try {
@@ -43,6 +46,35 @@ const PlacementStudent = () => {
4346 fetchAnnouncements ( ) ;
4447 } , [ ] ) ;
4548
49+ const [ selectedAnnouncement , setSelectedAnnouncement ] = useState ( null ) ;
50+ const [ isModalOpen , setIsModalOpen ] = useState ( false ) ;
51+
52+ const AnnouncementModal = ( { announcement, onClose } ) => (
53+ < div className = "fixed inset-0 flex items-center justify-center bg-gray-800 bg-opacity-50" >
54+ < div className = "bg-white p-8 max-w-md rounded-lg" >
55+ < h2 className = "text-xl font-semibold mb-4" > { announcement . title } </ h2 >
56+ < p className = "mb-4" > { announcement . desc } </ p >
57+ < p > Document Attached: </ p >
58+ < >
59+ { announcement . docs ? (
60+ < a
61+ href = { announcement . docs }
62+ target = "_blank"
63+ rel = "noopener noreferrer"
64+ className = "text-blue-500 underline hover:text-blue-700"
65+ >
66+ { getFileNameFromPath ( announcement . docs ) }
67+ </ a >
68+ ) : (
69+ < span > Not Available</ span >
70+ ) }
71+ </ >
72+ < br />
73+ < button className = "py-2 px-4 bg-blue-500 text-white rounded hover:bg-blue-600" onClick = { onClose } > Close</ button >
74+ </ div >
75+ </ div >
76+ ) ;
77+
4678 useEffect ( ( ) => {
4779 const timer = setTimeout ( ( ) => {
4880 setIsLoading ( false ) ;
@@ -67,8 +99,8 @@ const PlacementStudent = () => {
6799 < div className = 'bg-slate-300 h-[100%]' >
68100 < div className = "p-5 w-[90%] m-auto" >
69101 < div className = "mb-8 inline-block" >
70- < Link to = { '/placement-student ' } onClick = { ( ) => setSelectedComponent ( null ) } >
71- < h1 className = "text-xl hover:bg-gray-100 text-blue-900 w-fit p-2 rounded font-semibold bg-gray-200" > Placements Dashboard</ h1 >
102+ < Link to = { '/dashboard ' } onClick = { ( ) => setSelectedComponent ( null ) } >
103+ < h1 className = "text-xl hover:bg-gray-100 text-blue-900 w-fit p-2 rounded font-semibold bg-gray-200" > Dashboard</ h1 >
72104 </ Link >
73105 </ div >
74106 { isLoading ? (
@@ -78,17 +110,18 @@ const PlacementStudent = () => {
78110 < div >
79111 < div className = "bg-gray-200 p-4" >
80112 < ul >
113+ < li className = 'mb-2 ' > </ li >
81114 < li className = "mb-2" >
82- < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'AllPlacements' ) } > All Placements </ button >
115+ < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100 mx-auto " onClick = { ( ) => setSelectedComponent ( 'AllPlacements' ) } > Explore </ button >
83116 </ li >
84117 < li className = "mb-2" >
85- < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'ActivePlacements' ) } > Active Placements </ button >
118+ < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'ActivePlacements' ) } > Active Opportunities </ button >
86119 </ li >
87120 < li className = "mb-2" >
88- < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'PastPlacements' ) } > Past Placements </ button >
121+ < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'PastPlacements' ) } > Past openings </ button >
89122 </ li >
90123 < li className = "mb-2" >
91- < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'AnnouncementsPlacements' ) } > View All Announcements</ button >
124+ < button className = "block py-2 px-4 text-blue-900 font-semibold rounded hover:bg-gray-100" onClick = { ( ) => setSelectedComponent ( 'AnnouncementsPlacements' ) } > Announcements</ button >
92125 </ li >
93126 </ ul >
94127 </ div >
@@ -102,17 +135,25 @@ const PlacementStudent = () => {
102135 </ div >
103136 { selectedComponent !== 'AnnouncementsPlacements' && (
104137 < div className = "w-96 bg-gray-200 p-4 relative" >
105- < h2 className = "text-2xl font-bold mb-6" > Announcements</ h2 >
138+ < h2 className = "text-2xl font-semibold mb-6" > Announcements</ h2 >
106139 { announcements && announcements . length > 0 ? (
107140 announcements . map ( ( announcement ) => (
108- < div key = { announcement . id } >
109- < h3 className = "text-lg font-semibold" > { announcement . title } </ h3 >
141+ < div key = { announcement . id } onClick = { ( ) => {
142+ setSelectedAnnouncement ( announcement ) ;
143+ setIsModalOpen ( true ) ;
144+ } } >
145+ < h3 className = "text-lg font-semibold cursor-pointer hover:underline" > { announcement . title } </ h3 >
110146 < hr className = "my-2 border-gray-400" />
111147 </ div >
112148 ) )
149+
113150 ) : (
114151 < p > No announcements available.</ p >
115152 ) }
153+ { isModalOpen && selectedAnnouncement && (
154+ < AnnouncementModal announcement = { selectedAnnouncement } onClose = { ( ) => setIsModalOpen ( false ) } />
155+ ) }
156+
116157 < div className = "absolute inset-x-0 bottom-0 flex justify-end mb-1" >
117158 < button className = "py-2 px-4 text-blue-900 hover:underline font-semibold" onClick = { ( ) => setSelectedComponent ( 'AnnouncementsPlacements' ) } > View All...</ button >
118159 </ div >
0 commit comments