From 2f341c3b8d6b9746a027a566cdc88964a0b57ed6 Mon Sep 17 00:00:00 2001 From: Ryan Lucchese Date: Sun, 17 Dec 2017 13:18:54 -0700 Subject: [PATCH] start of proposal creator forms --- src/App.css | 7 +++ src/App.js | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 136 insertions(+), 4 deletions(-) diff --git a/src/App.css b/src/App.css index 8a5d639..ae69839 100644 --- a/src/App.css +++ b/src/App.css @@ -18,5 +18,12 @@ } .App-intro { + text-align: left; + font-size: large; +} + +.App-proposalForm +{ + text-align: left; font-size: large; } diff --git a/src/App.js b/src/App.js index 945b86b..83b461a 100644 --- a/src/App.js +++ b/src/App.js @@ -1,17 +1,142 @@ +/* Energi Proposal Creator +* +* The following JSON represents an Energi proposal object that can be submitted to the blockchain. +* The purpose of this app is to create and validate this data based on user input, and then prepare +* the commands a user would use to submit this object to the Energi blockchain. + +[ + [ + "proposal", + { + "end_epoch":1521329930, + "name":"TITLE", + "payment_address":"someaddr", + "payment_amount":1337, + "start_epoch":1513603490, + "type":1, + "url":"https://example.com/title-proposal" + } + ] +] +*/ + import React, { Component } from 'react'; import logo from './logo256.png'; import './App.css'; -class App extends Component { - render() { +class App extends Component +{ + constructor(props) + { + super(props); + + // there are 26 payment cycles annually for Energi, so this would be 1 year worth of payments. + this.maximumNumberOfPaymentCycles = 26; + + this.gobj = + [ + [ + "proposal", + { + "end_epoch": 0, + "name": "", + "payment_address": "", + "payment_amount": 0, + "start_epoch": 0, + "type": 1, + "url": "" + } + ] + ]; + + // reference to internal proposal data we need to modify for convenience + this.state = this.gobj[0][1]; + + this.handleInputChange = this.handleInputChange.bind(this); + } + + handleInputChange(event) + { + const target = event.target; + const value = target.type == 'checkbox' ? target.checked : target.value; + const name = target.name; + + this.setState({[name]: value}); + this.gobj[0][1] = this.state; + } + + getBudgetCycleStartDates() + { + let budgetCycleStartDates = [ 0, 1, 2, 3 ]; + let htmlOptionTags = []; + for (let i = 0; i < budgetCycleStartDates.length; i++) + { + htmlOptionTags.push(); + } + return htmlOptionTags; + } + + getNumberOfPayments() + { + let htmlOptionTags = []; + for (let i = 1; i <= this.maximumNumberOfPaymentCycles; i++) + { + htmlOptionTags.push(); + } + return htmlOptionTags; + } + + render() + { return (
logo -

Welcome to React

+

Energi Proposal Creator

+
+
+ +
+ +
+ +
+ +
+ +
+ +
+
+

- To get started, edit src/App.js and save to reload. + Proposal JSON: +

+            { JSON.stringify(this.gobj, null, "\t") }
+          

);