* WIP restored from .git cache * fix exports * sortable row model * feat column visibility component * wip filters with nuqs * pull in unique values from table into filters * correctly assign filters via v/f * inital selection bar refactor * data-table selection bar + optmistic update of delete * dynamic link * migrate member list table to new data-table * total list shows filtered value > db valuie * add filters for attributes * type errors * make content bigger on lg * add mb-6 to teams user datatable to match spacing spec * correctly render multi-badge * fix: masss asignment optimistic UI * fix type errors * remove log * fix toolbar type error * chore: Remove debug artifact * type errors * Update apps/web/public/static/locales/en/common.json * use max-w-fit * chore: Remove unused translation now we don't specify 'mass' in assign * perf: fix: use the onBlur event to prevent focus loss whilst the list is rerendering * Move the data-table exports together in the main barrel, then import * fix exports that were lost in a merge * fix exports that were lost in a merge * fix groupteammapping/availbilityslider * fix overflow problems * add scrollbar-thin class * fix type error * user serverside values for faceted filters * pass filters to serverside * filter serverside * fix team server side filter * add loaded x of y * attributes icon change * correct implementation for text/input attr optimistic * type check fixes * fix platform checks * fix types again * fix types again * fix types again * add use client * add use client * fix-types * fix: Add missing translation in EN * fix e2e tests via testid * fix e2e tests via testid * fix: Member invite popup not popping up * Update copyInviteLink to new-member-button testid * Hopefully fix test ids this time * fix: Use the right buttons on the right pages --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
78 lines
2.2 KiB
TypeScript
78 lines
2.2 KiB
TypeScript
import { useSession } from "next-auth/react";
|
|
import type { Dispatch } from "react";
|
|
|
|
import MemberInvitationModal from "@calcom/features/ee/teams/components/MemberInvitationModal";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc";
|
|
import { showToast } from "@calcom/ui";
|
|
import usePlatformMe from "@calcom/web/components/settings/platform/hooks/usePlatformMe";
|
|
|
|
import type { UserTableAction } from "./types";
|
|
|
|
interface Props {
|
|
dispatch: Dispatch<UserTableAction>;
|
|
}
|
|
|
|
export function InviteMemberModal(props: Props) {
|
|
const { data: session } = useSession();
|
|
const { data: platformUser } = usePlatformMe();
|
|
const utils = trpc.useUtils();
|
|
const { t, i18n } = useLocale();
|
|
const inviteMemberMutation = trpc.viewer.teams.inviteMember.useMutation({
|
|
async onSuccess(data) {
|
|
props.dispatch({ type: "CLOSE_MODAL" });
|
|
// Need to figure out if invalidating here is the right approach - we could have already
|
|
// loaded a bunch of data and idk how pagination works with invalidation. We may need to use
|
|
// Optimistic updates here instead.
|
|
await utils.viewer.organizations.listMembers.invalidate();
|
|
|
|
if (Array.isArray(data.usernameOrEmail)) {
|
|
showToast(
|
|
t("email_invite_team_bulk", {
|
|
userCount: data.numUsersInvited,
|
|
}),
|
|
"success"
|
|
);
|
|
} else {
|
|
showToast(
|
|
t("email_invite_team", {
|
|
email: data.usernameOrEmail,
|
|
}),
|
|
"success"
|
|
);
|
|
}
|
|
},
|
|
onError: (error) => {
|
|
showToast(error.message, "error");
|
|
},
|
|
});
|
|
|
|
const orgId = session?.user.org?.id ?? platformUser?.organizationId;
|
|
|
|
if (!orgId) return null;
|
|
|
|
return (
|
|
<MemberInvitationModal
|
|
members={[]}
|
|
isOpen={true}
|
|
onExit={() => {
|
|
props.dispatch({
|
|
type: "CLOSE_MODAL",
|
|
});
|
|
}}
|
|
teamId={orgId}
|
|
isOrg={true}
|
|
isPending={inviteMemberMutation.isPending}
|
|
onSubmit={(values) => {
|
|
inviteMemberMutation.mutate({
|
|
teamId: orgId,
|
|
language: i18n.language,
|
|
role: values.role,
|
|
usernameOrEmail: values.emailOrUsername,
|
|
isPlatform: platformUser?.organization.isPlatform,
|
|
});
|
|
}}
|
|
/>
|
|
);
|
|
}
|