From 96ba72db799780aa8c8584779a2bf25510171ab9 Mon Sep 17 00:00:00 2001 From: Ben Furber Date: Thu, 31 Oct 2024 15:07:15 +0000 Subject: [PATCH] feat: update functions for tags by project --- functions/src/userUpdates/utils.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/functions/src/userUpdates/utils.ts b/functions/src/userUpdates/utils.ts index 5515ca7fbb..565976e12f 100644 --- a/functions/src/userUpdates/utils.ts +++ b/functions/src/userUpdates/utils.ts @@ -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, @@ -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)