aboutsummaryrefslogtreecommitdiff
path: root/src/NewThread.js
diff options
context:
space:
mode:
authorLibravatar Renard 2019-10-01 01:15:54 -0300
committerLibravatar Renard 2019-10-01 01:15:54 -0300
commit9131d4ab9489c8a1abe05a701605c8348d6277a8 (patch)
treee7a721f9dbececda86ecc30d686f8de1ffe4426b /src/NewThread.js
parent97bf3d24c8dd2343ba57d3e6bdd6d48b9eae3ff6 (diff)
downloadbai-client-9131d4ab9489c8a1abe05a701605c8348d6277a8.tar.gz
bai-client-9131d4ab9489c8a1abe05a701605c8348d6277a8.tar.xz
bai-client-9131d4ab9489c8a1abe05a701605c8348d6277a8.zip
Avances creación de hilos
Diffstat (limited to 'src/NewThread.js')
-rw-r--r--src/NewThread.js122
1 files changed, 122 insertions, 0 deletions
diff --git a/src/NewThread.js b/src/NewThread.js
new file mode 100644
index 0000000..c76f515
--- /dev/null
+++ b/src/NewThread.js
@@ -0,0 +1,122 @@
+import React, { Component } from "react";
+import {
+ Segment,
+ Button,
+ Form,
+ Icon,
+ Checkbox,
+ Header
+} from "semantic-ui-react";
+
+class NewThread extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ subject: "",
+ name: "",
+ email: "",
+ message: "",
+ attachment: "",
+ selectedFile: null,
+ isSpoiler: false
+ };
+ this.handleChange = this.handleChange.bind(this);
+ }
+
+ handleChange(e) {
+ const { name, value } = e.target;
+ this.setState({ [name]: value });
+ }
+
+ render() {
+ const { boardList, dir } = this.props;
+ const {
+ subject,
+ name,
+ email,
+ message,
+ attachment,
+ selectedFile,
+ isSpoiler
+ } = this.state;
+ const currentBoard = boardList.find(board => {
+ return board.dir === dir;
+ });
+
+ return (
+ <Segment inverted={this.props.nightMode}>
+ <Header as="h2" dividing>
+ Crear un nuevo hilo en {currentBoard.name}
+ </Header>
+ <Form inverted={this.props.nightMode}>
+ {currentBoard.disable_subject === 0 && (
+ <Form.Input
+ id="subject"
+ name="subject"
+ label="Asunto"
+ value={subject}
+ onChange={this.handleChange}
+ />
+ )}
+ <Form.Group widths="equal">
+ {currentBoard.disable_name === 0 && (
+ <Form.Input
+ id="name"
+ name="name"
+ label="Nombre"
+ value={name}
+ onChange={this.handleChange}
+ />
+ )}
+ <Form.Input
+ id="email"
+ name="email"
+ label="E-mail"
+ value={email}
+ onChange={this.handleChange}
+ />
+ {currentBoard.allow_image_replies === 1 && (
+ <React.Fragment>
+ <input
+ id="hiddenInput"
+ name="hiddenInput"
+ type="file"
+ hidden
+ onChange={this.handleChange}
+ multiple={false}
+ />
+ <Form.Button
+ label="Adjunto"
+ fluid
+ value={attachment}
+ onClick={this.handleClick}
+ >
+ <Icon name="attach" />
+ {selectedFile === null ? "Adjuntar archivo" : selectedFile}
+ </Form.Button>
+ </React.Fragment>
+ )}
+ </Form.Group>
+ <Form.TextArea
+ name="message"
+ value={message}
+ label="Mensaje"
+ placeholder="( ・ω・) Cuentáme algo interesante ..."
+ onChange={this.handleChange}
+ rows={7}
+ />
+ {currentBoard.allow_spoilers === 1 && (
+ <Checkbox
+ label="El archivo adjunto es un spoiler"
+ checked={isSpoiler}
+ className="spoilerCheckbox"
+ />
+ )}
+ <Button type="submit">Crear nuevo hilo</Button>
+ </Form>
+ </Segment>
+ );
+ }
+}
+
+export default NewThread;