Skip to content

Commit 52435b7

Browse files
committed
fixed all pors
1 parent 22e07ca commit 52435b7

5 files changed

Lines changed: 20 additions & 93 deletions

File tree

frontend/src/Components/ManagePosition.jsx

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import api from "../utils/api";
1212
import { AdminContext } from "../context/AdminContext";
1313
import AddPositionHolder from "./AddPositionHolder";
14+
import ViewPositionHolder from "./Positions/ViewPositionHolder";
1415

1516
const ManagePositions = () => {
1617
const { isUserLoggedIn } = React.useContext(AdminContext);
@@ -128,17 +129,10 @@ const ManagePositions = () => {
128129
</div>
129130
</div>
130131
</div>
131-
{/* Gray horizontal line separator */}
132-
{/* <button
133-
onClick={() => setShowAddModal(true)}
134-
className="flex items-center gap-2 bg-black text-white text-sm px-4 py-2 rounded-lg hover:bg-[#856A5D] transition-colors"
135-
>
136-
<Plus className="w-4 h-4" /> Add Position
137-
</button> */}
138132
<div className="w-full h-[2px] bg-gray-300"></div>
139133
</div>
140-
141-
{/* Filters */}
134+
<ViewPositionHolder />
135+
{/*
142136
<div className="">
143137
<div className="flex flex lg:flex-row gap-4 pb-2">
144138
<div className="flex-1 relative round-xl">
@@ -183,7 +177,6 @@ const ManagePositions = () => {
183177
</div>
184178
</div>
185179
186-
{/* Positions Grid */}
187180
{filteredPositions.length === 0 ? (
188181
<div className="bg-white rounded-lg p-12 text-center">
189182
<UserCheck className="w-12 h-12 text-black mx-auto mb-4" />
@@ -245,24 +238,6 @@ const ManagePositions = () => {
245238
</div>
246239
</div>
247240
248-
{/* <div className="p-4 bg-[#F5F1EC] flex justify-around text-center">
249-
<div>
250-
<span className="text-xs text-black">Events</span>
251-
<p className="text-lg font-bold text-black">
252-
{position.performance_metrics?.events_organized || 0}
253-
</p>
254-
</div>
255-
<div className="border-l border-black h-8"></div>
256-
<div>
257-
<span className="text-xs text-black">Budget</span>
258-
<p className="text-sm font-bold text-black">
259-
{formatCurrency(
260-
position.performance_metrics?.budget_utilized
261-
)}
262-
</p>
263-
</div>
264-
</div> */}
265-
266241
<div className="px-4 py-2 border-t border-black text-xs text-black flex justify-between">
267242
<span>Created: {formatDate(position.created_at)}</span>
268243
{position.updated_at !== position.created_at && (
@@ -272,10 +247,10 @@ const ManagePositions = () => {
272247
</div>
273248
))}
274249
</div>
275-
)}
250+
)} */}
276251
</div>
277252

278-
{showAddModal && (
253+
{/* {showAddModal && (
279254
<div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
280255
<div className="relative w-full max-w-2xl bg-white rounded-xl shadow-lg p-6">
281256
<button
@@ -287,7 +262,7 @@ const ManagePositions = () => {
287262
<AddPositionHolder onClose={() => setShowAddModal(false)} />
288263
</div>
289264
</div>
290-
)}
265+
)} */}
291266
</div>
292267
);
293268
};

frontend/src/Components/Positions/PORs.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useContext } from "react";
22
import { AdminContext } from "../../context/AdminContext";
33
import { CreateTenure, TenureRecords, ViewTenure } from "./TenureRecords";
44
import ManagePositions from "../ManagePosition";
5+
import ViewPositionHolder from "./ViewPositionHolder";
56

67
const PORs = () => {
78
const { isUserLoggedIn } = useContext(AdminContext);

frontend/src/Components/Positions/ViewPositionHolder.jsx

Lines changed: 4 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,18 @@ const ViewPositionHolder = () => {
8585
};
8686

8787
return (
88-
<div className="min-h-screen bg-white px-4">
89-
<div className="max-w-7xl mx-auto">
88+
<div className="min-h-screen bg-white">
89+
<div className="max-w-7xl">
9090
{/* Header with Search and Filters */}
9191
<div className="bg-white rounded-lg mb-6">
9292
<div className="space-y-4">
93-
<div className="flex :flex-row gap-4">
93+
<div className="flex :flex-row gap-2">
9494
<SearchInput
9595
value={searchTerm}
9696
onChange={setSearchTerm}
9797
placeholder="Search by name, email, ID, position, or POR ID..."
9898
/>
99-
<div className="flex flex-wrap gap-3">
99+
<div className="flex flex-wrap gap-2">
100100
<select
101101
value={selectedStatus}
102102
onChange={(e) => setSelectedStatus(e.target.value)}
@@ -153,61 +153,6 @@ const ViewPositionHolder = () => {
153153
onEdit={() => handleEdit(holder)}
154154
onDelete={() => handleDelete(holder)}
155155
/>
156-
// <div
157-
// key={holder._id}
158-
// className="bg-white rounded-lg border-2 border-black hover:shadow-md transition-shadow flex flex-col"
159-
// >
160-
// <div className="p-4 flex-grow">
161-
// <div className="flex items-start justify-between mb-3">
162-
// <div className="flex-1">
163-
// <h3 className="font-semibold text-black text-lg">
164-
// {holder.user_id?.personal_info?.name || "N/A"}
165-
// </h3>
166-
// <p className="text-sm text-black truncate">
167-
// {holder.user_id?.user_id || "N/A"} •{" "}
168-
// {holder.user_id?.username || "N/A"}
169-
// </p>
170-
// </div>
171-
// <span
172-
// className={`px-2 py-1 ml-2 rounded-full text-xs font-medium flex-shrink-0 flex items-center gap-1 ${getStatusColor(holder.status)}`}
173-
// >
174-
// {getStatusIcon(holder.status)}
175-
// {holder.status?.charAt(0).toUpperCase() +
176-
// holder.status?.slice(1)}
177-
// </span>
178-
// </div>
179-
// <div>
180-
// <p className="font-medium text-black">
181-
// {holder.position_id?.title || "Unknown Position"}
182-
// </p>
183-
// <p className="text-sm text-black">
184-
// {holder.position_id?.unit_id?.name || "Unknown Dept"}
185-
// </p>
186-
// </div>
187-
// </div>
188-
// <div className="p-4 border-t border-[#DCD3C9]">
189-
// <div className="flex gap-2">
190-
// <button
191-
// onClick={() => handleViewDetails(holder)}
192-
// className="flex-1 px-3 py-2 bg-black text-white text-sm rounded-lg hover:bg-[#856A5D] transition-colors flex items-center justify-center gap-1"
193-
// >
194-
// <Eye className="w-4 h-4" /> View
195-
// </button>
196-
// <button
197-
// onClick={() => handleEdit(holder)}
198-
// className="px-3 py-2 bg-[#F5F1EC] text-black text-sm rounded-lg hover:bg-[#EAE0D5] transition-colors"
199-
// >
200-
// <Edit className="w-4 h-4" />
201-
// </button>
202-
// <button
203-
// onClick={() => handleDelete(holder)}
204-
// className="px-3 py-2 bg-red-100 text-red-700 text-sm rounded-lg hover:bg-red-200 transition-colors"
205-
// >
206-
// <Trash2 className="w-4 h-4" />
207-
// </button>
208-
// </div>
209-
// </div>
210-
// </div>
211156
))}
212157
</div>
213158

frontend/src/Components/common/InfoCard.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export const InfoCard = ({
1717
<div className="bg-[#FDFAE2] rounded-xl px-6 py-6">
1818
<div className="mb-2">
1919
<div className="flex justify-between items-start gap-4">
20-
<div className="text-2xl font-bold text-black">{title}</div>
20+
<div className="text-xl font-bold text-black truncate">{title}</div>
2121
<span
22-
className={`p-2 ${badgeColor} text-xs rounded-full font-medium shadow-sm`}
22+
className={`p-2 ${badgeColor} text-xs rounded-full font-medium shadow-sm truncate`}
2323
>
2424
{badgeText}
2525
</span>

frontend/src/hooks/usePositionHolders.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useState, useEffect, useRef, useContext } from "react";
22
import { useNavigate } from "react-router-dom";
33
import api from "../utils/api";
44
import { useProfile } from "./useProfile";
5+
import { AdminContext } from "../context/AdminContext";
56

67
// Hook for managing position holder form logic
78
export const usePositionHolderForm = (currentUser) => {
@@ -118,6 +119,8 @@ export const usePositionHolderForm = (currentUser) => {
118119

119120
// Hook for viewing position holders
120121
export const usePositionHolders = () => {
122+
const { isUserLoggedIn } = useContext(AdminContext);
123+
const userRole = isUserLoggedIn?.role || "STUDENT";
121124
const { profile } = useProfile();
122125

123126
const [positionHolders, setPositionHolders] = useState([]);
@@ -145,7 +148,10 @@ export const usePositionHolders = () => {
145148
useEffect(() => {
146149
let filtered = positionHolders;
147150
filtered = filtered.filter(
148-
(holder) => holder.position_id?.unit_id?.name === profile?.personal_info.name
151+
(holder) =>
152+
(userRole !== "STUDENT"
153+
? holder.position_id?.unit_id?.name
154+
: holder.user_id?.personal_info?.name) === profile?.personal_info.name
149155
);
150156

151157
if (searchTerm) {

0 commit comments

Comments
 (0)