-
Notifications
You must be signed in to change notification settings - Fork 4
Mpilo fe #95
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: development
Are you sure you want to change the base?
Mpilo fe #95
Changes from all commits
7f9d16f
3ef7dfc
5ed23b8
6c44f9d
fc14743
4352158
1db68ce
2901889
339773a
169d00b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| 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:'', | ||
| 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() | ||
|
Collaborator
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. Choose a specific style for your function declaration. On top of it, avoid leaving an empty line between your parentheses and your curly brackets
Collaborator
Author
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. i have changed the style of function declaration to |
||
| { | ||
| 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; | ||
| 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; | ||
| } |
| 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; |
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.
Keep a consistent naming convention.
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.
now my naming is consistent.