-
Notifications
You must be signed in to change notification settings - Fork 51
- FIRE - Stacy's Exquisite #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0a94802
6c15012
0c525db
72edf1f
feaceb7
f32c964
6d1a48d
7dcda5b
5c4e618
85a3bed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,54 @@ | ||
import React, { useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import './PlayerSubmissionForm.css'; | ||
|
||
const PlayerSubmissionForm = () => { | ||
return ( | ||
<div className="PlayerSubmissionForm"> | ||
<h3>Player Submission Form for Player #{ }</h3> | ||
|
||
<form className="PlayerSubmissionForm__form" > | ||
const PlayerSubmissionForm = (props) => { | ||
|
||
const [formFields, setFormFields] = useState(props.fields) | ||
|
||
const onFormFieldChange = (i, event) => { | ||
const newFormFields = [ | ||
...formFields | ||
]; | ||
newFormFields[i] = { | ||
...newFormFields[i], | ||
userInput: event.target.value | ||
}; | ||
setFormFields(newFormFields); | ||
}; | ||
|
||
const onFormSubmit = (event) => { | ||
event.preventDefault(); | ||
props.sendSubmission(formFields); | ||
setFormFields(props.fields); | ||
} | ||
const poemInputs = formFields.map((field, i) => { | ||
if (field.key) { | ||
return ( | ||
<input | ||
key={field.key} | ||
name={field.key} | ||
placeholder={field.placeholder} | ||
type="text" | ||
value={field.userInput} | ||
onChange={(event) => {onFormFieldChange(i,event)}} | ||
className={field.userInput ? '' : 'PlayerSubmissionForm__input--invalid' } | ||
/> | ||
)} else { | ||
return (field) | ||
} | ||
}); | ||
|
||
if (!props.isSubmitted) { | ||
return ( | ||
<div className="PlayerSubmissionForm"> | ||
<h3>Player Submission Form for Player #{ props.index }</h3> | ||
< form className = "PlayerSubmissionForm__form" | ||
onSubmit = {onFormSubmit} > | ||
|
||
<div className="PlayerSubmissionForm__poem-inputs"> | ||
|
||
{ | ||
// Put your form inputs here... We've put in one below as an example | ||
} | ||
<input | ||
placeholder="hm..." | ||
type="text" /> | ||
|
||
{poemInputs} | ||
</div> | ||
|
||
<div className="PlayerSubmissionForm__submit"> | ||
|
@@ -27,11 +57,15 @@ const PlayerSubmissionForm = () => { | |
</form> | ||
</div> | ||
); | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
PlayerSubmissionForm.propTypes = { | ||
index: PropTypes.number.isRequired, | ||
sendSubmission: PropTypes.func.isRequired, | ||
isSubmitted: PropTypes.bool.isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note, that because you've added this prop the tests are giving a warning because the tests aren't using. If you add that prop to the tests, the warning will stop. |
||
fields: PropTypes.arrayOf(PropTypes.oneOfType([ | ||
PropTypes.string, | ||
PropTypes.shape({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,16 +3,20 @@ import PropTypes from 'prop-types'; | |
import './RecentSubmission.css'; | ||
|
||
const RecentSubmission = (props) => { | ||
return ( | ||
<div className="RecentSubmission"> | ||
<h3>The Most Recent Submission</h3> | ||
<p className="RecentSubmission__submission">{ }</p> | ||
if (!props.isSubmitted && props.submission) { | ||
return ( | ||
<div className = "RecentSubmission" > | ||
<h3> The Most Recent Submission </h3> | ||
<p className = "RecentSubmission__submission" > {props.submission} </p> | ||
</div> | ||
); | ||
} | ||
) | ||
} else { | ||
return (null) | ||
}} | ||
|
||
RecentSubmission.propTypes = { | ||
submission: PropTypes.string.isRequired, | ||
isSubmitted: PropTypes.bool.isRequired, | ||
Comment on lines
18
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also if you're not using |
||
}; | ||
|
||
export default RecentSubmission; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stringFormat is a function here, so you can't render it. I'm not sure what this is supposed to do.