Skip to content

Commit

Permalink
Merge branch 'dev' into IN-945-service-edit-page
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Feb 20, 2024
2 parents 8430e69 + 433d553 commit a62a6bb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions packages/api/router/orgPhone/query.forContactInfo.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const getWhereId = (input: TForContactInfoSchema, isSingleLoc?: boolean): Prisma
switch (true) {
case isIdFor('organization', input.parentId): {
return isSingleLoc
? {
? { organization: { organization: { id: input.parentId, ...isPublic } } }
: {
OR: [
{ organization: { organization: { id: input.parentId, ...isPublic } } },
{ locations: { some: { location: { organization: { id: input.parentId, ...isPublic } } } } },
],
}
: { organization: { organization: { id: input.parentId, ...isPublic } } }
}
case isIdFor('orgLocation', input.parentId): {
return { locations: { some: { location: { id: input.parentId, ...isPublic } } } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ const whereId = (input: TForContactInfoSchema, isSingleLoc?: boolean): Prisma.Or
switch (true) {
case isIdFor('organization', input.parentId): {
return isSingleLoc
? {
? { organization: { id: input.parentId, ...isPublic } }
: {
OR: [
{ organization: { id: input.parentId, ...isPublic } },
{ locations: { every: { location: { organization: { id: input.parentId, ...isPublic } } } } },
],
}
: { organization: { id: input.parentId, ...isPublic } }
}
case isIdFor('orgLocation', input.parentId): {
return { locations: { some: { location: { id: input.parentId, ...isPublic } } } }
Expand Down
19 changes: 11 additions & 8 deletions packages/api/router/orgWebsite/query.forContactInfo.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ const whereId = (input: TForContactInfoSchema, isSingleLoc?: boolean): Prisma.Or
switch (true) {
case isIdFor('organization', input.parentId): {
return isSingleLoc
? {
? { organization: { id: input.parentId, ...isPublic } }
: {
OR: [
{ organization: { id: input.parentId, ...isPublic } },
{ locations: { every: { location: { organization: { id: input.parentId, ...isPublic } } } } },
],
}
: { organization: { id: input.parentId, ...isPublic } }
}
case isIdFor('orgLocation', input.parentId): {
return { locations: { some: { location: { id: input.parentId, ...isPublic } } } }
return { locations: { every: { location: { id: input.parentId, ...isPublic } } } }
}

default: {
Expand All @@ -35,13 +35,16 @@ export const forContactInfo = async ({ input }: TRPCHandlerParams<TForContactInf
})
: 0
const isSingleLoc = locCount === 1
console.log('location count', locCount)
const where = {
...isPublic,
...whereId(input, isSingleLoc),
...(input.locationOnly !== undefined ? { orgLocationOnly: input.locationOnly } : {}),
}
console.dir(where, { depth: 10 })

const result = await prisma.orgWebsite.findMany({
where: {
...isPublic,
...whereId(input, isSingleLoc),
...(input.locationOnly !== undefined ? { orgLocationOnly: input.locationOnly } : {}),
},
where,
select: {
id: true,
url: true,
Expand Down

0 comments on commit a62a6bb

Please sign in to comment.