Fix search results.

This commit is contained in:
Brian Cao 2023-08-11 11:37:01 -07:00
parent 937ff82d9f
commit cbed961d01
3 changed files with 25 additions and 23 deletions

View File

@ -1,5 +1,5 @@
import { useAuth, useCors } from 'lib/middleware';
import { NextApiRequestQueryBody, WebsiteSearchFilterType } from 'lib/types';
import { NextApiRequestQueryBody, SearchFilter, WebsiteSearchFilterType } from 'lib/types';
import { NextApiResponse } from 'next';
import { methodNotAllowed } from 'next-basics';

View File

@ -104,7 +104,7 @@ export async function getTeams(
...((filterType === TEAM_FILTER_TYPES.all ||
filterType === TEAM_FILTER_TYPES['user:username']) && {
teamUser: {
every: {
some: {
role: ROLES.teamOwner,
user: {
username: {

View File

@ -57,31 +57,33 @@ export async function getWebsites(
},
},
}),
AND: {
OR: [
{
...(userId && {
userId,
}),
},
{
...(includeTeams && {
teamWebsite: {
some: {
team: {
teamUser: {
some: {
userId,
AND: [
{
OR: [
{
...(userId && {
userId,
}),
},
{
...(includeTeams && {
teamWebsite: {
some: {
team: {
teamUser: {
some: {
userId,
},
},
},
},
},
},
}),
},
],
},
...(filter && filterQuery),
}),
},
],
},
{ ...(filter && filterQuery) },
],
};
const [pageFilters, getParameters] = prisma.getPageFilters({