Added copy invite link function

This commit is contained in:
Kristoffer Longva Eriksen 2022-03-23 09:04:11 +01:00
parent e544621639
commit b02b45c17a
3 changed files with 20 additions and 7 deletions

View File

@ -9550,6 +9550,11 @@
"warning": "^4.0.3" "warning": "^4.0.3"
} }
}, },
"react-custom-alert": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/react-custom-alert/-/react-custom-alert-0.1.2.tgz",
"integrity": "sha512-VkxPh4loaDzeQ4THauq5qOETr/SL/4L+4k1Ie3C948nSgxCy0CSY7MKrzkFwiwIiYCxib3/60zIqmTLUECHEww=="
},
"react-dev-utils": { "react-dev-utils": {
"version": "12.0.0", "version": "12.0.0",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz", "resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.0.tgz",

View File

@ -14,6 +14,7 @@
"iarn": "0.0.0", "iarn": "0.0.0",
"react": "^17.0.2", "react": "^17.0.2",
"react-bootstrap": "^2.2.1", "react-bootstrap": "^2.2.1",
"react-custom-alert": "^0.1.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-router-dom": "^6.2.2", "react-router-dom": "^6.2.2",
"react-scripts": "5.0.0", "react-scripts": "5.0.0",

View File

@ -1,5 +1,6 @@
import * as React from "react"; import * as React from "react";
import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom"; import { BrowserRouter as Router, Link, Route, Routes } from "react-router-dom";
import { AlertContainer, alert } from "react-custom-alert";
import HomeImage from "./components/homeimage"; import HomeImage from "./components/homeimage";
import SaveButton from "./components/savebutton"; import SaveButton from "./components/savebutton";
@ -39,18 +40,23 @@ function AnnounceButton(props) {
} }
function InviteButton(props) { function InviteButton(props) {
function event() {
copy();
alertSuccess();
}
const copy = () => {
navigator.clipboard.writeText("discord.gg/asura");
};
const alertSuccess = () =>
alert({ message: "Copied to clipboard.", type: "success" });
return ( return (
<button <button id="createInvLink" onClick={event}>
id="createInvLink" Copy Invite Link
onClick={() => {
return <div>Hei</div>;
}}
>
Create Invite Link
</button> </button>
); );
} }
//navigator.clipboard.writeText("discord.gg/asura")
export default function TournamentManager() { export default function TournamentManager() {
return ( return (
<React.Fragment> <React.Fragment>
@ -59,6 +65,7 @@ export default function TournamentManager() {
<AnnounceButton /> <AnnounceButton />
<InviteButton /> <InviteButton />
<SaveButton /> <SaveButton />
<AlertContainer floatingTime={5000} />
</React.Fragment> </React.Fragment>
); );
} }