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
2,106 changes: 1,228 additions & 878 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import Books from "./js/components/Books/Books";
import Login from "./js/components/LoginPage/Login";
import SignUp from "./js/components/RegisterPage/SignUp";
import ForgotSignIn from "./js/components/ForgotSignIn/ForgotSignIn";

import Product from "./js/components/Products/Product";
import Store from "./js/components/Products/Store";
import ProductName from "./js/components/Products/ProductName";
class App extends Component {

render() {
Expand All @@ -20,6 +22,9 @@ class App extends Component {
<Route path="/register" component={SignUp} />
<Route path="/resetpassword" component={ForgotSignIn} />
<Route path="/Books" component={Books} />
<Route path="/Product" component={Product} />
<Route path="/Store" component={Store}/>
<Route path="/Productname" component={ProductName}/>
<Route component={Home} />
</Switch>
</div>
Expand Down
177 changes: 177 additions & 0 deletions src/js/components/Products/Product.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
import React, { Component } from "react";
import Navbar from "../Navbar/Navbar";
import "./Product.scss";
import * as myConstClass from "../../constants/product-constants"

class Product extends Component {
constructor(props)
{
super(props);
this.state ={
Name:'',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep a consistent naming convention.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now my naming is consistent.

CoverImageLocation:'',
Description:'',
Price:'',
Type:'',
SizeOption:'',
ColourOption:'' ,
Small:false,
Medium:false,
Large:false,
Speedy:false,
Color:false,
Kyn:false,
Count:0,

}
this.onChange=this.onChange.bind(this);
this.onSubmit=this.onSubmit.bind(this);
this.Small=this.SmallFuction.bind(this);
this.Medium=this.MediumFuction.bind(this);
this.Large=this.LargeFuction.bind(this);
this.handleChecked=this.handleChecked.bind(this);
this.Color=this.Color.bind(this)
}

onChange(e)
{
this.setState({[e.target.name]:e.target.value});
}

onSubmit(e)
{
e.preventDefault();
const post=
{
Name:this.state.Name,
Description: this.state.Description,
Price:this.state.Price,
Type:this.state.Type,
SizeOption:this.state.Count,
ColourOption:this.state.ColourOption,
CoverImageLocation:this.state.FileUpload,
}

fetch(myConstClass.PRODUCT_URL,
{
method:'POST',
headers:{
'Accept': 'application/json',
'content-type':'application/json'
},
body:JSON.stringify(post)
})
.then(response=>response.json());
}

Color()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a specific style for your function declaration.
Color(){}
or

Color()
{
}

On top of it, avoid leaving an empty line between your parentheses and your curly brackets

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have changed the style of function declaration to
color()
{
}

{
if(this.state.Color==false)
{
this.setState({Color:true,ColourOption:1});
}
else
{
this.setState({Color:false})
}
}

handleChecked()
{
if(this.state.Speedy==false)
{
this.setState({Speedy:true,Kyn:false,Type:"Speedy"});
}
else{
this.setState({Speedy:false,Kyn:true,Type:"Know your nation"});
}
}

SmallFuction()
{
if(this.state.Small==false)
{
this.setState({Small:true,count:1});
}
else{
this.setState({Small:false});
}
}

MediumFuction()
{
if(this.state.Medium==false)
{
this.setState({Medium:true,Count:2})
}
else
{
this.state.Medium=false;
}
}

LargeFuction()
{
if(this.state.Large==false)
{
this.setState({Large:true,Count:3});
}
else
{
this.setState({Large:false});
}
}

render()
{
let loc_navBarTitle = "CREATE PRODUCT";
let loc_navbarItems = [true, false, false, true];
return (
<div className="Product">
<Navbar titleFromParent={loc_navBarTitle} navbarItems={loc_navbarItems}/>
<div className="container ">
<div>
<img src={require('./download.jpg')} />
</div>
<div className="row ">
<div className="col-12 cover-image">
<label >Cover Image</label>
<span>
<input name="file" type="file"/>
</span>
</div>
<div className="col-12 name">
<label >Name</label>
<input className="formInput" name="Name" type="text" onChange={this.onChange} value={this.state.Name}/>
</div>
<div className="col-12 name">
<label >Description</label>
</div>
<div className="col-12 description">
<textarea className ="description" type="text" name ="Description" onChange={this.onChange} value={this.state.Description}/>
</div>
<div className="col-12 name">
<label >Type/Category</label>
</div>
<div className="col-12 name">
<div className="rad">
<input type="radio" name="Speedy" value={this.state.Speedy} onClick={this.handleChecked} /><label >Speedy</label>
<input type="radio" value="Know your nation" name="Speedy" value={this.state.Speedy} onClick={this.handleChecked}/> Know your nation
</div>
</div>
<div className="col-12 name">
<label >Price</label>
<input className="formInput" name="Price" type="Price" onChange={this.onChange} value={this.state.Price}/>
</div>
<div className ="col-12 name" >
<div className="col-12 createbutton">
<button onClick ={this.onSubmit} type="button" className="btn-dark">CREATE</button>
</div>
</div>
</div>
</div>
</div>
);
}
}
export default Product;
87 changes: 87 additions & 0 deletions src/js/components/Products/Product.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
$primary-color: #fff;
$name-margin-top: 20px;
$color-margin-top:10px;
$color-label-margin-top:20px;
$size-margin-top:10px;
$cover-image-margin-top: 20px;
$description-margin-top :10px;

.Product
{
background-color: #bbb;
min-height: 100vh;
color: $primary-color;
}
span {
display:block;
overflow: hidden;
padding: 0 4px 0 6px;
}

.btn-circle.btn-xl {
width: 70px;
height: 70px;
padding: 10px 16px;
font-size: 24px;
line-height: 1.33;
border-radius: 35px;
}

.checkboxs{
display: flex;
}

.createbutton{
display: flex;
color: black;
flex-direction: row-reverse;
border-radius: 50%;
}

.rad{
display: flex;
}

.color{
display:flex;
}


.formInput
{
width: 100%
}

.name
{
margin-top: $name-margin-top;
display: flex;
}

.cover-image
{
margin-top: $cover-image-margin-top;
display: flex;
}

.description{
margin-top:$description-margin-top;
width: 100%
}

.color
{
margin-top: $color-margin-top;
}

.color-label
{
margin-top: $color-label-margin-top;
display: flex;
}

.size
{
margin-top: $size-margin-top;
display: flex;
}
108 changes: 108 additions & 0 deletions src/js/components/Products/Store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React, { Component } from 'react';
import Navbar from "../Navbar/Navbar";
import "./Store.scss"
import * as myConstClass from "../../constants/product-constants"
import { NavLink } from "react-router-dom";


class Store extends Component
{
constructor(props)
{
super(props);
this.state =
{
Type:'',
}
this.kynMerch=this.kynMerch.bind(this);
this.speedyMerch=this.speedyMerch.bind(this);
}
speedyMerch()
{
fetch(myConstClass.speedy_url)
.then((response) => response.json())
.then(
(data) =>
{
console.log(data);
this.posts = data.map((item,i) =>
{
return (
<td>
<div className="col-6 items">
<NavLink to={`/Productname/${item.id}`}><img src={require(`${item.coverImageLocation}`)} /></NavLink>
<div className='ProductPrice'>
<p>{item.name} </p>
<p>R{item.price}</p>
</div>
</div>
</td>)
})
this.setState(
{
posts: this.posts
})
},
(error) =>
{
console.log(error);
});
}

kynMerch()
{
fetch(myConstClass.kyn_url)
.then((response) => response.json())
.then(
(data) => {
console.log(data);
this.posts = data.map((item,i) => {
return (
<td>
<div className="col-4 items">
<NavLink to={`/Productname/${item.id}`} ><img src={require(`${item.coverImageLocation}`)}/></NavLink>
<div className='ProductPrice'>
<label>{item.name}</label>
<label> R{item.price}</label>
</div>
</div>
</td>
)
})
this.setState({
posts: this.posts
})
},
(error) => {
console.log(error);
});
}

render() {
let loc_navBarTitle = "Store";
let loc_navbarItems = [true, true, true, true];
return (
<div className="Store">
<Navbar titleFromParent={loc_navBarTitle} navbarItems={loc_navbarItems}/>
<div className="store-container">
<ul className="nav nav-tabs">
<a className="nav-link speed-KYN" data-toggle="tab" onClick= {this.speedyMerch} href="#speedyMerch">Speedy Merch</a>
<a className="nav-link speed-KYN" data-toggle="tab" onClick= {this.kynMerch} href="#KYNMerch">KYN Merch</a>
</ul>
</div>
<div className="container">
<div className='row product'>
{this.posts}
</div>
</div>
<div className ="col-12 name" >
<div className="col-12 createbutton">
<button type="button" class="btn btn-dark btn-circle btn-xl"> cart</button>
</div>
</div>
</div>
);
}
}

export default Store;
Loading