Skip to content

Commit 9347f89

Browse files
committed
refactor: update enhanceTags function to accept remote config store as a parameter
1 parent 831c9e4 commit 9347f89

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/utils/DataEnhancement.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import { Tag, useRemoteConfigStore, TagValuesFieldType } from 'src/features/remoteConfig'
1+
import { RemoteConfig, Tag, TagValuesFieldType } from 'src/features/remoteConfig'
22
import { BaseEntry } from 'src/types'
33

4-
export const enhanceTags = (tags: string[]): Tag[] => {
5-
const savedTags = useRemoteConfigStore.getState().supportedTags
6-
4+
export const enhanceTags = (remoteConfigStore: RemoteConfig, tags: string[]): Tag[] => {
75
return tags
8-
.map((tag) => savedTags.find((st) => st.value.toLowerCase() === tag.toLocaleString()))
6+
.map((tag) =>
7+
remoteConfigStore.supportedTags.find((st) => st.value.toLowerCase() === tag.toLocaleString())
8+
)
99
.filter(Boolean) as Tag[]
1010
}
1111

12-
1312
export const getCardTagsValue = (tags: Tag[], valuesField: TagValuesFieldType): string[] => {
1413
return tags.reduce((acc: string[], curr) => {
1514
if (!curr[valuesField] || curr[valuesField].length === 0) return acc
@@ -18,9 +17,8 @@ export const getCardTagsValue = (tags: Tag[], valuesField: TagValuesFieldType):
1817
}, [])
1918
}
2019

21-
2220
export const filterUniqueEntries = (entries: BaseEntry[]) => {
2321
const uniqueResults = new Map()
2422
entries.forEach((item) => uniqueResults.set(item.id, item))
2523
return Array.from(uniqueResults.values())
26-
}
24+
}

0 commit comments

Comments
 (0)