diff --git a/src/App.js b/src/App.js
index 74cf227..921475b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -24,8 +24,19 @@ function HomePage({
setShowedModal,
productSectionRef,
courseSectionRef,
+ scrollToProduct,
+ scrollToCourse,
setWillDo
}) {
+
+ useEffect(() => {
+ const params = new URLSearchParams(window.location.search);
+ const tab = params.get('tab');
+
+ if(tab === 'products') scrollToProduct();
+ if(tab === 'academy') scrollToCourse();
+ }, [productSectionRef, courseSectionRef]);
+
return (
<>
@@ -46,6 +57,7 @@ function HomePage({
/>
+
>
);
}
@@ -130,6 +142,7 @@ function App() {
useEffect(() => {
const params = new URLSearchParams(window.location.search);
const modalType = params.get('modal');
+ const tab = params.get('tab');
const productId = params.get('product_id');
const authorizedUri = params.get('authorized_uri');
const unauthorizedUri = params.get('unauthorized_uri');
@@ -148,6 +161,9 @@ function App() {
}
// Jika sudah login, tidak langsung fetch di sini — akan diproses saat subscriptions tersedia
}
+
+ if(tab === 'products') scrollToProduct();
+ if(tab === 'academy') scrollToCourse();
}, []);
useEffect(() => {
@@ -299,12 +315,14 @@ function App() {
productSectionRef={productSectionRef}
courseSectionRef={courseSectionRef}
setWillDo={setWillDo}
+ scrollToProduct={scrollToProduct}
+ scrollToCourse={scrollToCourse}
/>
}
/>
} />
+ setSelectedProduct={setSelectedProduct} subscriptions={subscriptions} setWillDo={setWillDo} />} />
-
{/* Modal */}
{showedModal && (
diff --git a/src/components/ProductDetailPage.js b/src/components/ProductDetailPage.js
index f024a08..4f77320 100644
--- a/src/components/ProductDetailPage.js
+++ b/src/components/ProductDetailPage.js
@@ -1,17 +1,20 @@
import React, { useState, useEffect } from 'react';
import styles from './ProductDetail.module.css';
+import { useNavigate } from 'react-router-dom';
const ProductDetail = ({ willDo, setWillDo, subscriptions, product, requestLogin, setShowedModal }) => {
const [showChildSelector, setShowChildSelector] = useState(false);
const [selectedChildIds, setSelectedChildIds] = useState([]);
const [matchingSubscriptions, setMatchingSubscriptions] = useState([]);
- const [selectedSubscriptionId, setSelectedSubscriptionId] = useState(null);
+ const [selectedSubscriptionId, setSelectedSubscriptionId] = useState(0);
const [showSubscriptionSelector, setShowSubscriptionSelector] = useState(false);
const [showNamingInput, setShowNamingInput] = useState(false);
const [customName, setCustomName] = useState('');
+ const navigate = useNavigate();
+
const onCheckout = () => {
const tokenCookie = document.cookie.split('; ').find(row => row.startsWith('token='));
const token = tokenCookie ? tokenCookie.split('=')[1] : '';
@@ -79,15 +82,14 @@ const ProductDetail = ({ willDo, setWillDo, subscriptions, product, requestLogin
};
const onConfirmChildren = () => {
- if (matchingSubscriptions.length > 0) {
+ if (matchingSubscriptions.length > 0 && !product.executeCheckout) {
setShowChildSelector(false);
setShowSubscriptionSelector(true);
return;
}
- else {
+ else if (!product.executeCheckout){
setShowChildSelector(false);
setShowNamingInput(true);
- return;
}
const tokenCookie = document.cookie.split('; ').find(row => row.startsWith('token='));
@@ -97,9 +99,9 @@ const ProductDetail = ({ willDo, setWillDo, subscriptions, product, requestLogin
alert('Pilih minimal satu produk');
return;
}
-
+ const encodedName = encodeURIComponent(product.executeCheckout);
const itemsParam = selectedChildIds.length > 0 ? JSON.stringify(selectedChildIds) : JSON.stringify([product.id]);
- window.location.href = `https://checkout.kediritechnopark.com/?token=${token}&itemsId=${itemsParam}&redirect_uri=https://kediritechnopark.com/products&redirect_failed=https://kediritechnopark.com`;
+ window.location.href = `https://checkout.kediritechnopark.com/?token=${token}&itemsId=${itemsParam}&set_name=${encodedName}&redirect_uri=https://kediritechnopark.com/products&redirect_failed=https://kediritechnopark.com`;
};
const onFinalCheckoutNewProduct = () => {
@@ -193,7 +195,7 @@ const ProductDetail = ({ willDo, setWillDo, subscriptions, product, requestLogin
{product.children.map(child => (
))}
-
- Total Harga: Rp {selectedChildIds
- .map(id => product.children.find(child => child.id === id)?.price || 0)
- .reduce((a, b) => a + b, 0)
- .toLocaleString('id-ID')}
-