Skip to content

Commit

Permalink
fix: basic info card address display (#1143)
Browse files Browse the repository at this point in the history
* enforce "notVisitable" on BasicListingCard

* do not throw error on not found
  • Loading branch information
JoeKarow authored Mar 7, 2024
1 parent 5dd4ff4 commit 61d4265
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const forLocationPage = async ({ input }: TRPCHandlerParams<TForLocationP
latitude: true,
description: globalSelect.freeText(),
attributes,
notVisitable: true,
reviews: {
where: { visible: true, deleted: false },
select: { id: true },
Expand Down
3 changes: 2 additions & 1 deletion packages/api/router/location/query.forVisitCard.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { type TForVisitCardSchema } from './query.forVisitCard.schema'

export const forVisitCard = async ({ input }: TRPCHandlerParams<TForVisitCardSchema>) => {
try {
const result = await prisma.orgLocation.findUniqueOrThrow({
const result = await prisma.orgLocation.findUnique({
where: {
...globalWhere.isPublic(),
id: input,
Expand All @@ -30,6 +30,7 @@ export const forVisitCard = async ({ input }: TRPCHandlerParams<TForVisitCardSch
longitude: true,
},
})
if (!result) return null
const { attributes, ...rest } = result
const transformed = {
...rest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const forOrgPage = async ({ ctx, input }: TRPCHandlerParams<TForOrgPageSc
postCode: true,
country: { select: { cca2: true } },
govDist: { select: { abbrev: true, tsKey: true, tsNs: true } },
notVisitable: true,
},
},
},
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/components/sections/ListingBasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ export const ListingBasicDisplay = memo(({ data }: ListingBasicInfoProps) => {
const isSingleLoc = locations?.length === 1
const location = isSingleLoc ? locations[0] : undefined

const addressLine = <Text variant={variants.Text.utility2darkGray}>{useFormattedAddress(location)}</Text>
const formattedAddress = useFormattedAddress(location)

const addressLine = location?.notVisitable ? null : (
<Text variant={variants.Text.utility2darkGray}>{formattedAddress}</Text>
)

const leaderAttributes = attributes.filter(({ attribute }) =>
attribute.categories.some(({ category }) => category.tag === 'organization-leadership')
Expand Down

0 comments on commit 61d4265

Please sign in to comment.