Skip to content

Commit

Permalink
refactor: Improve EventGrid component by adding visibility toggle and…
Browse files Browse the repository at this point in the history
… logging
  • Loading branch information
Aloento committed Oct 29, 2024
1 parent 0667221 commit a72e7e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
12 changes: 6 additions & 6 deletions .env
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# SD_BACKEND_URL="http://localhost:9000"
# SD_BACKEND_API="/api/v1"
# SD_BACKEND_V2=false
SD_BACKEND_URL="http://localhost:9000"
SD_BACKEND_API="/api/v1"
SD_BACKEND_V2=false

SD_BACKEND_URL="http://80.158.108.251:8000"
SD_BACKEND_API="/v2"
SD_BACKEND_V2=true
# SD_BACKEND_URL="http://80.158.108.251:8000"
# SD_BACKEND_API="/v2"
# SD_BACKEND_V2=true

# only for development
SD_BACKEND_FILE=false
15 changes: 10 additions & 5 deletions src/Components/Home/EventGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { ScaleDataGrid } from "@telekom/scale-components-react";
import { useCreation } from "ahooks";
import { useBoolean, useCreation } from "ahooks";
import dayjs from "dayjs";
import { chain } from "lodash";
import { useEffect, useRef } from "react";
import { Logger } from "~/Helpers/Logger";
import { useStatus } from "~/Services/Status";
import { EventStatus, EventType } from "../Event/Enums";

const log = new Logger("Home", "EventGrid");

/**
* @author Aloento
* @since 1.0.0
Expand All @@ -14,6 +17,7 @@ import { EventStatus, EventType } from "../Event/Enums";
export function EventGrid() {
const { DB } = useStatus();
const ref = useRef<HTMLScaleDataGridElement>(null);
const [hidden, { set }] = useBoolean();

const observer = useCreation(() => {
return new MutationObserver((mutationsList) => {
Expand Down Expand Up @@ -133,13 +137,14 @@ export function EventGrid() {
})
.value();

set(!events.length);
grid.rows = events;

if (!events.length) {
grid.style.display = "none";
}
}, [ref.current, DB]);

if (hidden) {
return null;
}

return (
<ScaleDataGrid
className="rounded-lg bg-white shadow-md"
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function Home() {
.uniqBy(s => s.Id)
.value();

log.debug(service);
log.debug("Abnormal Services", service);
return service.length;
}, [DB]);

Expand Down

0 comments on commit a72e7e4

Please sign in to comment.