Skip to content

Commit

Permalink
feat: update functions for tags by project
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Nov 4, 2024
1 parent ea84582 commit 96ba72d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions functions/src/userUpdates/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
import { profileTags } from 'oa-shared'
import { allCommunityProfileTags } from 'oa-shared'

import { CONFIG } from '../config/config'
import { valuesAreDeepEqual } from '../Utils'

import type { ISelectedTags, ITag, IUserDB } from 'oa-shared'

const projectName = () => {
const productionOptions = {
onearmyworld: 'precious-plastic',
'fixing-fashion-prod': 'fixing-fashion',
'project-kamp-community': 'project-kamp',
}

return productionOptions[CONFIG.service.project_id] || 'precious-plastic'
}

export const hasDetailsChanged = (
prevUser: IUserDB,
user: IUserDB,
Expand Down Expand Up @@ -87,8 +98,10 @@ export const getFirstCoverImage = (coverImages: IUserDB['coverImages']) => {
// For ease, duplicated from src/utils/getValidTags.ts
export const getValidTags = (tagIds: ISelectedTags) => {
const selectedTagIds = Object.keys(tagIds).filter((id) => tagIds[id] === true)
const projectTags = allCommunityProfileTags[projectName()]

const tags: ITag[] = selectedTagIds
.map((id) => profileTags.find(({ _id }) => id === _id))
.map((id) => projectTags.find(({ _id }) => id === _id))
.filter((tag): tag is ITag => !!tag)
.filter(({ _deleted }) => _deleted !== true)

Expand Down

0 comments on commit 96ba72d

Please sign in to comment.