Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Servond committed Jul 13, 2023
2 parents a9ecb30 + 405594e commit 642f111
Show file tree
Hide file tree
Showing 119 changed files with 5,582 additions and 2,267 deletions.
27 changes: 7 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified projects/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions projects/client/.env.production
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/
2 changes: 1 addition & 1 deletion projects/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "CI=false set DISABLE_ESLINT_PLUGIN=true && react-scripts build",
"build": "set DISABLE_ESLINT_PLUGIN=true && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Expand Down
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.
5,984 changes: 3,936 additions & 2,048 deletions projects/client/public/assets/images/React App.html

Large diffs are not rendered by default.

Binary file modified projects/client/public/favicon.ico
Binary file not shown.
10 changes: 3 additions & 7 deletions projects/client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<meta name="description" content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
Expand All @@ -31,7 +28,7 @@
<style>
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap");
</style>
<title>React App</title>
<title>Groseria</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand All @@ -45,6 +42,5 @@
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
--></body>
</html>
Binary file modified projects/client/public/logo192.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified projects/client/public/logo512.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified projects/client/public/product/101.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 projects/client/public/product/13.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 projects/client/public/product/144.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 projects/client/public/product/148.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 projects/client/public/product/76.png
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.
9 changes: 9 additions & 0 deletions projects/client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ import UpdateProduct from "./pages/UpdateProduct/UpdateProduct";
import ResetPassword from "./pages/ResetPassword/ResetPassword";
import ForgotPassword from "./pages/ForgotPassword/ForgotPassword";
import UserAuthGuard from "./pages/UserAuthGuard";
import OrderPage from "./pages/Order/OrderPage";
import OrderDetail from "./pages/OrderDetail/OrderDetail";
import CartPage from "./pages/Cart/CartPage";
import NotFoundPage from "./pages/NotFoundPage";

function App() {
return (
Expand Down Expand Up @@ -68,14 +72,17 @@ function App() {
element={<UserAuthGuard component={<CreateNewAddress />} />}
/>
<Route path="/account/edit-address" element={<UserAuthGuard component={<EditAddress />} />} />
<Route path="/cart" element={<UserAuthGuard component={<CartPage />} />} />
<Route path="/cart/checkout" element={<UserAuthGuard component={<CheckoutPage />} />} />
<Route path="/cart/checkout/address/change" element={<UserAuthGuard component={<SwitchAddress />} />} />
<Route path="/cart/checkout/voucher/change" element={<UserAuthGuard component={<SwitchVoucher />} />} />
<Route
path="/cart/checkout/logistic/change"
element={<UserAuthGuard component={<SwitchLogistic />} />}
/>
<Route path="/order" element={<UserAuthGuard component={<OrderPage />} />} />
<Route path="/order/upload" element={<UserAuthGuard component={<UploadProof />} />} />
<Route path="/order/detail/:transaction_id" element={<UserAuthGuard component={<OrderDetail />} />} />

{/* //Admin Auth Page */}
<Route path="/admin/order" element={<AdminAuthGuard component={<ManageOrder />} />} />
Expand All @@ -94,6 +101,8 @@ function App() {
<Route path="/admin/product" element={<AdminAuthGuard component={<ManageProduct />} />} />
<Route path="/admin/product/create" element={<AdminAuthGuard component={<CreateProduct />} />} />
<Route path="/admin/product/update" element={<AdminAuthGuard component={<UpdateProduct />} />} />
{/* //Not Found Page */}
<Route path="*" element={<NotFoundPage />} />
</Routes>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion projects/client/src/components/AccountMenu/AccountMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function AccountMenu() {
<h1 className="text-left font-bold mb-4 ml-6 text-lg text-gray-400">Account Settings</h1>
<div className="bg-white shadow overflow-hidden sm:rounded-md mb-6">
<ul className="divide-y divide-gray-100">
{user.hasLogged ? menus.map((menu) => <MenuButton menu={menu} />) : null}
{user.hasLogged ? menus.map((menu, index) => <MenuButton menu={menu} key={index} />) : null}
{user.hasLogged ? (
<LogoutButton />
) : (
Expand Down
14 changes: 2 additions & 12 deletions projects/client/src/components/AccountMenu/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import axios from "axios";
import { useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import ReferralCard from "../ReferralCard";

const MenuButton = ({ menu }) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -43,18 +44,7 @@ export default function Profile() {
<h1 className="text-left font-bold mb-4 ml-6 text-2xl text-gray-400 capitalize">
Hey {user?.name}
</h1>
<div className="bg-white overflow-hidden sm:rounded-md mb-6 flex justify-center sm:justify-start sm:ml-6">
<div className="bg-green-200 min-w-80 w-5/6 sm:w-96 text-white font-semibold rounded-lg p-4 text-left flex overflow-hidden">
<img src="/assets/images/gratis_ongkir.png" className="h-24 mr-4" alt="gratis ongkir" />
<div className="flex flex-col">
<div className="mb-1">Dapatkan Gratis Ongkir 25rb</div>
<div className=" font-normal text-xs mb-1">
Bagikan & ajak temanmu daftar pakai kode referral
</div>
<div className=" bg-green-400 w-fit px-1">{user?.referral_code}</div>
</div>
</div>
</div>
<ReferralCard user={user} />
</div>
) : null}
</>
Expand Down
2 changes: 1 addition & 1 deletion projects/client/src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Button = ({ name, type, onClickHandler = null, disabled, pending, children
>
{children}
<span className="flex items-center disabled:opacity-50">
{pending && <span class="material-symbols-rounded animate-spin mr-2">progress_activity</span>}
{pending && <span className="material-symbols-rounded animate-spin mr-2">progress_activity</span>}
{name}
</span>
</button>
Expand Down
48 changes: 48 additions & 0 deletions projects/client/src/components/Cart/CartBox.jsx
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;
40 changes: 40 additions & 0 deletions projects/client/src/components/Cart/CartBoxDetail.jsx
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;
11 changes: 11 additions & 0 deletions projects/client/src/components/Cart/CartHeader.jsx
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;
12 changes: 12 additions & 0 deletions projects/client/src/components/Cart/CartHeaderContent.jsx
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;
46 changes: 46 additions & 0 deletions projects/client/src/components/Cart/CartPriceDetail.jsx
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;
25 changes: 25 additions & 0 deletions projects/client/src/components/Cart/CheckoutButton.jsx
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;

0 comments on commit 642f111

Please sign in to comment.