import React, { useState } from "react"; import { usePendingUsers } from "@/user-management/userManagement/hooks/usePendingUsersHook"; import { toast } from "sonner"; import { Check, X, Users, Search, RefreshCw } from "lucide-react"; import { useTranslation } from "react-i18next"; import { useErrorHandler } from "@/shared/hooks/useErrorHandler"; const ReviewAllPendingUsers = () => { const { t } = useTranslation(); const { handleError } = useErrorHandler(t); const [searchTerm, setSearchTerm] = useState(""); const { pendingUsers, loadingPendingUsers, approveMutation, rejectMutation } = usePendingUsers({ take: 50, skip: 0 }); const handleApprove = (id: string) => { approveMutation.mutate(id, { onSuccess: () => toast.success(t("pendingUsers.employeeApprovedSuccess")), onError: (error) => handleError(error), }); }; const handleReject = (id: string) => { rejectMutation.mutate(id, { onSuccess: () => toast.success(t("pendingUsers.employeeRejectedSuccess")), onError: (error) => handleError(error), }); }; const handleSearch = (e: React.FormEvent) => { e.preventDefault(); // Integrate search with your API if needed }; // Loading skeleton (full width) if (loadingPendingUsers) { return (
| {h} | ))}|||
|---|---|---|---|
|
|
{t("pendingUsers.allRequestsReviewed")}
| {t("pendingUsers.name")} | {t("pendingUsers.email")} | {t("pendingUsers.positions")} | {t("pendingUsers.actions")} |
|---|---|---|---|
| {emp.name?.en} | {emp.user?.email} | {emp.employeePositions ?.map((pos: any) => pos.position?.name?.en) .join(", ") || "—"} |
|
{t("pendingUsers.showingUpTo")}