Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inventory-promotion-react
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ascend
inventory-promotion-react
Commits
d3245d94
Commit
d3245d94
authored
May 07, 2021
by
Sumaiyya Burney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds imgUrl upload+changes field names to match DB
parent
3a3923b2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
19 deletions
+29
-19
ProductForm.jsx
src/component/ProductForm.jsx
+29
-19
No files found.
src/component/ProductForm.jsx
View file @
d3245d94
...
...
@@ -4,13 +4,14 @@ import { useHistory, useLocation } from "react-router";
const
emptyForm
=
{
sku
:
""
,
upc
:
""
,
prodName
:
""
,
prod
uct
Name
:
""
,
brand
:
""
,
category
:
""
,
price
:
0.0
,
stock
:
0
,
prodDesc
:
""
,
productImage
:
""
,
availableStock
:
0
,
productDescription
:
""
,
productImageUrl
:
""
,
productImage
:
""
};
ProductForm
.
defaultProps
=
{
...
...
@@ -33,7 +34,7 @@ export default function ProductForm(props) {
if
(
form
.
upc
.
length
<
3
)
{
errs
.
push
(
"UPC must be at least 3 characters"
);
}
if
(
form
.
prodName
.
length
===
0
)
{
if
(
form
.
prod
uct
Name
.
length
===
0
)
{
errs
.
push
(
"Please enter a product name"
);
}
if
(
form
.
brand
.
length
===
0
)
{
...
...
@@ -45,7 +46,7 @@ export default function ProductForm(props) {
if
(
Number
(
form
.
price
)
<=
0
)
{
errs
.
push
(
"Price must be greater than 0"
);
}
if
(
Number
(
form
.
s
tock
)
<=
0
)
{
if
(
Number
(
form
.
availableS
tock
)
<=
0
)
{
errs
.
push
(
"Stock must be greater than 0"
);
}
...
...
@@ -126,17 +127,17 @@ export default function ProductForm(props) {
<
div
className=
"row mt-3"
>
<
div
className=
"col-6"
>
<
div
>
<
label
htmlFor=
"prodName"
className=
"form-label"
>
<
label
htmlFor=
"prod
uct
Name"
className=
"form-label"
>
Name
</
label
>
<
input
required
name=
"prodName"
name=
"prod
uct
Name"
type=
"text"
className=
"form-control"
id=
"prodName"
value=
{
form
.
prodName
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
prodName
:
e
.
target
.
value
})
}
id=
"prod
uct
Name"
value=
{
form
.
prod
uct
Name
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
prod
uct
Name
:
e
.
target
.
value
})
}
/>
</
div
>
<
div
>
...
...
@@ -169,17 +170,17 @@ export default function ProductForm(props) {
</
div
>
</
div
>
<
div
className=
"col-6"
>
<
label
htmlFor=
"prod
Desc
"
className=
"form-label"
>
<
label
htmlFor=
"prod
uctDescription
"
className=
"form-label"
>
Description
</
label
>
<
textarea
name=
"prod
Desc
"
id=
"prod
Desc
"
name=
"prod
uctDescription
"
id=
"prod
uctDescription
"
cols=
"40"
rows=
"7"
className=
"form-control"
value=
{
form
.
prod
Desc
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
prod
Desc
:
e
.
target
.
value
})
}
value=
{
form
.
prod
uctDescription
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
prod
uctDescription
:
e
.
target
.
value
})
}
></
textarea
>
</
div
>
</
div
>
...
...
@@ -208,8 +209,8 @@ export default function ProductForm(props) {
type=
"number"
className=
"form-control"
id=
"stock"
value=
{
form
.
s
tock
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
s
tock
:
e
.
target
.
value
})
}
value=
{
form
.
availableS
tock
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
availableS
tock
:
e
.
target
.
value
})
}
/>
</
div
>
</
div
>
...
...
@@ -217,13 +218,22 @@ export default function ProductForm(props) {
<
label
htmlFor=
"productImage"
className=
"form-label"
>
Product Image
</
label
>
<
input
id=
"productImageUrl"
name=
"productImageUrl"
className=
"form-control form-control-lg"
type=
"url"
placeholder=
"Enter image URL here or upload image below..."
value=
{
form
.
productImageUrl
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
productImageUrl
:
e
.
target
.
value
,
productImage
:
""
})
}
></
input
>
<
input
id=
"productImage"
name=
"productImage"
className=
"form-control form-control-lg"
type=
"file"
value=
{
form
.
productImage
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
productImage
:
e
.
target
.
value
})
}
onChange=
{
(
e
)
=>
setForm
({
...
form
,
productImage
:
e
.
target
.
value
,
productImageUrl
:
""
})
}
></
input
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment