feat: invite link with SMTP check
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useLazyCreateInviteLinkQuery } from "../../app/services/server";
|
import {
|
||||||
|
useLazyCreateInviteLinkQuery,
|
||||||
|
useGetSMTPConfigQuery,
|
||||||
|
} from "../../app/services/server";
|
||||||
import Button from "./styled/Button";
|
import Button from "./styled/Button";
|
||||||
import useCopy from "../hook/useCopy";
|
import useCopy from "../hook/useCopy";
|
||||||
const StyledWrapper = styled.div`
|
const StyledWrapper = styled.div`
|
||||||
@@ -47,6 +50,10 @@ const StyledWrapper = styled.div`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
export default function InviteLink() {
|
export default function InviteLink() {
|
||||||
|
const {
|
||||||
|
data: config,
|
||||||
|
isSuccess: configQuerySuccess,
|
||||||
|
} = useGetSMTPConfigQuery();
|
||||||
const [copid, copy] = useCopy();
|
const [copid, copy] = useCopy();
|
||||||
const {
|
const {
|
||||||
inviteLink: { link },
|
inviteLink: { link },
|
||||||
@@ -66,17 +73,23 @@ export default function InviteLink() {
|
|||||||
const handleNewLink = () => {
|
const handleNewLink = () => {
|
||||||
createLink();
|
createLink();
|
||||||
};
|
};
|
||||||
if (!loginUser || !loginUser.is_admin) return null;
|
if (!loginUser || !loginUser.is_admin || !configQuerySuccess) return null;
|
||||||
|
let finalLink = null;
|
||||||
|
if (link) {
|
||||||
|
const tmpURL = new URL(link);
|
||||||
|
tmpURL.searchParams.set("code", config.enabled);
|
||||||
|
finalLink = tmpURL.href;
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<StyledWrapper>
|
<StyledWrapper>
|
||||||
<span className="tip">
|
<span className="tip">
|
||||||
Share this link to invite people to this server.
|
Share this link to invite people to this server.
|
||||||
</span>
|
</span>
|
||||||
<div className="link">
|
<div className="link">
|
||||||
<span title={link} className="content">
|
<span title={finalLink} className="content">
|
||||||
{link}
|
{finalLink}
|
||||||
</span>
|
</span>
|
||||||
<Button onClick={copy.bind(null, link)} className="main">
|
<Button onClick={copy.bind(null, finalLink)} className="main">
|
||||||
{copid ? "Copied" : `Copy`}
|
{copid ? "Copied" : `Copy`}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user