//Lib import React from 'react'; import { useState } from 'react'; import classes from './QuickCommands.module.css'; import { IconSettingsAutomation, IconCopy } from '@tabler/icons'; export default function QuickCommands(props) { //State const [isCopied, setIsCopied] = useState(false); //Functions const handleCopy = async () => { // Asynchronously call copy to clipboard navigator.clipboard .writeText( `borg init -e repokey-blake2 ssh://${props.unixUser}@${process.env.NEXT_PUBLIC_HOSTNAME}:${process.env.NEXT_PUBLIC_SSH_SERVER_PORT}/./${props.repository}` ) .then(() => { // If successful, update the isCopied state value setIsCopied(true); setTimeout(() => { setIsCopied(false); }, 1500); }) .catch((err) => { console.log(err); }); }; return (
{isCopied ? (
Copied !
) : (
borg init -e repokey-blake2 ssh://{props.unixUser}@ {process.env.NEXT_PUBLIC_HOSTNAME}: {process.env.NEXT_PUBLIC_SSH_SERVER_PORT}/./ {props.repository}
)}
); }