-
Notifications
You must be signed in to change notification settings - Fork 3
Fixed project submission form redirect #20
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,12 @@ import React from 'react'; | |||||||||
| import { ReactSession } from "react-client-session"; | ||||||||||
| import styled from "styled-components"; | ||||||||||
| import TextField from "@mui/material/TextField"; | ||||||||||
| import Button from '@mui/material/Button'; | ||||||||||
| import Service from "../Service"; | ||||||||||
| import FilledInput from '@mui/material/FilledInput'; | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Strings must use doublequote.
Suggested change
|
||||||||||
| import InputAdornment from '@mui/material/InputAdornment'; | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Strings must use doublequote.
Suggested change
|
||||||||||
| import FormControl from '@mui/material/FormControl'; | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Strings must use doublequote.
Suggested change
|
||||||||||
| import { useHistory } from "react-router-dom"; | ||||||||||
|
|
||||||||||
| const Styles = styled.div` | ||||||||||
| background: #218888; | ||||||||||
|
|
@@ -12,7 +17,7 @@ const Styles = styled.div` | |||||||||
| border-bottom: 1px solid white; | ||||||||||
| color: #6f6f6f; | ||||||||||
| font-family: sans-serif; | ||||||||||
| font-size: 20px; | ||||||||||
| font-size: 30px; | ||||||||||
| font-weight: 600; | ||||||||||
| line-height: 24px; | ||||||||||
| padding: 10px; | ||||||||||
|
|
@@ -22,12 +27,14 @@ const Styles = styled.div` | |||||||||
| form { | ||||||||||
| background: white; | ||||||||||
| border: 1px solid #dedede; | ||||||||||
| border-radius: 30px; | ||||||||||
| display: flex; | ||||||||||
| flex-direction: column; | ||||||||||
| justify-content: space-around; | ||||||||||
| margin: 0 auto; | ||||||||||
| max-width: 1000px; | ||||||||||
| padding: 50px 200px; | ||||||||||
| padding: 20px 100px; | ||||||||||
| padding-bottom: 60px; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| input { | ||||||||||
|
|
@@ -45,6 +52,7 @@ const Styles = styled.div` | |||||||||
| font-size: 14px; | ||||||||||
| font-weight: 500; | ||||||||||
| margin-bottom: 5px; | ||||||||||
| width: 100%; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| .error { | ||||||||||
|
|
@@ -60,6 +68,13 @@ const Styles = styled.div` | |||||||||
| font-family: sans-serif; | ||||||||||
| font-size: 14px; | ||||||||||
| margin: 20px 0px; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| Button{ | ||||||||||
| background-color: #218888; | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| `; | ||||||||||
|
|
||||||||||
| // | ||||||||||
|
|
@@ -77,6 +92,14 @@ function ProjectForm() { | |||||||||
| const [message, setMessage] = React.useState(""); | ||||||||||
| const [user, setUser] = React.useState([""]); | ||||||||||
| const [tags, setTags] = React.useState(""); | ||||||||||
| const [country, setCountry] = React.useState(""); | ||||||||||
| const [funding, setFunding] = React.useState(""); | ||||||||||
|
|
||||||||||
| const history=useHistory(); | ||||||||||
|
|
||||||||||
| const handleRoute = () =>{ | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Missing space after =>.
Suggested change
|
||||||||||
| history.push("/dashboard"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| React.useEffect(() => { | ||||||||||
| setUser(ReactSession.get("username")); | ||||||||||
|
|
@@ -98,11 +121,22 @@ function ProjectForm() { | |||||||||
| setTags(e.target.value); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const handleLaunchCountryChange = (e) => { | ||||||||||
| setCountry(e.target.value); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const handleFundingChange = (e) => { | ||||||||||
| setFunding(e.target.value); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
| const handleSubmit = (event) => { | ||||||||||
| const form = new FormData(); | ||||||||||
| form.append("productName", name); | ||||||||||
| form.append("productDescription", description); | ||||||||||
| form.append("lauchCountry", country); | ||||||||||
| form.append("imageUrl", imageURL); | ||||||||||
| form.append("initialFunding", imageURL); | ||||||||||
| form.append("email", user); | ||||||||||
| form.append("tags", tags); | ||||||||||
| Service.post("addProduct", form) | ||||||||||
|
|
@@ -114,7 +148,7 @@ function ProjectForm() { | |||||||||
| } | ||||||||||
| }).catch(function(err){ | ||||||||||
| setMessage("There was a problem submitting your product. Please try again later.") | ||||||||||
| }); | ||||||||||
| }); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return ( | ||||||||||
|
|
@@ -129,18 +163,22 @@ function ProjectForm() { | |||||||||
| <label>Name</label> | ||||||||||
| <TextField | ||||||||||
| data-testid="form_name" | ||||||||||
| id="name" | ||||||||||
| label="" | ||||||||||
| multiline | ||||||||||
| maxRows={1} | ||||||||||
| inputProps={{ "data-testid": "form-inputName" }} | ||||||||||
| value={name} | ||||||||||
| onChange={handleNameChange} | ||||||||||
| fullWidth | ||||||||||
| id="filled-basic" | ||||||||||
| variant="filled" | ||||||||||
| style={{ color:'#218888'}} | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Strings must use doublequote.
Suggested change
|
||||||||||
| /> | ||||||||||
| <br /> | ||||||||||
| <label>Description</label> | ||||||||||
| <TextField | ||||||||||
| id="description" | ||||||||||
| id="filled-basic" | ||||||||||
| variant="filled" | ||||||||||
| label="" | ||||||||||
| multiline | ||||||||||
| rows={3} | ||||||||||
|
|
@@ -149,9 +187,24 @@ function ProjectForm() { | |||||||||
| onChange={handleDescriptionChange} | ||||||||||
| fullWidth | ||||||||||
| /> | ||||||||||
| <br /> | ||||||||||
| <label>Country of launch</label> | ||||||||||
| <TextField | ||||||||||
| id="filled-basic" | ||||||||||
| variant="filled" | ||||||||||
| label="" | ||||||||||
| multiline | ||||||||||
| rows={1} | ||||||||||
| inputProps={{ "data-testid": "form-country" }} | ||||||||||
| value={country} | ||||||||||
| onChange={handleLaunchCountryChange} | ||||||||||
| fullWidth | ||||||||||
| /> | ||||||||||
| <br /> | ||||||||||
| <label>Image URL</label> | ||||||||||
| <TextField | ||||||||||
| id="imageURL" | ||||||||||
| id="filled-basic" | ||||||||||
| variant="filled" | ||||||||||
| label="" | ||||||||||
| multiline | ||||||||||
| maxRows={1} | ||||||||||
|
|
@@ -160,9 +213,23 @@ function ProjectForm() { | |||||||||
| onChange={handleImageURLChange} | ||||||||||
| fullWidth | ||||||||||
| /> | ||||||||||
| <br /> | ||||||||||
| <label>Initial Funding</label> | ||||||||||
| <FormControl fullWidth variant="filled"> | ||||||||||
| <FilledInput | ||||||||||
| id="filled-adornment-amount" | ||||||||||
| value={funding} | ||||||||||
| onChange={handleFundingChange} | ||||||||||
| startAdornment={<InputAdornment position={"start"}>$</InputAdornment>} | ||||||||||
| multiline | ||||||||||
| maxRows={1} | ||||||||||
| /> | ||||||||||
| </FormControl> | ||||||||||
| <br /> | ||||||||||
| <label>Tags</label> | ||||||||||
| <TextField | ||||||||||
| id="tags" | ||||||||||
| id="filled-basic" | ||||||||||
| variant="filled" | ||||||||||
| label="" | ||||||||||
| multiline | ||||||||||
| maxRows={1} | ||||||||||
|
|
@@ -171,8 +238,11 @@ function ProjectForm() { | |||||||||
| onChange={handleTagsChange} | ||||||||||
| fullWidth | ||||||||||
| /> | ||||||||||
|
|
||||||||||
| <button data-testid="submit_button" onClick={handleSubmit}>Submit</button> | ||||||||||
| <br /><br /> | ||||||||||
| <Button variant="contained" size="large" data-testid="submit_button" onClick={()=>{handleSubmit();handleRoute()}} > | ||||||||||
|
Owner
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. Codacy has a fix for the issue: Missing semicolon.
Suggested change
Owner
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. Codacy has a fix for the issue: Missing space before =>.
Suggested change
|
||||||||||
| Submit | ||||||||||
| </Button> | ||||||||||
| {/* <button data-testid="submit_button" onClick={handleSubmit}>Submit</button> */} | ||||||||||
| </form> | ||||||||||
| </div> | ||||||||||
| ); | ||||||||||
|
|
||||||||||
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.
Codacy has a fix for the issue: Strings must use doublequote.