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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added .DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions airbnb-optimal-price/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,21 @@
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"cloudinary": "^1.19.0",
"cloudinary-react": "^1.3.2",
"cors": "^2.8.5",
"create-react-app": "^3.4.0",
"express": "^4.17.1",
"express-fileupload": "^1.1.6",
"local-storage": "^2.0.0",
"material-ui": "^0.20.2",
"multer": "^1.4.2",
"nodemon": "^2.0.2",
"prettier": "^1.19.1",
"react": "^16.13.0",
"react-dom": "^16.13.0",
"react-focus-lock": "^2.2.1",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.0",
"styled-components": "^5.0.1"
Expand Down
13 changes: 9 additions & 4 deletions airbnb-optimal-price/src/App.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import React from 'react';

import React from "react";
import { Route, Switch } from "react-router-dom";
//Components
import Login from './components/Login'
import NavBar from "./navigation/NavBar";
import FormIndex from "./components/FormIndex";


function App() {
return (
<div className="App">
<Login />
<Switch>
<NavBar />
</Switch>
<FormIndex />
</div>
);
}
Expand Down
51 changes: 51 additions & 0 deletions airbnb-optimal-price/src/components/FormIndex.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React, { useState } from "react";
import Property from "./Property";
import PropertyForm from "./PropertyForm";
import styled from 'styled-components';

const StyledIndex = styled.div`
.container-div{

padding-left: 3vw;
padding-bottom:3vh;

}

`;
export default function FormIndex() {
const [photo, setPhoto] = useState([
{
selectedFile: null
}
]);
const [properties, setProperties] = useState([
{
id: 1,
title: "",
body: ""
}
]);
const addNewPropery = property => {
const newProperty = {
id: Date.now(),
title: property.title,
body: property.body
};
setProperties([...properties, newProperty]);
};
const addNewPhoto = photos => {
const newPhoto = {
selectedFile: photos.selectedFile
};
setPhoto([...photo, newPhoto]);
};
return (
<StyledIndex>
<div className="container-div">
<h1>Add Properties</h1>
<PropertyForm addNewPropery={addNewPropery} addNewPhoto={addNewPhoto} />
<Property properties={properties} />
</div>
</StyledIndex>
);
}
62 changes: 0 additions & 62 deletions airbnb-optimal-price/src/components/Login.js

This file was deleted.

16 changes: 16 additions & 0 deletions airbnb-optimal-price/src/components/Property.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";

const Property = props => {
return (
<div>
{props.properties.map(property => (
<div key={property.id}>
<h2>{property.title}</h2>
<p>{property.body}</p>
</div>
))}
</div>
);
};

export default Property;
138 changes: 138 additions & 0 deletions airbnb-optimal-price/src/components/PropertyForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
import React, { useState } from "react";
import PropertyUpload from "./PropertyUpload";
import Styled from'styled-components'

const styledForm = Styled.div`
display:block;
margin:auto;


`
const PropertyForm = props => {
const [property, setProperty] = useState({
title: "",
body: ""
});

const handleChanges = e => {
setProperty({
...property,
[e.target.name]: e.target.value
});
};

const submitForm = e => {
e.preventDefault();
props.addNewPropery(property);
setProperty({
title: "",
body: ""
});
};

return (
<styledForm>
<form onSubmit={submitForm}>
<lable htmlFor="title">Property Title</lable>
<br />
<input
id="title"
type="text"
name="title"
onChange={handleChanges}
placeholder="title"
value={property.title}
/>
<br />
<br />
<br />
<lable htmlFor="property">Summery the Property</lable>
<br />
<textarea
id="property"
name="body"
placeholder="Brief Summery of property."
onChange={handleChanges}
value={property.body}
/>
<br />

<label>Property Type</label>
<br />

<select name="propertyType" id="propertyType">
<option value>-Please select one-</option>
<option value="House">House</option>
<option value="">Apartment</option>
<option value="">Villa</option>
<option value="">Hotel</option>
<option value="">Couch</option>
<option value="">Tent</option>
<option value="">Tree House</option>
<option value="">Other</option>
</select>
<br />
<br />
<label>Room Type</label>
<br />

<select name="propertyType" id="propertyType">
<option value>-Please select one-</option>
<option value="House">Entire House</option>
<option value="">Private Room</option>
<option value="">Shared House</option>
<option value="">Hotel Room</option>
<option value="">Shared Apartment</option>
</select>
<br />
<br />
<label>Book Instantly?</label>
<br />
<input id="Ibook" name="Ibook" type="checkbox" value="" />
<br />
<br />
<br />
<br />
<label>Hot Water?</label>
<br />
<input id="water" name="water" type="checkbox" value="" />
<br />
<br />
<br />
<br />
<label>Smoke Detectors?</label>
<br />
<input id="smoke" name="smoke" type="checkbox" value="" />

<br />
<br />
<br />
<label>Near Shopping Center?</label>
<br />
<input id="Ibook" name="Ibook" type="checkbox" value="" />
<br />
<br />
<br />
<br />
<label>Near Public Trasportation?</label>
<br />
<input id="publicT" name="publicT" type="checkbox" value="" />
<br />
<br />
<br />
<br />
<label>Pets Allowed?</label>
<br />
<input id="pets" name="pets" type="checkbox" value="" />
<br />
<br />
<PropertyUpload />
<button type="submit">Add Property</button>
</form>

</styledForm>

);
};

export default PropertyForm;
2 changes: 2 additions & 0 deletions airbnb-optimal-price/src/components/PropertyInfo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


46 changes: 46 additions & 0 deletions airbnb-optimal-price/src/components/PropertyUpload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import React, { useState } from "react";
import axios from "axios";
import "../index.css";

const PropertyUpload = (props) => {
const [image, setImage] = useState("");
const [loading, setLoading] = useState(true);


const uploadImage = e => {
const file = e.target.files[0];
const data = new FormData();
data.append("upload_preset", "this_one");
data.append("file", file);
setLoading(true);
axios
.post("https://api.cloudinary.com/v1_1/jorgescloud/image/upload", data)
.then(response => {
setImage(response.data.secure_url);
console.log("image", response.data.secure_url);
}, 3000)
.then(setLoading(false))
.catch(err => console.log("err", err));
};

return (
<div>
<input
type="file"
name="user[image]"
multiple={true}
onChange={uploadImage}
/>
<div>
{loading ? (
<h1>Waiting...</h1>
) : (
<img src={image} alt="" className="new-photo" />
)}
</div>
<div>
</div>
</div>
);
};
export default PropertyUpload;
Empty file.
1 change: 1 addition & 0 deletions airbnb-optimal-price/src/components/UserFormDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

10 changes: 10 additions & 0 deletions airbnb-optimal-price/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,13 @@ code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
* {
margin: 0;
padding: 0;
}

.new-photo{
width:20vw;
height:20vh;

}
Loading