Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review and Merge PR for Copy Button Feature #34

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/pages/add-dock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import { desktopAppDownloadLink } from "utils/constants";
import { useSession } from "next-auth/react";
import { api } from "../utils/api";

const copyToClipboard = async (text) => {
try {
await navigator.clipboard.writeText(text);
// Optional: Display feedback to the user
alert('Command copied to clipboard!');
} catch (err) {
console.error('Failed to copy: ', err);
}
};

const AddDock = () => {
const { data: sessionData } = useSession();
const user = api.users.getOne.useQuery({ id: sessionData?.user?.id ?? "" });
Expand Down Expand Up @@ -62,9 +72,17 @@ const AddDock = () => {
To add your own dock, run the following command in your{" "}
<Link href="/apps/Terminal">terminal</Link>:
</p>
<code className="mb-8 w-full rounded border bg-black p-4">
npx dockhunt
</code>
<div className="flex items-center">
<code className="mb-8 w-full rounded border bg-black p-4">
npx dockhunt
</code>
<button
onClick={() => copyToClipboard('npx dockhunt')}
className="ml-2 rounded bg-blue-500 px-2 py-1 text-white hover:bg-blue-400"
>
Copy
</button>
</div>
<p className="mb-2 text-xl">The command will:</p>
<ol className="mb-8 list-decimal pl-8 text-xl">
<li>Find the apps in your dock</li>
Expand Down Expand Up @@ -108,4 +126,4 @@ const AddDock = () => {
);
};

export default AddDock;
export default AddDock;