Run format
This commit is contained in:
@@ -28,7 +28,7 @@ const Body = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack align="stretch">
|
<Stack align="stretch">
|
||||||
<CopyTextField link={link} />
|
<CopyTextField link={link} />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@@ -1,52 +1,49 @@
|
|||||||
import {useRef, useState} from "react";
|
import { useRef, useState } from "react";
|
||||||
import toast from "../../utils/toast.util";
|
import toast from "../../utils/toast.util";
|
||||||
import {ActionIcon, TextInput} from "@mantine/core";
|
import { ActionIcon, TextInput } from "@mantine/core";
|
||||||
import {TbCheck, TbCopy} from "react-icons/tb";
|
import { TbCheck, TbCopy } from "react-icons/tb";
|
||||||
import {useClipboard} from "@mantine/hooks";
|
import { useClipboard } from "@mantine/hooks";
|
||||||
import {text} from "stream/consumers";
|
import { text } from "stream/consumers";
|
||||||
|
|
||||||
function CopyTextField(props: { link: string })
|
function CopyTextField(props: { link: string }) {
|
||||||
{
|
const clipboard = useClipboard({ timeout: 500 });
|
||||||
|
const [checkState, setCheckState] = useState(false);
|
||||||
|
const [textClicked, setTextClicked] = useState(false);
|
||||||
|
const timerRef = useRef<number | ReturnType<typeof setTimeout> | undefined>(
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
|
||||||
const clipboard = useClipboard({ timeout: 500 });
|
const copyLink = () => {
|
||||||
const [checkState, setCheckState] = useState(false);
|
clipboard.copy(props.link);
|
||||||
const [textClicked, setTextClicked] = useState(false);
|
toast.success("Your link was copied to the keyboard.");
|
||||||
const timerRef = useRef<number | ReturnType<typeof setTimeout> | undefined>(
|
if (timerRef.current) clearTimeout(timerRef.current);
|
||||||
undefined
|
timerRef.current = setTimeout(() => {
|
||||||
);
|
setCheckState(false);
|
||||||
|
}, 1500);
|
||||||
|
setCheckState(true);
|
||||||
|
};
|
||||||
|
|
||||||
const copyLink = () => {
|
return (
|
||||||
clipboard.copy(props.link);
|
<TextInput
|
||||||
toast.success("Your link was copied to the keyboard.");
|
readOnly
|
||||||
if (timerRef.current) clearTimeout(timerRef.current);
|
label="Link"
|
||||||
timerRef.current = setTimeout(() => {
|
variant="filled"
|
||||||
setCheckState(false);
|
value={props.link}
|
||||||
}, 1500);
|
onClick={() => {
|
||||||
setCheckState(true);
|
if (!textClicked) {
|
||||||
};
|
copyLink();
|
||||||
|
setTextClicked(true);
|
||||||
|
}
|
||||||
return(
|
}}
|
||||||
<TextInput
|
rightSection={
|
||||||
readOnly
|
window.isSecureContext && (
|
||||||
label="Link"
|
<ActionIcon onClick={copyLink}>
|
||||||
variant="filled"
|
{checkState ? <TbCheck /> : <TbCopy />}
|
||||||
value={props.link}
|
</ActionIcon>
|
||||||
onClick={() => {
|
)
|
||||||
if (!textClicked) {
|
}
|
||||||
copyLink();
|
/>
|
||||||
setTextClicked(true);
|
);
|
||||||
}
|
|
||||||
}}
|
|
||||||
rightSection={
|
|
||||||
window.isSecureContext && (
|
|
||||||
<ActionIcon onClick={copyLink}>
|
|
||||||
{checkState ? <TbCheck /> : <TbCopy />}
|
|
||||||
</ActionIcon>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CopyTextField;
|
export default CopyTextField;
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ const showCompletedUploadModal = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
|
const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
|
||||||
|
|
||||||
const modals = useModals();
|
const modals = useModals();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user