Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Components/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Feature = ({ features, index, setFeatures, editable }) => {
updatedFeature.downVoted = false;
let newVote = updatedFeature.upVoted ? 1 : (updatedFeature.downVoted ? -1 : 0);
updatedFeature.votes = updatedFeature.votes - currentVote + newVote;
setFeatures(features.map((feature) => feature._id === features[index]._id ? updatedFeature : feature));
setFeatures(features.map((feature) => feature.id === features[index].id ? updatedFeature : feature));
};
const downVote = () => {
const updatedFeature = { ...features[index] };
Expand All @@ -28,7 +28,7 @@ const Feature = ({ features, index, setFeatures, editable }) => {
updatedFeature.upVoted = false;
let newVote = updatedFeature.upVoted ? 1 : (updatedFeature.downVoted ? -1 : 0);
updatedFeature.votes = updatedFeature.votes - currentVote + newVote;
setFeatures(features.map((feature) => feature._id === features[index]._id ? updatedFeature : feature));
setFeatures(features.map((feature) => feature.id === features[index].id ? updatedFeature : feature));
};
const capitalizeFirstLetter = (string) => {
return string.charAt(0).toUpperCase() + string.slice(1);
Expand Down
88 changes: 79 additions & 9 deletions src/Components/ProjectForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Owner

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.

Suggested change
import Button from '@mui/material/Button';
import Button from "@mui/material/Button";

import Service from "../Service";
import FilledInput from '@mui/material/FilledInput';
Copy link
Owner

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.

Suggested change
import FilledInput from '@mui/material/FilledInput';
import FilledInput from "@mui/material/FilledInput";

import InputAdornment from '@mui/material/InputAdornment';
Copy link
Owner

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.

Suggested change
import InputAdornment from '@mui/material/InputAdornment';
import InputAdornment from "@mui/material/InputAdornment";

import FormControl from '@mui/material/FormControl';
Copy link
Owner

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.

Suggested change
import FormControl from '@mui/material/FormControl';
import FormControl from "@mui/material/FormControl";

import { useHistory } from "react-router-dom";

const Styles = styled.div`
background: #218888;
Expand All @@ -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;
Expand All @@ -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 {
Expand All @@ -45,6 +52,7 @@ const Styles = styled.div`
font-size: 14px;
font-weight: 500;
margin-bottom: 5px;
width: 100%;
}

.error {
Expand All @@ -60,6 +68,13 @@ const Styles = styled.div`
font-family: sans-serif;
font-size: 14px;
margin: 20px 0px;
}

Button{
background-color: #218888;
}


`;

//
Expand All @@ -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 = () =>{
Copy link
Owner

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: Missing space after =>.

Suggested change
const handleRoute = () =>{
const handleRoute = () => {

history.push("/dashboard");
}

React.useEffect(() => {
setUser(ReactSession.get("username"));
Expand All @@ -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)
Expand All @@ -114,7 +148,7 @@ function ProjectForm() {
}
}).catch(function(err){
setMessage("There was a problem submitting your product. Please try again later.")
});
});
}

return (
Expand All @@ -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'}}
Copy link
Owner

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.

Suggested change
style={{ color:'#218888'}}
style={{ color:"#218888"}}

/>
<br />
<label>Description</label>
<TextField
id="description"
id="filled-basic"
variant="filled"
label=""
multiline
rows={3}
Expand All @@ -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}
Expand All @@ -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}
Expand All @@ -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()}} >
Copy link
Owner

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: Missing semicolon.

Suggested change
<Button variant="contained" size="large" data-testid="submit_button" onClick={()=>{handleSubmit();handleRoute()}} >
<Button variant="contained" size="large" data-testid="submit_button" onClick={()=>{handleSubmit();handleRoute();}} >

Copy link
Owner

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: Missing space before =>.

Suggested change
<Button variant="contained" size="large" data-testid="submit_button" onClick={()=>{handleSubmit();handleRoute()}} >
<Button variant="contained" size="large" data-testid="submit_button" onClick={() =>{handleSubmit();handleRoute()}} >

Submit
</Button>
{/* <button data-testid="submit_button" onClick={handleSubmit}>Submit</button> */}
</form>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/Service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const baseUrl = "http://localhost:5000/";
//const baseUrl = "https://damp-citadel-25681.herokuapp.com/"
// const baseUrl = "http://localhost:5000/";
const baseUrl = "https://damp-citadel-25681.herokuapp.com/"

// const requestOptionsBuilder = (method, body, headers) => {
// let options = {
Expand Down