display all timeline logs inside expense
This commit is contained in:
parent
bb1fb2a696
commit
8f83d91d25
@ -5,7 +5,7 @@ import Timeline from "../common/TimeLine";
|
|||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { getColorNameFromHex } from "../../utils/appUtils";
|
import { getColorNameFromHex } from "../../utils/appUtils";
|
||||||
const ExpenseStatusLogs = ({ data }) => {
|
const ExpenseStatusLogs = ({ data }) => {
|
||||||
const [visibleCount, setVisibleCount] = useState(4);
|
|
||||||
|
|
||||||
const sortedLogs = useMemo(() => {
|
const sortedLogs = useMemo(() => {
|
||||||
if (!data?.expenseLogs) return [];
|
if (!data?.expenseLogs) return [];
|
||||||
@ -14,13 +14,8 @@ const ExpenseStatusLogs = ({ data }) => {
|
|||||||
);
|
);
|
||||||
}, [data?.expenseLogs]);
|
}, [data?.expenseLogs]);
|
||||||
|
|
||||||
const logsToShow = useMemo(
|
|
||||||
() => sortedLogs.slice(0, visibleCount),
|
|
||||||
[sortedLogs, visibleCount]
|
|
||||||
);
|
|
||||||
console.log(logsToShow);
|
|
||||||
const timelineData = useMemo(() => {
|
const timelineData = useMemo(() => {
|
||||||
return logsToShow.map((log, index) => ({
|
return sortedLogs.map((log, index) => ({
|
||||||
id: index + 1,
|
id: index + 1,
|
||||||
title: log.action || "Status Updated",
|
title: log.action || "Status Updated",
|
||||||
description: log.comment || "",
|
description: log.comment || "",
|
||||||
@ -37,7 +32,7 @@ const ExpenseStatusLogs = ({ data }) => {
|
|||||||
]
|
]
|
||||||
: [],
|
: [],
|
||||||
}));
|
}));
|
||||||
}, [logsToShow]);
|
}, [sortedLogs]);
|
||||||
|
|
||||||
const handleShowMore = () => {
|
const handleShowMore = () => {
|
||||||
setVisibleCount((prev) => prev + 4);
|
setVisibleCount((prev) => prev + 4);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user