mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 19:22:39 +10:00
@ -148,6 +148,7 @@
|
|||||||
"Select role to assign to all invited members": "Select role to assign to all invited members",
|
"Select role to assign to all invited members": "Select role to assign to all invited members",
|
||||||
"Select theme": "Select theme",
|
"Select theme": "Select theme",
|
||||||
"Send invitation": "Send invitation",
|
"Send invitation": "Send invitation",
|
||||||
|
"Invitation sent": "Invitation sent",
|
||||||
"Settings": "Settings",
|
"Settings": "Settings",
|
||||||
"Setup workspace": "Setup workspace",
|
"Setup workspace": "Setup workspace",
|
||||||
"Sign In": "Sign In",
|
"Sign In": "Sign In",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Menu, ActionIcon, Text } from "@mantine/core";
|
import { Menu, ActionIcon, Text } from "@mantine/core";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { IconDots, IconTrash } from "@tabler/icons-react";
|
import { IconCopy, IconDots, IconSend, IconTrash } from "@tabler/icons-react";
|
||||||
import { modals } from "@mantine/modals";
|
import { modals } from "@mantine/modals";
|
||||||
import {
|
import {
|
||||||
useResendInvitationMutation,
|
useResendInvitationMutation,
|
||||||
@ -9,6 +9,9 @@ import {
|
|||||||
} from "@/features/workspace/queries/workspace-query.ts";
|
} from "@/features/workspace/queries/workspace-query.ts";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { notifications } from "@mantine/notifications";
|
import { notifications } from "@mantine/notifications";
|
||||||
|
import { useClipboard } from "@mantine/hooks";
|
||||||
|
import { getInviteLink } from "@/features/workspace/services/workspace-service.ts";
|
||||||
|
import useUserRole from "@/hooks/use-user-role.tsx";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
invitationId: string;
|
invitationId: string;
|
||||||
@ -17,17 +20,21 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const resendInvitationMutation = useResendInvitationMutation();
|
const resendInvitationMutation = useResendInvitationMutation();
|
||||||
const revokeInvitationMutation = useRevokeInvitationMutation();
|
const revokeInvitationMutation = useRevokeInvitationMutation();
|
||||||
const { data: inviteLink, error, } = useGetInviteLink(invitationId);
|
const { isAdmin } = useUserRole();
|
||||||
|
const clipboard = useClipboard();
|
||||||
|
|
||||||
const onCopyLink = async () => {
|
const handleCopyLink = async (invitationId: string) => {
|
||||||
if (error) {
|
try {
|
||||||
notifications.show({ message: error.message, color: "red" })
|
const link = await getInviteLink({ invitationId });
|
||||||
} else {
|
clipboard.copy(link.inviteLink);
|
||||||
navigator.clipboard.writeText(inviteLink.inviteLink)
|
notifications.show({ message: t("Link copied") });
|
||||||
notifications.show({ message: "Invite link copied to clipboard!"})
|
} catch (err) {
|
||||||
|
notifications.show({
|
||||||
|
message: err["response"]?.data?.message,
|
||||||
|
color: "red",
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
const onResend = async () => {
|
const onResend = async () => {
|
||||||
await resendInvitationMutation.mutateAsync({ invitationId });
|
await resendInvitationMutation.mutateAsync({ invitationId });
|
||||||
@ -70,14 +77,26 @@ export default function InviteActionMenu({ invitationId }: Props) {
|
|||||||
</Menu.Target>
|
</Menu.Target>
|
||||||
|
|
||||||
<Menu.Dropdown>
|
<Menu.Dropdown>
|
||||||
<Menu.Item onClick={onResend}>{t("Resend invitation")}</Menu.Item>
|
<Menu.Item
|
||||||
<Menu.Item onClick={onCopyLink}>Copy invite link</Menu.Item>
|
onClick={() => handleCopyLink(invitationId)}
|
||||||
<Menu.Item onClick={onResend}>Resend invitation</Menu.Item>
|
leftSection={<IconCopy size={16} />}
|
||||||
|
disabled={!isAdmin}
|
||||||
|
>
|
||||||
|
{t("Copy link")}
|
||||||
|
</Menu.Item>
|
||||||
|
<Menu.Item
|
||||||
|
onClick={onResend}
|
||||||
|
leftSection={<IconSend size={16} />}
|
||||||
|
disabled={!isAdmin}
|
||||||
|
>
|
||||||
|
{t("Resend invitation")}
|
||||||
|
</Menu.Item>
|
||||||
<Menu.Divider />
|
<Menu.Divider />
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
c="red"
|
c="red"
|
||||||
onClick={openRevokeModal}
|
onClick={openRevokeModal}
|
||||||
leftSection={<IconTrash size={16} stroke={2} />}
|
leftSection={<IconTrash size={16} />}
|
||||||
|
disabled={!isAdmin}
|
||||||
>
|
>
|
||||||
{t("Revoke invitation")}
|
{t("Revoke invitation")}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@ -26,6 +26,7 @@ import {
|
|||||||
IWorkspace,
|
IWorkspace,
|
||||||
} from "@/features/workspace/types/workspace.types.ts";
|
} from "@/features/workspace/types/workspace.types.ts";
|
||||||
import { IUser } from "@/features/user/types/user.types.ts";
|
import { IUser } from "@/features/user/types/user.types.ts";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
export function useWorkspaceQuery(): UseQueryResult<IWorkspace, Error> {
|
export function useWorkspaceQuery(): UseQueryResult<IWorkspace, Error> {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@ -92,12 +93,13 @@ export function useGetInviteLink(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useCreateInvitationMutation() {
|
export function useCreateInvitationMutation() {
|
||||||
|
const { t } = useTranslation();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
return useMutation<void, Error, ICreateInvite>({
|
return useMutation<void, Error, ICreateInvite>({
|
||||||
mutationFn: (data) => createInvitation(data),
|
mutationFn: (data) => createInvitation(data),
|
||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
notifications.show({ message: "Invitation sent" });
|
notifications.show({ message: t("Invitation sent") });
|
||||||
queryClient.refetchQueries({
|
queryClient.refetchQueries({
|
||||||
queryKey: ["invitations"],
|
queryKey: ["invitations"],
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user