fix: teams are listed on insights but then you cant find them on settings page 11087 cal 2401 (#11092)
* fix listing of other teams * add more invalidate trpc queries * Remove unused code * Removed unnecesary flags
This commit is contained in:
@@ -2042,5 +2042,6 @@
|
||||
"seat_options_doesnt_multiple_durations": "Seat option doesn't support multiple durations",
|
||||
"include_calendar_event": "Include calendar event",
|
||||
"recently_added":"Recently added",
|
||||
"no_members_found": "No members found",
|
||||
"ADD_NEW_STRINGS_ABOVE_THIS_LINE_TO_PREVENT_MERGE_CONFLICTS": "↑↑↑↑↑↑↑↑↑↑↑↑↑ Add your new strings above here ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import { showToast } from "@calcom/ui";
|
||||
@@ -15,8 +14,6 @@ interface Props {
|
||||
export default function OtherTeamList(props: Props) {
|
||||
const utils = trpc.useContext();
|
||||
|
||||
const { t } = useLocale();
|
||||
|
||||
const [hideDropdown, setHideDropdown] = useState(false);
|
||||
|
||||
function selectAction(action: string, teamId: number) {
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
|
||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||
import { MembershipRole } from "@calcom/prisma/enums";
|
||||
import type { RouterOutputs } from "@calcom/trpc/react";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
ConfirmationDialogContent,
|
||||
Dialog,
|
||||
DialogTrigger,
|
||||
Dropdown,
|
||||
DropdownItem,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
showToast,
|
||||
Tooltip,
|
||||
} from "@calcom/ui";
|
||||
import { Edit2, ExternalLink, Link as LinkIcon, MoreHorizontal, Trash } from "@calcom/ui/components/icon";
|
||||
import { Edit2, ExternalLink, Link as LinkIcon, MoreHorizontal } from "@calcom/ui/components/icon";
|
||||
|
||||
import { useOrgBranding } from "../../../organizations/context/provider";
|
||||
|
||||
@@ -38,8 +33,6 @@ export default function OtherTeamListItem(props: Props) {
|
||||
|
||||
const orgBranding = useOrgBranding();
|
||||
|
||||
const isOwner = props.team.role === MembershipRole.OWNER;
|
||||
|
||||
const { hideDropdown, setHideDropdown } = props;
|
||||
|
||||
if (!team) return <></>;
|
||||
@@ -126,35 +119,6 @@ export default function OtherTeamListItem(props: Props) {
|
||||
</DropdownItem>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
|
||||
<DropdownMenuSeparator />
|
||||
{isOwner && (
|
||||
<DropdownMenuItem>
|
||||
<Dialog open={hideDropdown} onOpenChange={setHideDropdown}>
|
||||
<DialogTrigger asChild>
|
||||
<DropdownItem
|
||||
color="destructive"
|
||||
type="button"
|
||||
StartIcon={Trash}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}>
|
||||
{t("disband_team")}
|
||||
</DropdownItem>
|
||||
</DialogTrigger>
|
||||
<ConfirmationDialogContent
|
||||
variety="danger"
|
||||
title={t("disband_team")}
|
||||
confirmBtnText={t("confirm_disband_team")}
|
||||
isLoading={props.isLoading}
|
||||
onConfirm={() => {
|
||||
props.onActionSelect("disband");
|
||||
}}>
|
||||
{t("disband_team_confirmation_message")}
|
||||
</ConfirmationDialogContent>
|
||||
</Dialog>
|
||||
</DropdownMenuItem>
|
||||
)}
|
||||
</DropdownMenuContent>
|
||||
</Dropdown>
|
||||
</ButtonGroup>
|
||||
|
||||
@@ -38,6 +38,11 @@ function MembersList(props: MembersListProps) {
|
||||
})}
|
||||
</ul>
|
||||
) : null}
|
||||
{members?.length === 0 && (
|
||||
<div className="flex flex-col items-center justify-center">
|
||||
<p className="text-default text-sm font-bold">{t("no_members_found")}</p>
|
||||
</div>
|
||||
)}
|
||||
{displayLoadMore && (
|
||||
<button
|
||||
className="text-primary-500 hover:text-primary-600"
|
||||
@@ -107,7 +112,13 @@ const MembersView = () => {
|
||||
|
||||
const isLoading = isTeamLoading || isLoadingMembers || isOrgListLoading;
|
||||
|
||||
const inviteMemberMutation = trpc.viewer.teams.inviteMember.useMutation();
|
||||
const inviteMemberMutation = trpc.viewer.teams.inviteMember.useMutation({
|
||||
onSuccess: () => {
|
||||
utils.viewer.organizations.listOtherTeams.invalidate();
|
||||
utils.viewer.teams.list.invalidate();
|
||||
utils.viewer.organizations.listOtherTeamMembers.invalidate();
|
||||
},
|
||||
});
|
||||
|
||||
const isOrgAdminOrOwner =
|
||||
currentOrg &&
|
||||
|
||||
@@ -520,23 +520,9 @@ const SettingsSidebarContainer = ({
|
||||
alt={otherTeam.name || "Team logo"}
|
||||
/>
|
||||
<p className="w-1/2 truncate">{otherTeam.name}</p>
|
||||
{!otherTeam.accepted && otherTeam.userId === session.data?.user.id && (
|
||||
<Badge className="ms-3" variant="orange">
|
||||
Inv.
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsibleContent className="space-y-0.5">
|
||||
{((otherTeam.accepted && otherTeam.userId === session.data?.user.id) ||
|
||||
isOrgAdminOrOwner) && (
|
||||
<VerticalTabItem
|
||||
name={t("profile")}
|
||||
href={`/settings/organizations/teams/other/${otherTeam.id}/profile`}
|
||||
textClassNames="px-3 text-emphasis font-medium text-sm"
|
||||
disableChevron
|
||||
/>
|
||||
)}
|
||||
<VerticalTabItem
|
||||
name={t("members")}
|
||||
href={`/settings/organizations/teams/other/${otherTeam.id}/members`}
|
||||
|
||||
@@ -9,38 +9,20 @@ type ListOptions = {
|
||||
};
|
||||
|
||||
export const listOtherTeamHandler = async ({ ctx }: ListOptions) => {
|
||||
const teamsInOrgIamNotPartOf = await prisma.membership.findMany({
|
||||
const teamsInOrgIamNotPartOf = await prisma.team.findMany({
|
||||
where: {
|
||||
userId: {
|
||||
not: ctx.user.id,
|
||||
parent: {
|
||||
id: ctx.user?.organization?.id,
|
||||
},
|
||||
team: {
|
||||
parent: {
|
||||
is: {
|
||||
id: ctx.user?.organization?.id,
|
||||
},
|
||||
},
|
||||
members: {
|
||||
none: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
members: {
|
||||
none: {
|
||||
userId: ctx.user.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
team: true,
|
||||
},
|
||||
orderBy: { role: "desc" },
|
||||
distinct: ["teamId"],
|
||||
});
|
||||
|
||||
return teamsInOrgIamNotPartOf.map(({ team, ...membership }) => ({
|
||||
role: membership.role,
|
||||
accepted: membership.accepted,
|
||||
userId: membership.userId,
|
||||
isOrgAdmin: true,
|
||||
...team,
|
||||
}));
|
||||
return teamsInOrgIamNotPartOf;
|
||||
};
|
||||
|
||||
export default listOtherTeamHandler;
|
||||
|
||||
Reference in New Issue
Block a user