Question: I have to create a java code for a Wish List Management and those are the requierements: Users can create and have 3 different wish
I have to create a java code for a Wish List Management and those are the requierements:
Users can create and have 3 different wish lists which can have books moved to from the primary list.
DESCRIPTION: There will be a section called wish lists, in which the user can create up to 3 new lists and give them different names. Each list can show the items that have been added to the list and each item can be added to the cart. Items can be added to the different lists from the item details page. Items can be removed from any list in this section. Items can be transferred from one wish list to another.
I have something like this but I need java code
import React, { useState, useEffect } from "react"; import API from "../../utils/API"; import { Container, Card, Row, Col, Dropdown, DropdownButton, Button } from "react-bootstrap"; import EditText from "../EditText/EditText";
function WishList(props) { const [items, setItems] = useState([])
useEffect(() => { API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) .catch(err => console.log(err)); }, [])
function handleMoveBook(current, desired, book){ console.log(current, desired); if(current === desired){ return; } API.removeBookFromWishlist(props.userEmail, current, book).then(res => { API.addBookToWishList(props.userEmail, desired, book).then(res =>{ API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) .catch(err => console.log(err)); }) .catch(err =>{ console.log(err); }) }) .catch(err =>{ console.log(err); }) }
function handleNameChange(wishListId, name) { API.renameWishlist(props.userEmail, wishListId, name).then(res =>{ API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) }) .catch(err =>{ console.log(err); }) } function handleNewWishList(id){ API.addWishList(props.userEmail, id, []).then(res =>{ API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) }) .catch(err =>{ console.log(err); }) }
function handleWishListDelete(wishListId){ API.removeWishlist(props.userEmail, wishListId).then(res =>{ API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) }) .catch(err =>{ console.log(err); }) }
function handleAddToShoppingCart(book, wishListId){ API.addToCart(props.userEmail, book).then(res =>{ API.removeWishlist(props.userEmail, wishListId).then(res =>{ API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) }) }) .catch(err =>{ console.log(err); }) }
function handleBookDelete(wishListId, book){ API.removeBookFromWishlist(props.userEmail, wishListId, book).then(res => { API.getWishLists({ email: props.userEmail }).then(res => { setItems(res.data); }) .catch(err => console.log(err)); }) .catch(err =>{ console.log(err); }) }
return (
Wishlists
{items.length < 3?handleNewWishList(items.length + 1)}>Add New Wishlist : null} {items.map((item, index) => ( handleNameChange(item.wishListId, text)}> handleWishListDelete(item.wishListId)}>Delete {item.books.map((book, index) => ( {book.title} {book.description} {items.map((otherthing, index) =>( {handleMoveBook(item.wishListId, index + 1, book)}}>{otherthing.name} ))} handleAddToShoppingCart(book, item.wishListId)}>Shopping Cart handleBookDelete(item.wishListId, book)}>Delete ))} ))} ) }
export default WishList;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
