refactor: added copy-to-clipboard library and replaced navigator.clipboard.writeText with copy function

This commit is contained in:
vishalkadam47
2025-01-31 20:31:16 +05:30
parent 41a8014585
commit 2c6c89e4c1
2 changed files with 5 additions and 3 deletions

View File

@@ -51,7 +51,8 @@ import Link from "next/link";
import { useRouter } from "next/router";
import React, { useState, useEffect, type ReactElement } from "react";
import { toast } from "sonner";
import superjson from "superjson";
import superjson from "superjson";
import copy from 'copy-to-clipboard';
type TabState =
| "projects"
@@ -142,7 +143,7 @@ const Service = (
className="cursor-pointer"
onClick={() => {
if (data?.server?.ipAddress) {
navigator.clipboard.writeText(data.server.ipAddress);
copy(data.server.ipAddress);
toast.success("IP Address Copied!");
}
}}

View File

@@ -45,6 +45,7 @@ import { useRouter } from "next/router";
import React, { useState, useEffect, type ReactElement } from "react";
import superjson from "superjson";
import { toast } from "sonner";
import copy from 'copy-to-clipboard';
type TabState =
| "projects"
@@ -135,7 +136,7 @@ const Service = (
className="cursor-pointer"
onClick={() => {
if (data?.server?.ipAddress) {
navigator.clipboard.writeText(data.server.ipAddress);
copy(data.server.ipAddress);
toast.success("IP Address Copied!");
}
}}