Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion backend/controllers/userController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ export const getUsers = async (req: Request, res: Response): Promise<void> => {
const users = await User.find(query)
.skip(skip)
.limit(Number(limit))
.select("name email userType company");
.select(
"name email role company certification address1 city state zip phone language certification"
);

const total = await User.countDocuments(query);

Expand Down
2 changes: 1 addition & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 40 additions & 18 deletions frontend/src/pages/Admin/UserManagementPage/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface User {
timezone?: string;
language: "English" | "Spanish";
selected?: boolean;
certification?: string;
}

interface UserForm {
Expand All @@ -56,6 +57,7 @@ interface UserForm {
userType: string;
timezone: string;
language: "English" | "Spanish";
certification?: string;
}

interface SpeakerProduct {
Expand Down Expand Up @@ -113,6 +115,7 @@ const UserManagementPage: React.FC = () => {
userType: "",
timezone: "",
language: "English",
certification: "",
});
const [editingUserId, setEditingUserId] = useState<string | null>(null);
const [currentSpeaker, setCurrentSpeaker] = useState<User | null>(null);
Expand All @@ -139,24 +142,32 @@ const UserManagementPage: React.FC = () => {

const response = await apiClient.get(`/users?${params.toString()}`);

const mappedUsers = response.data.users.map((user: any) => ({
_id: user._id,
id: user._id,
firstName: user.name?.split(" ")[0] || "",
lastName: user.name?.split(" ")[1] || "",
name: user.name,
email: user.email,
userType: user.userType || "",
company: user.company || "",
addressLine: user.address1 || "",
city: user.city || "",
stateProvinceRegion: user.state || "",
zipPostalCode: user.zip || "",
country: user.country || "",
phoneNumber: user.phone || "",
language: user.language || "English",
selected: false,
}));
console.log("Raw API response:", response.data.users);

const mappedUsers = response.data.users.map((user: any) => {
console.log("Individual user data:", user);
const mappedUser = {
_id: user._id,
id: user._id,
firstName: user.name?.split(" ")[0] || "",
lastName: user.name?.split(" ")[1] || "",
name: user.name,
email: user.email,
userType: user.role || user.userType || "",
company: user.company || "",
addressLine: user.address1 || "",
city: user.city || "",
stateProvinceRegion: user.state || "",
zipPostalCode: user.zip || "",
country: user.country || "",
phoneNumber: user.phone || "",
language: user.language || "English",
certification: user.certification || "",
selected: false,
};
console.log("Mapped user:", mappedUser);
return mappedUser;
});

setUsers(mappedUsers);
setTotalUsers(response.data.total);
Expand Down Expand Up @@ -199,6 +210,7 @@ const UserManagementPage: React.FC = () => {
country: userData.country,
phone: userData.phoneNumber,
language: userData.language,
certification: userData.certification,
};
};

Expand Down Expand Up @@ -229,6 +241,7 @@ const UserManagementPage: React.FC = () => {
country: userForm.country,
phoneNumber: userForm.phoneNumber,
language: userForm.language,
certification: userForm.certification,
}
: user
)
Expand Down Expand Up @@ -256,6 +269,7 @@ const UserManagementPage: React.FC = () => {
country: userForm.country,
phoneNumber: userForm.phoneNumber,
language: userForm.language,
certification: userForm.certification,
selected: false,
};

Expand Down Expand Up @@ -286,6 +300,7 @@ const UserManagementPage: React.FC = () => {
userType: "",
timezone: "",
language: "English",
certification: "",
});
};

Expand All @@ -304,6 +319,7 @@ const UserManagementPage: React.FC = () => {
userType: user.userType,
timezone: user.timezone || "",
language: user.language || "English",
certification: user.certification || "",
});
setEditingUserId(user._id || null);
setIsUserModalOpen(true);
Expand Down Expand Up @@ -506,6 +522,9 @@ const UserManagementPage: React.FC = () => {
<th className="px-6 py-3 text-left text-sm font-semibold text-gray-600">
Language
</th>
<th className="px-6 py-3 text-left text-sm font-semibold text-gray-600">
Certified Through
</th>
<th className="px-6 py-3 text-left text-sm font-semibold text-gray-600">
Actions
</th>
Expand Down Expand Up @@ -556,6 +575,9 @@ const UserManagementPage: React.FC = () => {
{user.language}
</span>
</td>
<td className="px-6 py-4 text-sm text-gray-900">
{user.certification}
</td>
<td className="px-6 py-4 text-sm">
<div className="flex gap-3">
<Tooltip text="Edit">
Expand Down
205 changes: 205 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.