Skip to content

Commit

Permalink
Merge pull request #163 from iwkz-dev/add_po_closed
Browse files Browse the repository at this point in the history
po closed handler for customer site
  • Loading branch information
ilhamuh97 authored Sep 2, 2024
2 parents 3c2aeb4 + 16a18ab commit 810107a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Button, Card, Space, Typography, message } from "antd";
import { ShoppingCartOutlined } from "@ant-design/icons";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { addOrder } from "../../../../stores/reducers/cart";
import ImagesPreview from "../../../atoms/ImagesPreview/ImagesPreview";
import Router from "next/router";
import style from "./ProductItem.module.scss";

const ProductItem = ({ product }) => {
const dispatch = useDispatch();
const events = useSelector((state) => state.event.data);
const { Meta } = Card;

const handleClick = (e) => {
Expand Down Expand Up @@ -48,7 +49,10 @@ const ProductItem = ({ product }) => {
</Typography.Text>
<Button
type="primary"
disabled={product.quantity == product.quantityOrder}
disabled={
product.quantity == product.quantityOrder ||
events[0].po_closed
}
onClick={(e) => handleClick(e)}
shape="round"
icon={<ShoppingCartOutlined />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import React from "react";
import BackToButton from "../../atoms/BackToButton/BackToButton";
import ImagesPreview from "../../atoms/ImagesPreview/ImagesPreview";
import { addOrder } from "../../../stores/reducers/cart";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";

const ProductDetailContent = ({ detailMenu }) => {
const dispatch = useDispatch();
const events = useSelector((state) => state.event.data);

const handleClick = () => {
message.success(detailMenu.name + " Added");
Expand All @@ -30,13 +31,11 @@ const ProductDetailContent = ({ detailMenu }) => {
maxWidth: "1024px",
padding: "1rem",
margin: "1rem auto",
}}
>
}}>
<Space
size="large"
direction="vertical"
style={{ width: "100%" }}
>
style={{ width: "100%" }}>
<BackToButton targetURL="/" buttonText="Back to home" />
<Space
direction="vertical"
Expand All @@ -45,8 +44,7 @@ const ProductDetailContent = ({ detailMenu }) => {
alignItems: "center",
textAlign: "center",
width: "100%",
}}
>
}}>
<Typography.Title level={3}>
{detailMenu.name}
</Typography.Title>
Expand All @@ -71,8 +69,7 @@ const ProductDetailContent = ({ detailMenu }) => {
style={{
textAlign: "justify",
maxWidth: "550px",
}}
>
}}>
{detailMenu.description}
</Typography.Paragraph>
</Space>
Expand All @@ -93,12 +90,12 @@ const ProductDetailContent = ({ detailMenu }) => {
type="primary"
disabled={
detailMenu.quantity ==
detailMenu.quantityOrder
detailMenu.quantityOrder ||
events[0].po_closed
}
onClick={handleClick}
shape="round"
icon={<ShoppingCartOutlined />}
>
icon={<ShoppingCartOutlined />}>
Add to cart
</Button>
</Space>
Expand All @@ -111,8 +108,7 @@ const ProductDetailContent = ({ detailMenu }) => {
maxWidth: "1024px",
padding: "1rem",
margin: "1rem auto",
}}
>
}}>
<Empty />
</div>
</Layout.Content>
Expand Down
6 changes: 6 additions & 0 deletions client-site/src/pages/product/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@ import MainLayout from "../../components/organismus/MainLayout/MainLayout";
import ProductDetailContent from "../../components/organismus/ProductDetailContent/ProductDetailContent";
import { getMenuWithId } from "../../stores/reducers/menu";
import { useRouter } from "next/router";
import { getEvent } from "../../stores/reducers/event";

const productDetail = () => {
const dispatch = useDispatch();
const detailMenu = useSelector((state) => state.menu.menuDetail);
const router = useRouter();
const { id } = router.query;

useEffect(() => {
const status = "approved";
dispatch(getEvent(status));
}, []);

useEffect(() => {
if (id) {
dispatch(getMenuWithId(id));
Expand Down

0 comments on commit 810107a

Please sign in to comment.