forked from near/bwe-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from trechriron/trentin-progress-wed
WED Progress
- Loading branch information
Showing
7 changed files
with
366 additions
and
41 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
const formStyles = { | ||
row: { | ||
display: "flex", | ||
flexDirection: "row", | ||
justifyContent: "space-around", | ||
alignItems: "center", | ||
padding: "10px", | ||
width: "100%", | ||
}, | ||
column: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "space-around", | ||
padding: "10px", | ||
}, | ||
columnText: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "space-around", | ||
padding: "10px", | ||
width: "50%", | ||
}, | ||
textField: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "space-around", | ||
alignItems: "center", | ||
padding: "10px", | ||
}, | ||
checkboxField: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "space-around", | ||
alignItems: "left", | ||
padding: "10px", | ||
}, | ||
formLabel: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "space-around", | ||
alignItems: "center", | ||
padding: "10px", | ||
}, | ||
button: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
margin: "10px", | ||
}, | ||
listHeading: { | ||
fontWeight: "bold", | ||
fontSize: "1.2rem", | ||
}, | ||
list: { | ||
|
||
}, | ||
paragraph: { | ||
display: "flex", | ||
padding: "5px", | ||
}, | ||
}; | ||
|
||
const [formData, setFormData] = useState({ | ||
textField1: '', | ||
textField2: '', | ||
textField3: '', | ||
textField4: '', | ||
textField5: '', | ||
checkbox1: false, | ||
checkbox2: false, | ||
checkbox3: false, | ||
checkbox4: false, | ||
checkbox5: false, | ||
label1: 'Requires Provider Data Lake', | ||
label2: 'Requires Sharded Database', | ||
label3: 'Requires Provider MPC Service', | ||
label4: 'Requires Provider Indexer', | ||
label5: 'Requires Provider RPC Service', | ||
}); | ||
|
||
const handleChange = (e) => { | ||
const { name, value, type, checked } = e.target; | ||
setFormData((prevData) => ({ | ||
...prevData, | ||
[name]: type === 'checkbox' ? checked : value, | ||
})); | ||
}; | ||
|
||
const handleSubmit = (e) => { | ||
props.submitDeveloperProfile(formData); | ||
|
||
// Basic form validation - check if all text fields are filled | ||
const isFormValid = Object.values(formData).every((value) => value !== ''); | ||
|
||
if (isFormValid) { | ||
props.setDeveloperProfile(formData); | ||
} else { | ||
console.warn('The form was not submitted. Please fill in all fields.'); | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div style={formStyles.row}> | ||
<div style={formStyles.columnText}> | ||
<p style={formStyles.paragraph}>To better help you estimate the cost of your project, please fill out the form below. Each phase represents a milestone in the development process. | ||
</p> | ||
<span style={formStyles.listHeading}>Example Phases:</span> | ||
<div style={formStyles.list}> | ||
<li>Phase 1: Prototype</li> | ||
<li>Phase 2: Beta</li> | ||
<li>Phase 3: Alpha Release</li> | ||
<li>Phase 4: First 6 months</li> | ||
<li>Phase 5: 12 months after Phase 4</li> | ||
</div> | ||
</div> | ||
<div style={formStyles.columnText}> | ||
<p style={formStyles.paragraph}>The number provided = the number of active users per minute. For example, if you expect 100 users to be using your app per minute, enter 100. You can break down your estimate into 5 phases. Leave any unused fields blank. | ||
</p> | ||
<p style={formStyles.paragraph}> | ||
Please check the boxes that apply to your project. If you are unsure, leave the box unchecked. | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<form onSubmit={handleSubmit}> | ||
{/* Text Fields */} | ||
<div style={formStyles.row}> | ||
{Array.from({ length: 5 }, (_, index) => ( | ||
<div key={index} style={formStyles.column}> | ||
<label style={formStyles.formLabel} htmlFor={`textField${index + 1}`}>{`Phase ${index + 1}:`}</label> | ||
<input | ||
style={formStyles.textField} | ||
type="text" | ||
id={`textField${index + 1}`} | ||
name={`textField${index + 1}`} | ||
value={formData[`textField${index + 1}`]} | ||
onChange={handleChange} | ||
// required | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{/* Checkboxes */} | ||
<div style={formStyles.row}> | ||
{Array.from({ length: 5 }, (_, index) => ( | ||
<div key={index} style={formStyles.column}> | ||
<label style={formStyles.formLabel}> | ||
<input | ||
style={formStyles.checkboxField} | ||
type="checkbox" | ||
name={`checkbox${index + 1}`} | ||
checked={formData[`checkbox${index + 1}`]} | ||
onChange={handleChange} | ||
/> | ||
{formData[`label${index + 1}`]} | ||
</label> | ||
</div> | ||
))} | ||
</div> | ||
|
||
{/* Submit Button */} | ||
<div style={formStyles.row}> | ||
<button type="submit" style={formStyles.button}>Submit</button> | ||
</div> | ||
</form> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const [developerProfile, setDeveloperProfile] = useState(null); | ||
const [headerText, setHeaderText] = useState(null); | ||
|
||
const devStyles = { | ||
header: { | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
height: "100%", | ||
width: "100%", | ||
fontSize: "2rem", | ||
}, | ||
body: { | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
height: "300px", | ||
width: "100%", | ||
}, | ||
}; | ||
|
||
{!developerProfile && ( | ||
setHeaderText("Enter Project Metrics") | ||
)} | ||
{developerProfile && ( | ||
setHeaderText("Project Cost Estimate") | ||
)} | ||
|
||
return ( | ||
<div> | ||
<Widget src="monkeypatcher.near/App.Header" trust={{ mode: "trusted-author" }} /> | ||
<h1 style={devStyles.header}>{headerText}</h1> | ||
<div> | ||
{!developerProfile && ( | ||
<Widget | ||
src="monkeypatcher.near/App.DevFormComponent" | ||
props={{ | ||
submitDeveloperProfile: (formData) => { | ||
setDeveloperProfile(formData); | ||
}, | ||
}} | ||
/> | ||
)} | ||
{developerProfile && ( | ||
<Widget | ||
src="monkeypatcher.near/App.DevResultPage" | ||
props={{ | ||
developerProfile | ||
}} | ||
/> | ||
)} | ||
</div> | ||
<div><Widget src="monkeypatcher.near/App.Footer" trust={{ mode: "trusted-author" }} /></div> | ||
</div> | ||
); |
Oops, something went wrong.