+
Agreement ID:
+
+
-
+
+ >
) : null}
>
);
};
-export const EventCard = (event: EventType) => {
+export const EventCard = (
+ event: EventType & {
+ isExpanded: boolean;
+ toggleExpanded: () => void;
+ }
+) => {
return (
{(() => {
switch (event.kind) {
case Event.ALLOCATION_CREATED:
- return ;
+ return (
+ }
+ />
+ );
case Event.ALLOCATION_RELEASED:
- return ;
+ return (
+ }
+ />
+ );
case Event.DEPOSIT_CREATED:
- return ;
+ return (
+ }
+ />
+ );
case Event.DEPOSIT_EXTENDED:
- return ;
+ return (
+ }
+ />
+ );
case Event.AGREEMENT_SIGNED:
- return ;
+ return (
+ }
+ />
+ );
case Event.AGREEMENT_TERMINATED:
- return ;
+ return (
+ }
+ />
+ );
case Event.NEW_INVOICE:
- return ;
+ return (
+ }
+ />
+ );
case Event.DEPOSIT_FEE_PAYMENT:
- return ;
+ return (
+ }
+ />
+ );
case Event.DEPOSIT_PROVIDER_PAYMENT:
- return ;
+ return (
+ }
+ />
+ );
case Event.FILE_SCAN_ERROR:
- return ;
+ return (
+ }
+ />
+ );
case Event.FILE_SCAN_OK:
- return ;
+ return (
+ }
+ />
+ );
case Event.NEW_DEBIT_NOTE:
- return ;
+ return (
+ }
+ />
+ );
}
})()}
diff --git a/frontend/src/components/homePage/events/events.tsx b/frontend/src/components/homePage/events/events.tsx
index 24ee547..f9cb3e0 100644
--- a/frontend/src/components/homePage/events/events.tsx
+++ b/frontend/src/components/homePage/events/events.tsx
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { EventType } from "types/events";
import { useAllocationEvents } from "hooks/events/useAllocationEvents";
import { EventCard } from "./event";
-import { uniqBy, sortBy, prop } from "ramda";
+import { uniqBy, sortBy, reverse, prop } from "ramda";
import { useDepositEvents } from "hooks/events/useDepositEvents";
import { useYagnaEvents } from "hooks/events/useYagnaEvents";
import { finalize, merge } from "rxjs";
@@ -15,6 +15,8 @@ export const Events = () => {
(EventType & {
id: number;
timestamp: number;
+ isExpanded: boolean;
+ toggleExpanded: () => void;
})[]
>([]);
@@ -58,14 +60,45 @@ export const Events = () => {
}
) => {
setEvents((prevEvents) => {
- return sortBy(prop("timestamp"))(
- uniqBy(
- (e) => {
- return `${e.kind}-${e.id}`;
- },
- [...prevEvents, event]
+ return reverse(
+ sortBy(prop("timestamp"))(
+ uniqBy(
+ (e) => {
+ return `${e.kind}-${e.id}`;
+ },
+ [
+ ...prevEvents.map((e) => {
+ return {
+ ...e,
+ };
+ }),
+ {
+ ...event,
+ isExpanded: true,
+ },
+ ]
+ )
)
- );
+ ).map((e, index) => {
+ return {
+ ...e,
+ isExpanded: index === 0,
+
+ toggleExpanded: () => {
+ setEvents((prevEvents) => {
+ return prevEvents.map((prevEvent) => {
+ return {
+ ...prevEvent,
+ isExpanded:
+ e.id === prevEvent.id
+ ? !prevEvent.isExpanded
+ : prevEvent.isExpanded,
+ };
+ });
+ });
+ },
+ };
+ });
});
}
);
@@ -80,6 +113,7 @@ export const Events = () => {
return (
<>
{events.map((event, index) => {
+ console.log(event.isExpanded);
return
;
})}
>
diff --git a/frontend/src/components/homePage/statusSections/agreement.tsx b/frontend/src/components/homePage/statusSections/agreement.tsx
index ed1bd22..acef17e 100644
--- a/frontend/src/components/homePage/statusSections/agreement.tsx
+++ b/frontend/src/components/homePage/statusSections/agreement.tsx
@@ -20,8 +20,6 @@ export const Agreement = () => {
events$
.pipe(
filter((event: any) => {
- console.log("e,", event);
- console.log("t", user.currentAgreement?.id);
return event.payload.agreementId === user.currentAgreement?.id;
})
)
@@ -29,6 +27,7 @@ export const Agreement = () => {
setTotalAmount(event.payload.totalAmountDue);
});
}, []);
+
return (