Skip to content

Instantly share code, notes, and snippets.

@MarlikAlmighty
Created January 12, 2023 19:56
Show Gist options
  • Select an option

  • Save MarlikAlmighty/dcbbfed7ae86d727217192651f2e9190 to your computer and use it in GitHub Desktop.

Select an option

Save MarlikAlmighty/dcbbfed7ae86d727217192651f2e9190 to your computer and use it in GitHub Desktop.

Revisions

  1. MarlikAlmighty created this gist Jan 12, 2023.
    78 changes: 78 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,78 @@
    import React from "react";
    import axios from "axios";
    import 'semantic-ui-css/semantic.min.css';
    import {
    Form,
    Button,
    GridRow,
    Grid,
    Container,
    } from "semantic-ui-react";
    import Nav from "./Nav";
    import List from './List';
    import Footer from "./Footer";

    const options = [
    { key: 'eth', text: 'Ethereum', value: 'eth' },
    { key: 'ethsolo', text: 'Ethereum SOLO', value: 'ethsolo' },
    { key: 'ethpow', text: 'Ethereum PoW', value: 'ethpow' },
    ]

    export default class App extends React.Component {

    state = {
    addr: '',
    pool: '',
    }

    handleChangePool = (event, { value }) => {
    this.setState({ pool: value });
    };

    handleChangeAddr = event => {
    this.setState({ addr: event.target.value });
    }

    handleSubmit = event => {

    event.preventDefault();

    axios.post(`/address`, { pool: this.state.pool, addr: this.state.addr })
    .then(() => {
    this.setState({ addr: "" });
    this.setState({ pool: "" });
    })
    .catch(res => {
    console.log(res.status + res.statusText);
    });
    };

    render() {
    return (
    <div>
    <Form onSubmit={this.handleSubmit}>
    <Form.Field>
    <Form.Select
    label='Select Pool'
    options={options}
    placeholder='Select Pool'
    onChange={this.handleChangePool} />
    <label>Paste Address</label>
    <input
    name='addr'
    placeholder='Paste Address'
    onChange={this.handleChangeAddr} />
    </Form.Field>
    <Button
    basic
    compact
    color="teal"
    floated="right"
    className="ui button">
    Submit
    </Button>
    </Form>
    </div >
    );
    }
    }