summaryrefslogtreecommitdiff
path: root/src-migrate/modules
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-08-02 10:16:46 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-08-02 10:16:46 +0000
commitd8510399c21b2cf4bf606441397a0142bc265a94 (patch)
tree75543baf82a73fb7e8dea6c8a1c353e02c57bbcd /src-migrate/modules
parent6a2c25e83a45eeb5d613a99a0caa6f0ec1aae15f (diff)
parent55c9f5e1fb868c85e704529ac914b3d75fc7744e (diff)
Merged in Feature/new-cart-popup (pull request #208)
Feature/new cart popup
Diffstat (limited to 'src-migrate/modules')
-rw-r--r--src-migrate/modules/product-detail/components/AddToCart.tsx11
-rw-r--r--src-migrate/modules/product-promo/components/AddToCart.tsx4
-rw-r--r--src-migrate/modules/product-promo/components/Card.tsx5
-rw-r--r--src-migrate/modules/product-promo/components/ModalContent.tsx1
-rw-r--r--src-migrate/modules/product-promo/components/Section.tsx4
-rw-r--r--src-migrate/modules/register/components/Form.tsx2
6 files changed, 13 insertions, 14 deletions
diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index 0ac8229e..6c9aedf8 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -31,16 +31,17 @@ const AddToCart = ({
position: 'top',
isClosable: true
})
+
const [product, setProducts] = useState(products);
+
const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
- useProductCartContext()
+ useProductCartContext()
const productSimilarQuery = [
product?.name,
`fq=-product_id_i:${product.id}`,
`fq=-manufacture_id_i:${product.manufacture?.id || 0}`,
].join('&');
-
const [addCartAlert, setAddCartAlert] = useState(false);
const handleClick = async () => {
@@ -55,8 +56,10 @@ const AddToCart = ({
isNaN(quantity) ||
typeof auth !== 'object'
) return;
+
setRefreshCart(true);
setAddCartAlert(true);
+
toast.promise(
upsertUserCart({
userId: auth.id,
@@ -103,8 +106,7 @@ const AddToCart = ({
active={addCartAlert}
close={() => {
setAddCartAlert(false);
- }
- }
+ }}
>
<div className='flex mt-4'>
<div className='w-[10%]'>
@@ -128,7 +130,6 @@ const AddToCart = ({
</Link>
</div>
</div>
-
<div className='mt-8 mb-4'>
<div className='text-h-sm font-semibold mb-6'>
Kamu Mungkin Juga Suka
diff --git a/src-migrate/modules/product-promo/components/AddToCart.tsx b/src-migrate/modules/product-promo/components/AddToCart.tsx
index f066a4c8..10904f90 100644
--- a/src-migrate/modules/product-promo/components/AddToCart.tsx
+++ b/src-migrate/modules/product-promo/components/AddToCart.tsx
@@ -16,7 +16,6 @@ import LazyLoad from 'react-lazy-load'
import ProductSimilar from '../../../../src/lib/product/components/ProductSimilar';
import { IProductDetail } from '~/types/product';
import { useProductCartContext } from '@/contexts/ProductCartContext'
-
type Props = {
promotion: IPromotion
product: IProductDetail
@@ -32,11 +31,11 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => {
const [status, setStatus] = useState<Status>('idle')
const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
useProductCartContext()
+
const productSimilarQuery = [
promotion?.name,
`fq=-product_id_i:${promotion.products[0].product_id}`,
].join('&');
-
const [addCartAlert, setAddCartAlert] = useState(false);
const handleButton = async () => {
@@ -139,7 +138,6 @@ const ProductPromoAddToCart = ({product, promotion }: Props) => {
</Link>
</div>
</div>
-
<div className='mt-8 mb-4'>
<div className='text-h-sm font-semibold mb-6'>
Kamu Mungkin Juga Suka
diff --git a/src-migrate/modules/product-promo/components/Card.tsx b/src-migrate/modules/product-promo/components/Card.tsx
index b286aa5b..5c323276 100644
--- a/src-migrate/modules/product-promo/components/Card.tsx
+++ b/src-migrate/modules/product-promo/components/Card.tsx
@@ -16,7 +16,6 @@ import ProductPromoItem from './Item'
import ProductPromoAddToCart from "./AddToCart"
import ProductPromoCardCountdown from "./CardCountdown"
import { IProductDetail } from '~/types/product';
-
import MobileView from '../../../../src/core/components/views/MobileView';
import DesktopView from '../../../../src/core/components/views/DesktopView';
@@ -133,7 +132,7 @@ const ProductPromoCard = ({product, promotion}: Props) => {
</div>
<div>
- <ProductPromoAddToCart product={product} promotion={promotion} />
+ <ProductPromoAddToCart product={product} promotion={promotion} />
</div>
</div>
@@ -190,7 +189,7 @@ const ProductPromoCard = ({product, promotion}: Props) => {
</div>
</div>
<div>
- <ProductPromoAddToCart product={product} promotion={promotion} />
+ <ProductPromoAddToCart product={product} promotion={promotion} />
</div>
</div>
diff --git a/src-migrate/modules/product-promo/components/ModalContent.tsx b/src-migrate/modules/product-promo/components/ModalContent.tsx
index 44ad52d6..256ef61a 100644
--- a/src-migrate/modules/product-promo/components/ModalContent.tsx
+++ b/src-migrate/modules/product-promo/components/ModalContent.tsx
@@ -5,6 +5,7 @@ import { getVariantPromoByCategory } from "~/services/productVariant"
import { useModalStore } from "../stores/useModalStore"
import ProductPromoCard from "./Card"
+
import { IProductDetail } from '~/types/product';
type Props = {
product: IProductDetail
diff --git a/src-migrate/modules/product-promo/components/Section.tsx b/src-migrate/modules/product-promo/components/Section.tsx
index 05b849c7..1228a6f0 100644
--- a/src-migrate/modules/product-promo/components/Section.tsx
+++ b/src-migrate/modules/product-promo/components/Section.tsx
@@ -13,10 +13,10 @@ import { IProductDetail } from '~/types/product';
type Props = {
productId: number;
- product: IProductDetail
+ product: IProductDetail;
}
-const ProductPromoSection = ({product, productId }: Props) => {
+const ProductPromoSection = ({ product, productId }: Props) => {
const promotionsQuery = useQuery({
queryKey: [`promotions.highlight`, productId],
queryFn: async () => await fetch(`/api/product-variant/${productId}/promotion/highlight`).then((res) => res.json()) as { data: IPromotion[] }
diff --git a/src-migrate/modules/register/components/Form.tsx b/src-migrate/modules/register/components/Form.tsx
index 4baaf380..b834f97a 100644
--- a/src-migrate/modules/register/components/Form.tsx
+++ b/src-migrate/modules/register/components/Form.tsx
@@ -168,7 +168,7 @@ const Form = () => {
<button
type="submit"
className="btn-yellow w-full mt-2"
- disabled={!isFormValid || !isCheckedTNC || mutation.isLoading}
+ disabled={!isFormValid || !isCheckedTNC || mutation.isLoading || !isValidCaptcha}
>
{mutation.isLoading ? 'Loading...' : 'Daftar'}
</button>