diff --git a/packages/api/router/location/query.forVisitCard.handler.ts b/packages/api/router/location/query.forVisitCard.handler.ts index e565a12921..dfe9c9864c 100644 --- a/packages/api/router/location/query.forVisitCard.handler.ts +++ b/packages/api/router/location/query.forVisitCard.handler.ts @@ -29,17 +29,19 @@ const forVisitCard = async ({ input }: TRPCHandlerParams) = latitude: true, longitude: true, addressVisibility: true, + hours: { where: { active: true }, select: { id: true } }, }, }) if (!result) { return null } - const { attributes, ...rest } = result + const { attributes, hours, ...rest } = result const transformed = { ...rest, ...formatAddressVisiblity(rest), remote: attributes.find(({ attribute }) => attribute.tsKey === 'additional.offers-remote-services') ?.attribute, + hasHours: hours.length > 0, } return transformed } catch (err) { diff --git a/packages/api/router/misc/query.hasContactInfo.handler.ts b/packages/api/router/misc/query.hasContactInfo.handler.ts index f244c6a9a2..9f8f9ed217 100644 --- a/packages/api/router/misc/query.hasContactInfo.handler.ts +++ b/packages/api/router/misc/query.hasContactInfo.handler.ts @@ -74,8 +74,8 @@ const whereId = ( locations: { some: { location: { id: input, ...isPublic } } }, ...isPublic, }, - socialMedia: { locations: { every: { location: { id: input, ...isPublic } } }, ...isPublic }, - website: { locations: { every: { location: { id: input, ...isPublic } } }, ...isPublic }, + socialMedia: { locations: { some: { location: { id: input, ...isPublic } } }, ...isPublic }, + website: { locations: { some: { location: { id: input, ...isPublic } } }, ...isPublic }, } } case isIdFor('orgService', input): { @@ -120,7 +120,10 @@ const hasContactInfo = async ({ input }: TRPCHandlerParams { const { isMobile, isTablet } = useScreenSize() const { data: hasContactInfo } = api.misc.hasContactInfo.useQuery(parentId) - if (!hasContactInfo && !edit) return null + if (!hasContactInfo && !edit) { + return null + } const body = ( diff --git a/packages/ui/components/sections/VisitCard.tsx b/packages/ui/components/sections/VisitCard.tsx index d6e5aa2252..184cdc0f8f 100644 --- a/packages/ui/components/sections/VisitCard.tsx +++ b/packages/ui/components/sections/VisitCard.tsx @@ -109,6 +109,9 @@ const VisitCardDisplay = ({ locationId }: VisitCardProps) => { */} ) + if (!formattedAddress && !data.hasHours) { + return null + } return isTablet ? body : {body} }