generated from purwadhikafullstack/final-project-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
119 changed files
with
5,582 additions
and
2,267 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
PORT=8000 | ||
REACT_APP_API_BASE_URL=https://jcwdol0901.purwadhikabootcamp.com/api | ||
REACT_APP_IMAGE_BASE_URL=http://jcwdol0901.purwadhikabootcamp.com/ | ||
PORT=3000 | ||
REACT_APP_API_BASE_URL=http://monorepo.purwadhikabootcamp.com/api | ||
REACT_APP_IMAGE_BASE_URL=http://monorepo.purwadhikabootcamp.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+347 KB
projects/client/public/assets/categories/category_1688963921825718062566.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+52.1 KB
projects/client/public/assets/categories/category_1688964011487513965161.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5,984 changes: 3,936 additions & 2,048 deletions
5,984
projects/client/public/assets/images/React App.html
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import CartHeader from "./CartHeader"; | ||
import CartHeaderContent from "./CartHeaderContent"; | ||
import CartBoxDetail from "./CartBoxDetail"; | ||
import { useState } from "react"; | ||
import { getUserCart } from "./handlers/CartHandler"; | ||
|
||
const CartBox = () => { | ||
const [cart, setCart] = useState(); | ||
const [subTotal, setSubTotal] = useState(); | ||
const [isUpdate, setIsUpdate] = useState(false); | ||
|
||
React.useEffect(() => { | ||
getUserCart() | ||
.then((result) => { | ||
// if (!result.data) navigate("/404"); | ||
setCart(result.data); | ||
setSubTotal( | ||
cart?.reduce((acc, curr) => { | ||
const price = curr.Inventory.Product.price; | ||
const quantity = curr.quantity; | ||
const promoId = curr.Inventory.promo?.Promotion?.id; | ||
const promoValue = curr.Inventory.promo?.value; | ||
const finalPrice = | ||
promoId === 2 | ||
? price - promoValue | ||
: promoId === 3 | ||
? price - (promoValue / 100) * price | ||
: price; | ||
|
||
return acc + finalPrice * quantity; | ||
}, 0), | ||
); | ||
setIsUpdate(false); | ||
}) | ||
.catch((error) => { | ||
alert(error); | ||
}); | ||
}, [isUpdate]); | ||
return ( | ||
<> | ||
<CartHeader Content={CartHeaderContent} /> | ||
<CartBoxDetail cart={cart} setIsUpdate={setIsUpdate} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default CartBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import React from "react"; | ||
import CartPriceDetail from "./CartPriceDetail"; | ||
import QuantityUpdateButtonSet from "./QuantityUpdateButtonSet"; | ||
// import PriceDetail from "./PriceDetail.jsx"; | ||
|
||
const CartBoxDetail = ({ cart, setIsUpdate }) => { | ||
return cart.length ? ( | ||
<div className=""> | ||
{cart.map((item, index) => { | ||
return ( | ||
<div key={index} className="flex flex-row p-4 border-b border-dashed"> | ||
<img | ||
src={item.Inventory.Product.image} | ||
className="max-w-[100px] border border-green-500 rounded p-2 object-contain" | ||
alt={item.Inventory.Product.name} | ||
/> | ||
<div className="flex flex-col items-start justify-between pl-4 py-1"> | ||
<span className="font-semibold text-sm">{item.Inventory.Product.name}</span> | ||
<span className="text-sm text-left mb-auto mt-0.5"> | ||
@{item.Inventory.Product.weight} gr | ||
</span> | ||
<QuantityUpdateButtonSet | ||
stock={item.Inventory.stock} | ||
amount={item.quantity} | ||
inventory_id={item.Inventory.id} | ||
setIsUpdate={setIsUpdate} | ||
/> | ||
<CartPriceDetail item={item} /> | ||
</div> | ||
<span className="text-md font-light mt-auto ml-auto mb-1 mr-1">x {item.quantity}</span> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
) : ( | ||
<div className="text-rose-500 font-semibold text-left pl-4 py-2">Cart is empty</div> | ||
); | ||
}; | ||
|
||
export default CartBoxDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import React from "react"; | ||
|
||
const CartHeader = ({ Content }) => { | ||
return ( | ||
<div className="grid grid-cols-7 gap-2 bg-green-200 text-green-100 py-2 font-medium"> | ||
<Content /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CartHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from "react"; | ||
|
||
const CartHeaderContent = () => { | ||
return ( | ||
<> | ||
<span className="col-span-1 material-symbols-rounded">shopping_cart</span> | ||
<span className="col-span-4 text-left">Your Cart:</span> | ||
</> | ||
); | ||
}; | ||
|
||
export default CartHeaderContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import React from "react"; | ||
import { getDisplayPrice } from "./handlers/CartHandler"; | ||
|
||
const Promo = ({ item, isBOGO }) => { | ||
const text = React.useRef(""); | ||
|
||
if (isBOGO) { | ||
text.current = "(Buy One Get One)"; | ||
} else { | ||
const promo = item.Inventory.promo; | ||
|
||
if (promo.Promotion.id === 2) { | ||
text.current = `Potongan Rp ${promo.value.toLocaleString("id")}`; | ||
} else if (promo.Promotion.id === 3) { | ||
text.current = `${promo.value}% Off`; | ||
} | ||
} | ||
|
||
return <span className="text-xs mt-auto text-left text-[#f47229] sm:ml-3">{text.current}</span>; | ||
}; | ||
|
||
const PriceWithPromo = ({ item }) => { | ||
const price = getDisplayPrice(item); | ||
|
||
return ( | ||
<div className="flex flex-col sm:flex-row gap-1"> | ||
<span className="text-sm text-left">Rp {price.final.toLocaleString("id")}</span> | ||
{!price.isBOGO && ( | ||
<span className="text-sm text-xs mt-auto text-left line-through text-gray-200 sm:ml-3"> | ||
Rp {price.original.toLocaleString("id")} | ||
</span> | ||
)} | ||
<Promo item={item} isBOGO={price.isBOGO} /> | ||
</div> | ||
); | ||
}; | ||
|
||
const CartPriceDetail = ({ item }) => { | ||
return item.Inventory.promo ? ( | ||
<PriceWithPromo item={item} /> | ||
) : ( | ||
<span className="text-sm text-left">Rp {item.Inventory.Product.price.toLocaleString("id")}</span> | ||
); | ||
}; | ||
|
||
export default CartPriceDetail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
// import { useSelector, useDispatch } from "react-redux"; | ||
// import { postTransaction } from "./handlers/checkoutHandler"; | ||
|
||
const CheckoutButton = ({ cart }) => { | ||
// const checkout = useSelector((state) => state.checkout); | ||
// const dispatch = useDispatch(); | ||
const navigate = useNavigate(); | ||
return ( | ||
<div className="flex flex-col"> | ||
<button | ||
type="button" | ||
className="flex items-center bg-green-500 text-green-100 rounded-lg w-fit ml-auto mr-8 py-3 px-6 mb-6 disabled:opacity-50" | ||
onClick={() => navigate("/cart/checkout")} | ||
disabled={cart?.length === 0} | ||
> | ||
<span className="mr-8 font-bold">Checkout Cart</span> | ||
<span className="material-symbols-rounded">arrow_right</span> | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CheckoutButton; |
Oops, something went wrong.