Run format

This commit is contained in:
pierrbt
2023-06-23 16:22:57 +02:00
parent e5718700bc
commit 8fdba0ca7c
3 changed files with 44 additions and 48 deletions

View File

@@ -28,7 +28,7 @@ const Body = ({
return (
<Stack align="stretch">
<CopyTextField link={link} />
<CopyTextField link={link} />
<Button
onClick={() => {

View File

@@ -1,52 +1,49 @@
import {useRef, useState} from "react";
import { useRef, useState } from "react";
import toast from "../../utils/toast.util";
import {ActionIcon, TextInput} from "@mantine/core";
import {TbCheck, TbCopy} from "react-icons/tb";
import {useClipboard} from "@mantine/hooks";
import {text} from "stream/consumers";
import { ActionIcon, TextInput } from "@mantine/core";
import { TbCheck, TbCopy } from "react-icons/tb";
import { useClipboard } from "@mantine/hooks";
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 [checkState, setCheckState] = useState(false);
const [textClicked, setTextClicked] = useState(false);
const timerRef = useRef<number | ReturnType<typeof setTimeout> | undefined>(
undefined
);
const copyLink = () => {
clipboard.copy(props.link);
toast.success("Your link was copied to the keyboard.");
if (timerRef.current) clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => {
setCheckState(false);
}, 1500);
setCheckState(true);
};
const copyLink = () => {
clipboard.copy(props.link);
toast.success("Your link was copied to the keyboard.");
if (timerRef.current) clearTimeout(timerRef.current);
timerRef.current = setTimeout(() => {
setCheckState(false);
}, 1500);
setCheckState(true);
};
return(
<TextInput
readOnly
label="Link"
variant="filled"
value={props.link}
onClick={() => {
if (!textClicked) {
copyLink();
setTextClicked(true);
}
}}
rightSection={
window.isSecureContext && (
<ActionIcon onClick={copyLink}>
{checkState ? <TbCheck /> : <TbCopy />}
</ActionIcon>
)
}
/>
)
return (
<TextInput
readOnly
label="Link"
variant="filled"
value={props.link}
onClick={() => {
if (!textClicked) {
copyLink();
setTextClicked(true);
}
}}
rightSection={
window.isSecureContext && (
<ActionIcon onClick={copyLink}>
{checkState ? <TbCheck /> : <TbCopy />}
</ActionIcon>
)
}
/>
);
}
export default CopyTextField;
export default CopyTextField;

View File

@@ -21,7 +21,6 @@ const showCompletedUploadModal = (
};
const Body = ({ share, appUrl }: { share: Share; appUrl: string }) => {
const modals = useModals();
const router = useRouter();