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
Create add poem feature #73
Conversation
Relates #33
const [title, setTitle] = React.useState(""); | ||
const [poem, setPoem] = React.useState(""); | ||
const [error, setError] = React.useState(false); | ||
const [typeError, setTypeError] = React.useState(false); |
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.
I think there is no type in the poem
const [typeError, setTypeError] = React.useState(false); | ||
const [fetchError, setFetchError] = React.useState(false); | ||
const [buttonContent, setButtonContent] = React.useState("Save"); | ||
const acceptedTypes = ""; |
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.
type for what? 🤔
fetch: "Sorry something went wrong, Please try again" | ||
}; | ||
|
||
let type = poem.name.split(".")[poem.name.split(".").length - 1]; |
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.
I think for the poem just has title and content
|
||
setButtonContent("Loading..."); | ||
|
||
const poemData = new poemData(); |
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.
there is no class name is poemData
Do you mean FormData
?? 🤔
<label htmlFor="new-poem__text">Add a poem</label> | ||
<input | ||
id="mew-poem__text" | ||
type="text" |
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.
I think best if we put the type textarea
<input | ||
id="mew-poem__text" | ||
type="text" | ||
onChange={e => setPoem(e.target.poems[0])} |
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.
mmmm there is poems
inside the target
🙄
<a href="/poems" className="large-skip__button"> | ||
Back | ||
</a> | ||
<button className="large-save__button" type="submit"> |
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.
I think there is Button
Component why don't use it and where the onClick
for this button
)} | ||
{fetchError && <p className="add-poem__error">{message.fetch}</p>} | ||
<div className="add-poem__form__button"> | ||
<a href="/poems" className="large-skip__button"> |
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.
why use a
tag also there is Button
component and use props.history.goBack()
const message = { | ||
default: "Please add a title and add a poem", | ||
tyrebased: | ||
"Please upload a different poem, we do not support that poem type", |
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.
I think there is no uploading in this file. 🤔
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.
You never pushed your last commit, I remember you changed it a lot. Easily done.
const [title, setTitle] = React.useState(""); | ||
const [poem, setPoem] = React.useState(""); | ||
const [error, setError] = React.useState(false); | ||
const [typeError, setTypeError] = React.useState(false); |
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.
This line is not necessary
const [typeError, setTypeError] = React.useState(false); |
e.preventDefault(); | ||
|
||
if ((title === "") | (poem === "")) { | ||
console.log(title, poem); |
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.
console.log(title, poem); |
|
||
setButtonContent("Loading..."); | ||
|
||
fetch("/api/v1/send-poem", { |
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.
can you change the api url to /api/v1/poems
? It is a best practise to use restful apis.
Here is a link if you're interested:
https://restfulapi.net/resource-naming/
}} | ||
/> | ||
|
||
<Input |
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.
As shorouq said, it is better to have textarea instead of input?
Relates #33