Skip to content

Commit

Permalink
Small changes for Grant comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hungle-bruinen committed Apr 2, 2024
1 parent b8eca20 commit 3ee3782
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
21 changes: 5 additions & 16 deletions frontend/src/app/databases/databases-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import AddDatabase from "./add-database";
import Loading from "../loading";
import { ErrorDisplay } from "@/components/error-display";
import { useDatabases } from "@/data/use-database";
import { useEffect, useState } from "react";
import { useState } from "react";
import * as _ from "lodash";
import { CleanDatabase } from "@/definitions";

export default function DatabasesList() {
const [isOpen, setIsOpen] = useState<boolean>(false);
Expand All @@ -25,16 +24,6 @@ export default function DatabasesList() {
mutate: mutateDatabases,
} = useDatabases();

const [filteredDatabases, setFilteredDatabases] = useState<CleanDatabase[]>(
[],
);

useEffect(() => {
setFilteredDatabases(
databases?.filter((database) => !database.deleted_at) || [],
);
}, [databases]);

const renderDatabases = () => {
if (isLoadingDatabases) {
return <Loading />;
Expand All @@ -49,7 +38,7 @@ export default function DatabasesList() {
);
}

if (filteredDatabases && filteredDatabases?.length < 1) {
if (databases && databases?.length < 1) {
return (
<NonIdealState
title="No items"
Expand All @@ -60,7 +49,7 @@ export default function DatabasesList() {
action={
<AddDatabase
mutateDatabases={mutateDatabases}
databases={filteredDatabases}
databases={databases}
isOpen={isOpen}
setIsOpen={setIsOpen}
displayButton={true}
Expand All @@ -72,7 +61,7 @@ export default function DatabasesList() {

return (
<CardList bordered className="h-full max-h-full overflow-auto">
{_.map(filteredDatabases, (database: any) => {
{_.map(databases, (database: any) => {
return (
<Card
key={database.id}
Expand Down Expand Up @@ -113,7 +102,7 @@ export default function DatabasesList() {
rightElement={
<AddDatabase
mutateDatabases={mutateDatabases}
databases={filteredDatabases || []}
databases={databases || []}
isOpen={isOpen}
setIsOpen={setIsOpen}
displayButton={true}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/data/use-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const useDatabases = () => {
};

export const useDatabase = (id?: string) => {
console.log("useDatabase", id);
const { data, error, isLoading, isValidating, mutate } =
useSWR<CleanDatabase>(id ? `/databases/${id}` : null, backendGet);
return { data, error, isLoading, isValidating, mutate };
Expand Down

0 comments on commit 3ee3782

Please sign in to comment.