added edit and delete who can perform action
This commit is contained in:
parent
e2d45e54a0
commit
3464b63588
@ -4,24 +4,27 @@ import Avatar from "../common/Avatar";
|
||||
import { useExpenseContext } from "../../pages/Expense/ExpensePage";
|
||||
import { formatDate, formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||
import Pagination from "../common/Pagination";
|
||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
import { APPROVE_EXPENSE, ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
import { AppColorconfig, getColorNameFromHex } from "../../utils/appUtils";
|
||||
import { ExpenseTableSkeleton } from "./ExpenseSkeleton";
|
||||
import ConfirmModal from "../common/ConfirmModal";
|
||||
import { useProfile } from "../../hooks/useProfile";
|
||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||
import { useSelector } from "react-redux";
|
||||
|
||||
const ExpenseList = ({filters}) => {
|
||||
const [deletingId, setDeletingId] = useState(null);
|
||||
const [IsDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
|
||||
const { setViewExpense, setManageExpenseModal } = useExpenseContext();
|
||||
const IsExpenseEditable = useHasUserPermission()
|
||||
const IsExpesneApprpve = useHasUserPermission(APPROVE_EXPENSE)
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const pageSize = 10;
|
||||
const { profile } = useProfile();
|
||||
|
||||
|
||||
const { mutate: DeleteExpense, isPending } = useDeleteExpense();
|
||||
const { data, isLoading, isError, isInitialLoading, error, isFetching } =
|
||||
useExpenseList(10, currentPage, filters);
|
||||
const SelfId = useSelector((store)=>store?.globalVariables?.loginUser?.employeeInfo?.id)
|
||||
|
||||
const handleDelete = (id) => {
|
||||
setDeletingId(id);
|
||||
@ -260,7 +263,7 @@ const ExpenseList = ({filters}) => {
|
||||
{(expense.status.name === "Draft" ||
|
||||
expense.status.name === "Rejected") &&
|
||||
expense.createdBy.id ===
|
||||
profile?.employeeInfo.id ? (
|
||||
SelfId ? (
|
||||
<i
|
||||
className="bx bx-edit bx-sm text-secondary"
|
||||
onClick={() =>
|
||||
@ -279,7 +282,7 @@ const ExpenseList = ({filters}) => {
|
||||
</span>
|
||||
|
||||
<span className="cursor-pointer">
|
||||
{expense.status.name === "Draft" ? (
|
||||
{(expense.status.name === "Draft" && expense?.createdBy?.id === SelfId ) ? (
|
||||
<i
|
||||
className="bx bx-trash bx-sm text-danger"
|
||||
onClick={() => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user