Skip to content

Commit

Permalink
Merge pull request #22 from bonniesimon/master
Browse files Browse the repository at this point in the history
Started work on post
  • Loading branch information
bonniesimon authored Aug 6, 2020
2 parents ac179e5 + ae38d09 commit 3357ae2
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 8 deletions.
Empty file added jsconfig.json
Empty file.
4 changes: 2 additions & 2 deletions src/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import InputForm from './components/InputForm'
import PrimaryButton from './components/PrimaryButton'
// import ViewDataCard from './components/ViewDataCard'
import TextDisplay from './components/TextDisplay'
import Products from './components/Products'
import GetProducts from './helpers/GetProducts'

class Home extends Component {
constructor(props) {
Expand All @@ -28,7 +28,7 @@ class Home extends Component {
<TextDisplay message="You can view all your product entries here!" />
<div className="space-20"></div>
{/* <ViewDataCard/> */}
<Products/>
<GetProducts/>
</div>
</div>
)
Expand Down
9 changes: 4 additions & 5 deletions src/components/Products.js → src/helpers/GetProducts.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useState, useEffect } from 'react';
import axios from 'axios';

import ViewDataCard from './ViewDataCard';
import ViewDataCard from '../components/ViewDataCard';

import { getProducts } from '../helpers/ProductService';
import { getProducts } from './ProductService';

const Products = () => {
const GetProducts = () => {
const [products, setProducts] = useState([]);

useEffect(() => {
Expand Down Expand Up @@ -37,7 +37,6 @@ const Products = () => {
let productsModded = [];
inputProducts.forEach(product => {
product.product_inventories.forEach(product_inventory => {
console.log(`${product.name} - ${product_inventory.unit} - ${product_inventory.price}`)
const newProd = { ...product, product_inventory };
productsModded.push(newProd)
})
Expand Down Expand Up @@ -70,4 +69,4 @@ const Products = () => {
)
}

export default Products;
export default GetProducts;
22 changes: 22 additions & 0 deletions src/helpers/PostProducts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, {useState} from 'react'
import InputForm from '../components/InputForm'


const PostProducts = () => {
const [name, setName] = useState("")
const [description, setDescription] = useState("")
const [category, setCategory] = useState("")
const [subcategory, setSubcategory] = useState("")
const [price, setPrice] = useState("")
const [type, setType] = useState("")
const [unit, setUnit] = useState("")


return (
<>
<InputForm/>
</>
)
}

export default PostProducts
21 changes: 20 additions & 1 deletion src/helpers/ProductService.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,23 @@ export const getProducts = async () => {
const res = await axios.get(`${baseUrl}/products`);
const data = res.data;
return data;
}
}

/*
Post product schema
{
"name": "string",
"description": "string",
"category": "fruitsAndVegetables",
"product_inventories": [
"string"
],
"subCategory": "vegetables",
"created_by": "string",
"updated_by": "string"
}
*/

// export const postProducts = async (product) => {

// }

0 comments on commit 3357ae2

Please sign in to comment.