fix: filter and listMember handler (#14429)

* fix: filter and listMember handler

* Update packages/trpc/server/routers/viewer/teams/listMembers.handler.ts

Co-authored-by: Keith Williams <keithwillcode@gmail.com>

* Update packages/features/bookings/components/PeopleFilter.tsx

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
This commit is contained in:
sean-brydonandKeith Williams authored and GitHub committed 2024-04-05 11:51:22 -03:00
1 parent 5e3f6e6c2c
commit e3b7264208
2 files changed
+15

No files matched your search

@@ -15,6 +15,10 @@ export const PeopleFilter = () => {
const { t } = useLocale();
const orgBranding = useOrgBranding();
const { data: currentOrg } = trpc.viewer.organizations.listCurrent.useQuery();
const isAdmin = currentOrg?.user.role === "ADMIN" || currentOrg?.user.role === "OWNER";
const hasPermToView = !currentOrg?.isPrivate || isAdmin;
const { data: query, pushItemToKey, removeItemByKeyAndValue, removeAllQueryParams } = useFilterQuery();
const [searchText, setSearchText] = useState("");
@@ -37,6 +41,10 @@ export const PeopleFilter = () => {
return `${t("all")}`;
};
if (!hasPermToView) {
return null;
}
return (
<AnimatedPopover text={getTextForPopover()} prefix={`${t("people")}: `}>
<FilterCheckboxFieldsContainer>
@@ -14,6 +14,13 @@ type ListMembersOptions = {
export const listMembersHandler = async ({ ctx, input }: ListMembersOptions) => {
const { prisma } = ctx;
const { isOrgAdmin } = ctx.user.organization;
const hasPermsToView = !ctx.user.organization.isPrivate || isOrgAdmin;
if (!hasPermsToView) {
return [];
}
const teams = await prisma.team.findMany({
where: {
id: {