Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/heureka/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"@cloudoperators/juno-url-state-provider": "workspace:*",
"@tanstack/react-query": "5.89.0",
"@tanstack/react-router": "1.133.22",
"lodash": "4.17.21",
"react": "19.1.0",
"react-dom": "19.1.0"
},
Expand All @@ -49,7 +48,6 @@
"@testing-library/jest-dom": "6.8.0",
"@testing-library/react": "16.3.0",
"@testing-library/user-event": "14.6.1",
"@types/lodash": "4.17.19",
"@types/node": "24.3.2",
"@types/react": "19.1.8",
"@types/react-dom": "19.1.6",
Expand Down
6 changes: 3 additions & 3 deletions apps/heureka/src/components/Services/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { isEmpty, isNil, map, omit } from "lodash"
import { isEmpty, isNil, omit } from "../../utils"
import { ApolloError } from "@apollo/client"
import {
Edge,
Expand Down Expand Up @@ -298,9 +298,9 @@ export const getFiltersForUrl = (filterSettings: FilterSettings): Record<string,
}

export const getNormalizedFilters = (data: GetServiceFiltersQuery | undefined | null): Filter[] =>
isEmpty(data) || isEmpty(data.ServiceFilterValues)
isEmpty(data) || isEmpty(data?.ServiceFilterValues)
? []
: map(omit(data.ServiceFilterValues, ["__typename"]), (filter) => ({
: Object.values(omit(data!.ServiceFilterValues!, ["__typename"])).map((filter) => ({
displayName: filter?.displayName || "",
filterName: filter?.filterName || "",
values: filter?.values?.filter((value) => value !== null) || [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { useCallback, useState } from "react"
import { isEmpty } from "lodash"
import { isEmpty } from "../../../utils"
import { InputGroup, ComboBox, ComboBoxOption, SelectOption, Select, Stack } from "@cloudoperators/juno-ui-components"
import { Filter, SelectedFilter } from "./types"

Expand Down
35 changes: 35 additions & 0 deletions apps/heureka/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,38 @@ export const useTextOverflow = (text: string | null) => {

return { needsExpansion, textRef }
}

/**
* Utility functions to replace lodash dependencies
*/

// Replace _.isEmpty()
export const isEmpty = (value: any): boolean => {
if (value == null) return true
if (typeof value === "string" || Array.isArray(value)) return value.length === 0
if (typeof value === "object") return Object.keys(value).length === 0
return false
}

// Replace _.isNil()
export const isNil = (value: any): value is null | undefined => {
return value == null
}

// Replace _.omit()
export const omit = <T extends Record<string, any>, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> => {
const result = { ...obj }
keys.forEach((key) => {
delete result[key]
})
return result
}

// Replace _.map() for objects - transforms object values
export const mapObject = <T, U>(obj: Record<string, T>, iteratee: (value: T, key: string) => U): Record<string, U> => {
const result: Record<string, U> = {}
Object.entries(obj).forEach(([key, value]) => {
result[key] = iteratee(value, key)
})
return result
}
6 changes: 0 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading