wire up skylink input

This commit is contained in:
Karol Wypchlo 2020-02-13 18:30:36 -05:00
parent 756df40d6e
commit 0fbdd8fd01
2 changed files with 13 additions and 3 deletions

View File

@ -58,6 +58,16 @@ export default class HomeUpload extends Component {
}); });
}; };
handleSkylink = (event) => {
event.preventDefault();
const skylink = event.target.skylink.value.replace('sia://', '');
if(skylink.length === 46) {
window.open(`/${event.target.skylink.value}`, '_blank');
}
}
render() { render() {
return ( return (
<Reveal effect="active"> <Reveal effect="active">
@ -104,8 +114,8 @@ export default class HomeUpload extends Component {
<h3>Have a Skylink?</h3> <h3>Have a Skylink?</h3>
<p>Enter the ID to retrieve the file</p> <p>Enter the ID to retrieve the file</p>
<form className="home-upload-retrieve-form"> <form className="home-upload-retrieve-form" onSubmit={this.handleSkylink}>
<input type="text" placeholder="sia://" /> <input name="skylink" type="text" placeholder="sia://" />
<button type="submit"> <button type="submit">
<DownArrow /> <DownArrow />
</button> </button>

View File

@ -1,4 +1,4 @@
import React, { Component } from 'react' import React from 'react'
import MailchimpSubscribe from 'react-mailchimp-subscribe' import MailchimpSubscribe from 'react-mailchimp-subscribe'
import classNames from 'classnames' import classNames from 'classnames'