-
-
Notifications
You must be signed in to change notification settings - Fork 389
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
93 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 3 additions & 13 deletions
16
packages/components/src/ProfileTagsList/ProfileTagsList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { ProfileTagsList } from 'oa-components' | ||
import { getValidTags } from 'src/utils/getValidTags' | ||
|
||
import type { ISelectedTags } from 'oa-shared' | ||
|
||
interface IProps { | ||
tagIds: ISelectedTags | ||
} | ||
|
||
export const ProfileTags = ({ tagIds }: IProps) => { | ||
const tags = getValidTags(tagIds) | ||
|
||
if (tags.length === 0) { | ||
return null | ||
} | ||
|
||
return <ProfileTagsList tags={tags} /> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { getValidTags } from "./getValidTags" | ||
|
||
describe('getValidTags', () => { | ||
it('returns only true valid tags', () => { | ||
const tagIds = { | ||
'uCzWZbz3aVKyx2keoqRi': true, // A valid tag | ||
'J3LF7fMsDfniYT2ZX3rf': false, // A valid tag | ||
'not-a-tag': false, | ||
} | ||
const tags = getValidTags(tagIds) | ||
expect(tags.length).toEqual(1) | ||
expect(tags[0]._id).toEqual('uCzWZbz3aVKyx2keoqRi') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { profileTags } from 'oa-shared' | ||
|
||
import type { ISelectedTags, ITag } from 'oa-shared' | ||
|
||
// For ease, duplicated from functions/src/uperUpdates/utils.ts | ||
export const getValidTags = (tagIds: ISelectedTags): ITag[] => { | ||
const selectedTagIds = Object.keys(tagIds).filter((id) => tagIds[id] === true) | ||
|
||
const tags: ITag[] = selectedTagIds | ||
.map((id) => profileTags.find(({ _id }) => id === _id)) | ||
.filter((tag): tag is ITag => !!tag) | ||
.filter(({ _deleted }) => _deleted !== true) | ||
|
||
return tags | ||
} |