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 17, 2024
1 parent f9cec04 commit e798c84
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
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 e798c84

Please sign in to comment.