Skip to content

Commit

Permalink
Fixes to link sharing (#425)
Browse files Browse the repository at this point in the history
* fixed and removed inefficiencies

* removed unnecessary image
  • Loading branch information
trp02 authored Mar 10, 2024
1 parent d77efe6 commit f3ce3f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Binary file removed src/assets/copySuccess.png
Binary file not shown.
10 changes: 4 additions & 6 deletions src/components/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
import { LoadingSpinner } from "./loadingSpinner";
import copyImage from "../assets/copy.png";
const searchParams = new URLSearchParams(window.location.search);
const prefillVar = searchParams.get("prefill_var");
const prefillVar = searchParams.get("share");

const Form = () => {
const [data, setData] = useState(null);
Expand All @@ -13,7 +13,6 @@ const Form = () => {
const [isLoading, setIsLoading] = useState(false);
const previousUserInput = useRef(undefined);
const hasUserInputChanged = previousUserInput.current !== userInput;
const [copyStatus, setImageSrc] = useState(copyImage);
const [isCopied, setIsCopied] = useState(false);

function clearDataBeforeFetch() {
Expand Down Expand Up @@ -66,12 +65,11 @@ const Form = () => {

const copyToClipboard = (e) => {
e.preventDefault();
const link = `${window.location.origin}/?prefill_var=${userInput}`;
const link = `${window.location.origin}/?share=${userInput}`;
navigator.clipboard
.writeText(link)
.then(() => {
console.log("Link copied to clipboard");
setImageSrc(copyImage);
setIsCopied(true);
setTimeout(() => setIsCopied(false), 2000);
})
Expand Down Expand Up @@ -163,8 +161,8 @@ const Form = () => {
</span>
) : (
<img
src={copyStatus}
alt="Copy"
src={copyImage}
alt="Copy Link"
className="absolute inset-0 w-full h-full object-contain group-hover:scale-110"
/>
)}
Expand Down

0 comments on commit f3ce3f6

Please sign in to comment.