Commit d281331f authored by John Lam's avatar John Lam

fix to update forms and styles

parent 0b732f3a
......@@ -5,6 +5,7 @@ import ProductIndex from "./ProductIndex";
import SearchResults from "./SearchResults";
import PromotionNewFormComponent from "./promotionforms/PromotionNewFormComponent";
import PromotionIndexComponent from "./promo_index/PromotionsIndexComponent";
import PromotionUpdateFormComponent from "./promotionforms/UpdatePromotionForm";
export default function Main() {
......@@ -22,6 +23,7 @@ export default function Main() {
path="/promos/new"
component={PromotionNewFormComponent}
></AuthRoute>
<AuthRoute exact path="/promos/:promoId/update" component={PromotionUpdateFormComponent}></AuthRoute>
<AuthRoute exact path="/products" component={ProductIndex}></AuthRoute>
<AuthRoute path="/promos">
<PromotionIndexComponent />
......
......@@ -15,7 +15,6 @@ export default function PromotionIndexComponent () {
const response = await fetch(`${Config.promotionsUrl}`);
const data = await response.json();
setPromoData(data);
console.log(data);
}
const deletePromotion = (promoId) => {
......@@ -28,7 +27,7 @@ export default function PromotionIndexComponent () {
return (
<div>
<div className="promo-container">
<div className="promo-list-container">
<div className="promo-list-container">
<div className="promo-header">
<h1 className="promo-title"> Promotions</h1>
......
......@@ -16,7 +16,6 @@ export default function PromotionNewFormComponent (props) {
const onSubmit = (data) => {
console.log(data)
fetch(`${Config.promotionsUrl}`, {
method: "POST",
......@@ -36,20 +35,14 @@ export default function PromotionNewFormComponent (props) {
const loadProducts = async (event) => {
const data = await getAllProducts();
setproductData(data);
}
const onChange = (e, data) => {
console.log(data)
setValue('productSku', data.value)
console.log(productSku)
}
const productSku = register('productSku', { required: true })
return (
<div>
<div className="promo-container">
......@@ -136,7 +129,7 @@ export default function PromotionNewFormComponent (props) {
{...register("minimumQuantity", {
valueAsNumber: true,
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"
......
......@@ -16,8 +16,6 @@ export default function PromotionUpdateFormComponent(props) {
const [productData, setproductData] = useState([]);
const onSubmit = (data) => {
console.log(data)
fetch(`${Config.promotionsUrl}/${data.promotionId}`, {
method: "PUT",
headers: {
......@@ -88,7 +86,6 @@ export default function PromotionUpdateFormComponent(props) {
}
})} />
{errors.productSku && <p className="form-error">{errors.productSku.message}</p>}
{errors.productSku && console.log(errors) && <p className="form-error">{errors.productSku.message}</p>}
<br></br>
</div>
......@@ -124,12 +121,11 @@ export default function PromotionUpdateFormComponent(props) {
valueAsNumber: true,
value: props.location.state.promo.minimumQuantity,
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"
className="form-control"
type="number"
min="1"
placeholder={props.location.state.promo.minimumQuantity}
/>
{errors.minimumQuantity && <p className="form-error">{errors.minimumQuantity.message}</p>}
......
......@@ -3,7 +3,7 @@
margin: 0px auto;
padding: 50px;
border-radius: 3px;
max-width: 500px;
}
......
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