Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Select option for category in create product screen #97

Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 20 additions & 10 deletions frontend/src/screens/CreateProductScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const CreateProductScreen = ({ history }) => {
const [description, setDescription] = useState('')
const [uploading, setUploading] = useState(false)


const dispatch = useDispatch()

const productCreate = useSelector((state) => state.productCreate)
Expand Down Expand Up @@ -177,15 +178,24 @@ const CreateProductScreen = ({ history }) => {
></Form.Control>
</Form.Group>

<Form.Group className="my-3" controlId="category">
<Form.Label>Category</Form.Label>
<Form.Control
type="text"
placeholder="Enter Category"
value={category}
onChange={(e) => setCategory(e.target.value)}
></Form.Control>
</Form.Group>
<Form.Group controlId="Category">
<Form.Label>Category</Form.Label>
<Form.Control
className='form-select'
as="select"
value={category}
onChange={e => {
setCategory(e.target.value);
}}
>
<option>--Select One--</option>
<option value="vegetables">Vegetables</option>
Copy link
Owner

Choose a reason for hiding this comment

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

These fields should be dynamic. We have categories data stored in the DB. It will be great if you use those data to render categories.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure will work on it.

<option value="exotic">Exotic</option>
<option value="seasonal">Seasonal</option>
<option value="fruits">Fruits</option>
<option value="sprouts">Sprouts</option>
</Form.Control>
</Form.Group>

<Form.Group controlId="description">
<Form.Label>Description</Form.Label>
Expand All @@ -200,7 +210,7 @@ const CreateProductScreen = ({ history }) => {
</Form.Group>

<Button className="my-3" type="submit" variant="primary">
Update
Create
</Button>
<Link to="/admin/productlist" className="btn btn-light my-3 ms-3">
Go Back
Expand Down
27 changes: 18 additions & 9 deletions frontend/src/screens/ProductEditScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,24 @@ const ProductEditScreen = ({ match, history }) => {
></Form.Control>
</Form.Group>

<Form.Group className="my-3" controlId="category">
<Form.Label>Category</Form.Label>
<Form.Control
type="text"
placeholder="Enter Category"
value={category}
onChange={(e) => setCategory(e.target.value)}
></Form.Control>
</Form.Group>
<Form.Group controlId="Category">
<Form.Label>Category</Form.Label>
<Form.Control
className='form-select'
as="select"
value={category}
onChange={e => {
setCategory(e.target.value);
}}
>
<option>--Select One--</option>
<option value="vegetables">Vegetables</option>
<option value="exotic">Exotic</option>
<option value="seasonal">Seasonal</option>
<option value="fruits">Fruits</option>
<option value="sprouts">Sprouts</option>
</Form.Control>
</Form.Group>

<Form.Group controlId="description">
<Form.Label>Description</Form.Label>
Expand Down