не копировать для новых ссылок (без возможности теста пока)
This commit is contained in:
parent
98bf92466b
commit
87d4c9d53d
@ -6,6 +6,7 @@ import { InfoPopover } from "@/ui_kit/InfoPopover";
|
||||
import TooltipClickInfo from "@/ui_kit/Toolbars/TooltipClickInfo";
|
||||
import { useDomainDefine } from "@/utils/hooks/useDomainDefine";
|
||||
import { IconButton, ListItem, Typography, useTheme } from "@mui/material";
|
||||
import { useMemo } from "react";
|
||||
|
||||
interface AuditoryLinkProps {
|
||||
item: AuditoryItem;
|
||||
@ -19,7 +20,16 @@ export const AuditoryLink = ({ utmParams, item, index, onDelete }: AuditoryLinkP
|
||||
const quiz = useCurrentQuiz();
|
||||
const { isTestServer } = useDomainDefine();
|
||||
|
||||
const canCopy = useMemo(() => {
|
||||
if (!item.created_at) return true;
|
||||
const now = new Date().getTime();
|
||||
const created = new Date(item.created_at).getTime();
|
||||
const diffInMinutes = (now - created) / (1000 * 60);
|
||||
return diffInMinutes >= 5;
|
||||
}, [item.created_at]);
|
||||
|
||||
const handleCopy = (text: string) => {
|
||||
if (!canCopy) return;
|
||||
navigator.clipboard.writeText(text);
|
||||
};
|
||||
|
||||
@ -27,7 +37,7 @@ export const AuditoryLink = ({ utmParams, item, index, onDelete }: AuditoryLinkP
|
||||
onDelete(item.id);
|
||||
};
|
||||
|
||||
const linkText = `${isTestServer ? "https://s.hbpn.link/" : "https://hbpn.link/"}${quiz.qid}?_paud=${item.id}${utmParams}`;
|
||||
const linkText = `${isTestServer ? "https://s.hbpn.link/" : "https://hbpn.link/"}${quiz?.qid}?_paud=${item.id}${utmParams}`;
|
||||
|
||||
return (
|
||||
<ListItem
|
||||
@ -70,19 +80,33 @@ export const AuditoryLink = ({ utmParams, item, index, onDelete }: AuditoryLinkP
|
||||
<IconButton
|
||||
edge="end"
|
||||
aria-label="copy"
|
||||
sx={{ color: theme.palette.brightPurple.main, p: 0, width: 18, height: 18, marginRight: "-2px" }}
|
||||
disabled={!canCopy}
|
||||
sx={{
|
||||
color: canCopy ? theme.palette.brightPurple.main : theme.palette.grey[400],
|
||||
p: 0,
|
||||
width: 18,
|
||||
height: 18,
|
||||
marginRight: "-2px"
|
||||
}}
|
||||
onClick={() => handleCopy(linkText)}
|
||||
>
|
||||
<CopyIcon color={theme.palette.brightPurple.main} />
|
||||
<CopyIcon color={canCopy ? theme.palette.brightPurple.main : theme.palette.grey[400]} />
|
||||
</IconButton>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Typography sx={{
|
||||
color: 'black', fontWeight: 400, fontSize: "16px",
|
||||
textOverflow: "ellipsis", whiteSpace: "nowrap", overflow: "hidden",
|
||||
width: "calc(100% - 80px)"
|
||||
|
||||
color: 'black',
|
||||
fontWeight: 400,
|
||||
fontSize: "16px",
|
||||
textOverflow: "ellipsis",
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
width: "calc(100% - 80px)",
|
||||
userSelect: "none",
|
||||
WebkitUserSelect: "none",
|
||||
MozUserSelect: "none",
|
||||
msUserSelect: "none"
|
||||
}}>
|
||||
{linkText}
|
||||
</Typography>
|
||||
|
Loading…
Reference in New Issue
Block a user