Skip to content

Commit

Permalink
feat: add user tags to map list items
Browse files Browse the repository at this point in the history
  • Loading branch information
benfurber committed Oct 23, 2024
1 parent 054f10b commit f2918c7
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"main": "lib/index.js",
"type": "module",
"scripts": {
"start": "concurrently --kill-others --names themes,components,platform --prefix-colors cyan,blue,magenta \"yarn start:shared\" \"yarn start:themes\" \"yarn start:components\" \"yarn start:platform\"",
"start-ci": "concurrently --kill-others --names themes,components,platform --prefix-colors cyan,blue,magenta \"yarn start:themes\" \"yarn start:components\" \"yarn start:platform-ci\"",
"start": "concurrently --kill-others --names shared,themes,components,platform --prefix-colors cyan,blue,magenta \"yarn start:shared\" \"yarn start:themes\" \"yarn start:components\" \"yarn start:platform\"",
"start-ci": "concurrently --kill-others --names shared,themes,components,platform --prefix-colors cyan,blue,magenta \"yarn start:themes\" \"yarn start:components\" \"yarn start:platform-ci\"",
"start:themes": "yarn workspace oa-themes dev",
"start:components": "yarn workspace oa-components dev",
"start:shared": "yarn workspace oa-shared dev",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Flex, Image, Text } from 'theme-ui'

import { Category } from '../Category/Category'
import { MemberBadge } from '../MemberBadge/MemberBadge'
import { ProfileTagsList } from '../ProfileTagsList/ProfileTagsList'
import { Username } from '../Username/Username'

import type { IProfileCreator } from 'oa-shared'
Expand All @@ -19,6 +20,7 @@ export const CardDetailsSpaceProfile = ({ creator, isLink }: IProps) => {
countryCode,
coverImage,
profileType,
tags,
workspaceType,
} = creator

Expand Down Expand Up @@ -82,7 +84,8 @@ export const CardDetailsSpaceProfile = ({ creator, isLink }: IProps) => {
isLink={isLink}
/>
</Flex>
{workspaceType && (

{workspaceType && profileType === 'workspace' && (
<Category
category={{ label: workspaceLabel }}
sx={{
Expand All @@ -92,6 +95,9 @@ export const CardDetailsSpaceProfile = ({ creator, isLink }: IProps) => {
}}
/>
)}

{tags && <ProfileTagsList tagIds={tags} />}

{about && (
<Text variant="quiet" sx={{ fontSize: 2 }}>
{aboutTextStart || about}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ProfileTagsList = ({ tagIds }: IProps) => {
}

return (
<Flex sx={{ gap: 2 }}>
<Flex sx={{ gap: 2, flexWrap: 'wrap' }}>
{tags.map(
(tag, index) =>
tag?.label && (
Expand Down
2 changes: 2 additions & 0 deletions shared/models/maps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { ILatLng } from './common'
import type { IModerationStatus } from './moderation'
import type { ISelectedTags } from './tags'
import type { IUserBadges, ProfileTypeName, WorkspaceType } from './user'

/**
Expand Down Expand Up @@ -68,6 +69,7 @@ export interface IProfileCreator {
displayName: string
isContactableByPublic: boolean
profileType: ProfileTypeName
tags?: ISelectedTags
workspaceType?: string
userImage?: string
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Maps/Maps.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ const MapsPage = observer(() => {

useEffect(() => {
const userName = user?._id
if (!userName) {
if (!userName || mapPins.find(({ _id }) => _id === userName)) {
return
}

mapPinService.getMapPinSelf(userName).then((userMapPin) => {
if (userMapPin && !mapPins.find((pin) => pin._id === userMapPin._id)) {
setMapPins([...mapPins, userMapPin])
setMapPins((existingPins) => [...existingPins, userMapPin])
}
})
}, [user])
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Maps/map.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const getMapPins = async (currentUserId?: string) => {
const response = await fetch(API_URL + '/map-pins')
const mapPins = await response.json()

const currentUserPin = !!mapPins.find(({ _id }) => _id === currentUserId)
const hasCurrentUserPin = !!mapPins.find(({ _id }) => _id === currentUserId)

if (currentUserId && !currentUserPin) {
if (currentUserId && !hasCurrentUserPin) {
const userMapPin = await getMapPinByUserId(currentUserId)
userMapPin && mapPins.push(userMapPin)
}
Expand Down
6 changes: 4 additions & 2 deletions src/stores/Maps/maps.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,13 @@ export class MapsStore extends ModuleStore {
badges,
coverImages,
displayName,
isContactableByPublic,
location,
profileType,
isContactableByPublic,
userImage,
tags,
verified,
workspaceType,
userImage,
} = user
const type = profileType || ProfileTypeList.MEMBER
const existingPin = await this.getPin(_id, 'server')
Expand Down Expand Up @@ -238,6 +239,7 @@ export class MapsStore extends ModuleStore {
isContactableByPublic:
isContactableByPublic || DEFAULT_PUBLIC_CONTACT_PREFERENCE,
profileType,
...(tags ? { tags } : {}),
...(workspaceType ? { workspaceType } : {}),
...(userImage ? { userImage: userImage.downloadUrl } : {}),
},
Expand Down

0 comments on commit f2918c7

Please sign in to comment.