Commit 0bf58a8b authored by Sumaiyya Burney's avatar Sumaiyya Burney

Merge branch 'dev' into 'uniform-styling'

Dev

See merge request !21
parents 797dcf3e b33ae44d
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
"react": "^17.0.2", "react": "^17.0.2",
"react-bootstrap": "^1.5.2", "react-bootstrap": "^1.5.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-google-login": "^5.2.2",
"react-hook-form": "^7.4.1", "react-hook-form": "^7.4.1",
"react-router": "^5.2.0", "react-router": "^5.2.0",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
...@@ -14626,6 +14627,19 @@ ...@@ -14626,6 +14627,19 @@
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz",
"integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA=="
}, },
"node_modules/react-google-login": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/react-google-login/-/react-google-login-5.2.2.tgz",
"integrity": "sha512-JUngfvaSMcOuV0lFff7+SzJ2qviuNMQdqlsDJkUM145xkGPVIfqWXq9Ui+2Dr6jdJWH5KYdynz9+4CzKjI5u6g==",
"dependencies": {
"@types/react": "*",
"prop-types": "^15.6.0"
},
"peerDependencies": {
"react": "^16 || ^17",
"react-dom": "^16 || ^17"
}
},
"node_modules/react-hook-form": { "node_modules/react-hook-form": {
"version": "7.4.1", "version": "7.4.1",
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.4.1.tgz", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.4.1.tgz",
...@@ -31867,6 +31881,15 @@ ...@@ -31867,6 +31881,15 @@
"resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz", "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.0.tgz",
"integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==" "integrity": "sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA=="
}, },
"react-google-login": {
"version": "5.2.2",
"resolved": "https://registry.npmjs.org/react-google-login/-/react-google-login-5.2.2.tgz",
"integrity": "sha512-JUngfvaSMcOuV0lFff7+SzJ2qviuNMQdqlsDJkUM145xkGPVIfqWXq9Ui+2Dr6jdJWH5KYdynz9+4CzKjI5u6g==",
"requires": {
"@types/react": "*",
"prop-types": "^15.6.0"
}
},
"react-hook-form": { "react-hook-form": {
"version": "7.4.1", "version": "7.4.1",
"resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.4.1.tgz", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.4.1.tgz",
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
"react": "^17.0.2", "react": "^17.0.2",
"react-bootstrap": "^1.5.2", "react-bootstrap": "^1.5.2",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-google-login": "^5.2.2",
"react-hook-form": "^7.4.1", "react-hook-form": "^7.4.1",
"react-router": "^5.2.0", "react-router": "^5.2.0",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",
......
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0" integrity="sha384-wEmeIV1mKuiNpC+IOBjI7aAzPcEZeedi5yW5f2yOq55WWLwNGmvvx4Um1vskeMj0"
crossorigin="anonymous" crossorigin="anonymous"
/> />
<link async rel="stylesheet" href="//cdn.jsdelivr.net/npm/semantic-ui@${props.versions.sui}/dist/semantic.min.css" />
<script async src="//cdn.jsdelivr.net/npm/semantic-ui@${props.versions.sui}/dist/semantic.min.js"></script>
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> <link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" /> <meta name="theme-color" content="#000000" />
......
...@@ -5,6 +5,7 @@ import ProductIndex from "./ProductIndex"; ...@@ -5,6 +5,7 @@ import ProductIndex from "./ProductIndex";
import SearchResults from "./SearchResults"; import SearchResults from "./SearchResults";
import PromotionNewFormComponent from "./promotionforms/PromotionNewFormComponent"; import PromotionNewFormComponent from "./promotionforms/PromotionNewFormComponent";
import PromotionIndexComponent from "./promo_index/PromotionsIndexComponent"; import PromotionIndexComponent from "./promo_index/PromotionsIndexComponent";
import PromotionUpdateFormComponent from "./promotionforms/UpdatePromotionForm";
export default function Main() { export default function Main() {
...@@ -22,6 +23,7 @@ export default function Main() { ...@@ -22,6 +23,7 @@ export default function Main() {
path="/promos/new" path="/promos/new"
component={PromotionNewFormComponent} component={PromotionNewFormComponent}
></AuthRoute> ></AuthRoute>
<AuthRoute exact path="/promos/:promoId/update" component={PromotionUpdateFormComponent}></AuthRoute>
<AuthRoute exact path="/products" component={ProductIndex}></AuthRoute> <AuthRoute exact path="/products" component={ProductIndex}></AuthRoute>
<AuthRoute path="/promos"> <AuthRoute path="/promos">
<PromotionIndexComponent /> <PromotionIndexComponent />
......
import React from "react"; import React from "react";
import ProductRow from "./ProductRow.jsx"; import ProductRow from "./ProductRow.jsx";
import { Table } from "react-bootstrap"; import { Table, Container } from "react-bootstrap";
import { deleteProduct } from "../actions/apiRequests"; import { deleteProduct } from "../actions/apiRequests";
import { withRouter } from "react-router"; import { withRouter } from "react-router";
import Search from "./Search.jsx"; import Search from "./Search.jsx";
...@@ -27,11 +27,13 @@ class SearchResults extends React.Component { ...@@ -27,11 +27,13 @@ class SearchResults extends React.Component {
render() { render() {
return ( return (
<div className="container flex-column d-flex justify-content-center"> <div className="container flex-column d-flex justify-content-center">
<div className="container mt-3 d-flex justify-content-between align-items-center">
<h1 id="title" >Search Results</h1> <h1 id="title" >Search Results</h1>
<Search /> <div><Search /></div>
</div>
{this.state.results.length > 0 ? {this.state.results.length > 0 ?
<Container id="prod-table" className="mt-3 mx-auto">
<Table> <Table>
<thead> <thead>
<tr> <tr>
...@@ -53,6 +55,7 @@ class SearchResults extends React.Component { ...@@ -53,6 +55,7 @@ class SearchResults extends React.Component {
})} })}
</tbody> </tbody>
</Table> </Table>
</Container>
: :
<p>Unable to find any matching products.</p> <p>Unable to find any matching products.</p>
} }
......
...@@ -27,12 +27,11 @@ export default function PromotionIndexComponent () { ...@@ -27,12 +27,11 @@ export default function PromotionIndexComponent () {
return ( return (
<div> <div>
<div className="promo-container">
<div className="container flex-column d-flex justify-content-center">
<div className="promo-list-container"> <div className="container mt-3 d-flex justify-content-between align-items-center">
<div className="promo-header">
<h1 className="promo-title"> Promotions</h1> <h1 className="promo-title"> Promotions</h1>
<NavLink className="add-navLink" to='/promos/new'><button className="btn-success">+ New Promotion</button></NavLink> <NavLink className="add-navLink" to='/promos/new'><button className="btn btn-success">+ New Promotion</button></NavLink>
</div> </div>
<table className="promo-index-list"> <table className="promo-index-list">
<thead className="promo-table-title"> <thead className="promo-table-title">
...@@ -49,16 +48,16 @@ export default function PromotionIndexComponent () { ...@@ -49,16 +48,16 @@ export default function PromotionIndexComponent () {
<th> <th>
Minimum Quanitity Minimum Quanitity
</th> </th>
<th> <th className="row-width">
</th> </th>
<th> <th className="row-width">
</th> </th >
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{promoData.map((promo, key) => { {promoData.length > 0 ? promoData.map((promo, key) => {
return ( return (
<tr key={key}> <tr key={key}>
<td> <td>
...@@ -78,20 +77,19 @@ export default function PromotionIndexComponent () { ...@@ -78,20 +77,19 @@ export default function PromotionIndexComponent () {
pathname: `/promos/${promo.promotionId}/update`, pathname: `/promos/${promo.promotionId}/update`,
state: {promo} state: {promo}
}}> }}>
<button className="btn-primary">Update</button> <button className="btn-color btn btn-primary btn-sm">Update</button>
</NavLink> </NavLink>
</td> </td>
<td> <td>
<button className="btn-danger btn-sm" onClick={() => deletePromotion(promo.promotionId)}>Delete</button> <button className="btn btn-danger btn-sm" onClick={() => deletePromotion(promo.promotionId)}>Delete</button>
</td> </td>
</tr> </tr>
) )
}).reverse() }).reverse() : <p>no promotions found.</p>}
}
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div>
) )
} }
.promo-container { /* .promo-container {
margin: 30px auto; margin: 30px auto;
padding: 0 16px; padding: 0 16px;
} }
.promo-header { .promo-header {
background-color: #212529;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding-left: 10px; padding-left: 10px;
padding-right: 10px; padding-right: 10px;
} } */
/*
.promo-title { .promo-title {
color: white;
padding: 8px; padding: 8px;
} */
.promo-index-list {
margin-top: 7px;
}
.promo-table-title {
border-bottom: 1px solid black;
} }
.add-navLink { .add-navLink {
align-self: center; align-self: center;
} }
...@@ -24,6 +27,14 @@ table { ...@@ -24,6 +27,14 @@ table {
width: 100%; width: 100%;
} }
.row-width {
width: 7%;
}
.btn-color {
background-color: #00567D;
}
td, td,
th { th {
text-align: left; text-align: left;
...@@ -42,10 +53,11 @@ tr:nth-child(even) { ...@@ -42,10 +53,11 @@ tr:nth-child(even) {
background-color: #dddddd; background-color: #dddddd;
} }
thead th { /* thead th {
background-color: #dddddd; background-color: #dddddd;
height: 35px; height: 35px;
} /* border-bottom: 1px black; */
tr:hover { tr:hover {
background-color: lightblue; background-color: lightblue;
......
...@@ -16,7 +16,6 @@ export default function PromotionNewFormComponent (props) { ...@@ -16,7 +16,6 @@ export default function PromotionNewFormComponent (props) {
const onSubmit = (data) => { const onSubmit = (data) => {
console.log(data)
fetch(`${Config.promotionsUrl}`, { fetch(`${Config.promotionsUrl}`, {
method: "POST", method: "POST",
...@@ -36,20 +35,14 @@ export default function PromotionNewFormComponent (props) { ...@@ -36,20 +35,14 @@ export default function PromotionNewFormComponent (props) {
const loadProducts = async (event) => { const loadProducts = async (event) => {
const data = await getAllProducts(); const data = await getAllProducts();
setproductData(data); setproductData(data);
} }
const onChange = (e, data) => { const onChange = (e, data) => {
console.log(data)
setValue('productSku', data.value) setValue('productSku', data.value)
console.log(productSku)
} }
const productSku = register('productSku', { required: true }) const productSku = register('productSku', { required: true })
return ( return (
<div> <div>
<div className="promo-container"> <div className="promo-container">
...@@ -64,7 +57,7 @@ export default function PromotionNewFormComponent (props) { ...@@ -64,7 +57,7 @@ export default function PromotionNewFormComponent (props) {
<input <input
{...register("promotionId", { {...register("promotionId", {
required: "promotion id is required", required: "promotion id is required",
maxLength: { value: 10, message: "You exceeded the maximum value" } maxLength: { value: 20, message: "You exceeded the maximum value" }
})} })}
id="promotionId" id="promotionId"
className="form-control" className="form-control"
...@@ -102,6 +95,8 @@ export default function PromotionNewFormComponent (props) { ...@@ -102,6 +95,8 @@ export default function PromotionNewFormComponent (props) {
})} })}
/> />
{errors.productSku && <p className="form-error">{errors.productSku.message}</p>} {errors.productSku && <p className="form-error">{errors.productSku.message}</p>}
<br></br> <br></br>
</div> </div>
...@@ -134,7 +129,7 @@ export default function PromotionNewFormComponent (props) { ...@@ -134,7 +129,7 @@ export default function PromotionNewFormComponent (props) {
{...register("minimumQuantity", { {...register("minimumQuantity", {
valueAsNumber: true, valueAsNumber: true,
required: "minimum quantity is required", required: "minimum quantity is required",
min: { value: 1, message: "discount percentage must be greater than 0" }, min: { value: 1, message: "minimum quantity must be greater than 0" },
})} })}
id="minimumQuantity" id="minimumQuantity"
......
...@@ -16,8 +16,6 @@ export default function PromotionUpdateFormComponent(props) { ...@@ -16,8 +16,6 @@ export default function PromotionUpdateFormComponent(props) {
const [productData, setproductData] = useState([]); const [productData, setproductData] = useState([]);
const onSubmit = (data) => { const onSubmit = (data) => {
console.log(data)
fetch(`${Config.promotionsUrl}/${data.promotionId}`, { fetch(`${Config.promotionsUrl}/${data.promotionId}`, {
method: "PUT", method: "PUT",
headers: { headers: {
...@@ -42,7 +40,8 @@ export default function PromotionUpdateFormComponent(props) { ...@@ -42,7 +40,8 @@ export default function PromotionUpdateFormComponent(props) {
setValue('productSku', data.value) setValue('productSku', data.value)
} }
const productSku = register('productSku', { required: true }) register('productSku', { required: true })
setValue('productSku', props.location.state.promo.productSku);
return ( return (
<div> <div>
<div className="promo-container"> <div className="promo-container">
...@@ -57,7 +56,7 @@ export default function PromotionUpdateFormComponent(props) { ...@@ -57,7 +56,7 @@ export default function PromotionUpdateFormComponent(props) {
{...register("promotionId", { {...register("promotionId", {
value: props.location.state.promo.promotionId, value: props.location.state.promo.promotionId,
required: "promotion id is required", required: "promotion id is required",
maxLength: { value: 10, message: "You exceeded the maximum value" }, maxLength: { value: 20, message: "You exceeded the maximum value" },
})} })}
readOnly readOnly
...@@ -87,6 +86,7 @@ export default function PromotionUpdateFormComponent(props) { ...@@ -87,6 +86,7 @@ export default function PromotionUpdateFormComponent(props) {
} }
})} /> })} />
{errors.productSku && <p className="form-error">{errors.productSku.message}</p>} {errors.productSku && <p className="form-error">{errors.productSku.message}</p>}
<br></br> <br></br>
</div> </div>
...@@ -121,12 +121,11 @@ export default function PromotionUpdateFormComponent(props) { ...@@ -121,12 +121,11 @@ export default function PromotionUpdateFormComponent(props) {
valueAsNumber: true, valueAsNumber: true,
value: props.location.state.promo.minimumQuantity, value: props.location.state.promo.minimumQuantity,
required: "minimum quantity is required", required: "minimum quantity is required",
min: { value: 1, message: "discount percentage must be greater than 0" }, min: { value: 1, message: "minimum quantity must be greater than 0" },
})} })}
id="minimumQuantity" id="minimumQuantity"
className="form-control" className="form-control"
type="number" type="number"
min="1"
placeholder={props.location.state.promo.minimumQuantity} placeholder={props.location.state.promo.minimumQuantity}
/> />
{errors.minimumQuantity && <p className="form-error">{errors.minimumQuantity.message}</p>} {errors.minimumQuantity && <p className="form-error">{errors.minimumQuantity.message}</p>}
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
margin: 0px auto; margin: 0px auto;
padding: 50px; padding: 50px;
border-radius: 3px; border-radius: 3px;
max-width: 700px;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment