From 485f4bee29fbd94a4db731f9a19c13d767c1233a Mon Sep 17 00:00:00 2001 From: timka Date: Wed, 22 Nov 2023 22:43:18 +0300 Subject: [PATCH] totally complete add link --- src/components/AddLink.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/AddLink.js b/src/components/AddLink.js index 09da7c2..c07da4c 100644 --- a/src/components/AddLink.js +++ b/src/components/AddLink.js @@ -8,7 +8,7 @@ import axios from 'axios' class AddLink extends Component { constructor(props) { super(props); - this.state = {value: ''} + this.state = {value: '', buttonText: 'Short!'} this.handleChange = this.handleChange.bind(this) this.short = this.short.bind(this) this.createLink = this.createLink.bind(this) @@ -24,7 +24,10 @@ class AddLink extends Component { } var linkName = makeid(6) this.createLink(this.state.value, linkName) - this.setState({value: `https://timka.su/${linkName}`}) + const link = `https://timka.su/${linkName}` + this.setState({value: link}) + navigator.clipboard.writeText(link) + this.setState({buttonText: 'Copied!'}) } createLink(url, linkName) { @@ -46,7 +49,7 @@ class AddLink extends Component { autoComplete="off" required />
- + }