ok
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
const LoginRegister = ({postLoginAction, setPostLoginAction}) => {
|
||||
const LoginRegister = ({setShowedModal}) => {
|
||||
const [tab, setTab] = useState('login'); // 'login' or 'register'
|
||||
const [email, setEmail] = useState('');
|
||||
const [username, setUsername] = useState('');
|
||||
@@ -95,11 +95,17 @@ const LoginRegister = ({postLoginAction, setPostLoginAction}) => {
|
||||
if (token) {
|
||||
document.cookie = `token=${token}; path=/; max-age=${7 * 24 * 60 * 60}`;
|
||||
|
||||
if (postLoginAction) {
|
||||
postLoginAction(); // resume action (e.g., checkout)
|
||||
setPostLoginAction(null);
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const nextAction = params.get('next');
|
||||
|
||||
if (nextAction === 'checkout') {
|
||||
params.delete('next');
|
||||
const newUrl = `${window.location.pathname}?${params.toString()}`;
|
||||
window.history.replaceState({}, '', newUrl);
|
||||
setShowedModal('product');
|
||||
} else {
|
||||
window.location.reload();
|
||||
}
|
||||
// window.location.reload()
|
||||
} else {
|
||||
alert('Token tidak ditemukan pada respons login');
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import styles from './ProductDetail.module.css';
|
||||
|
||||
const ProductDetail = ({ subscriptions, product, setPostLoginAction, setShowedModal }) => {
|
||||
const ProductDetail = ({ subscriptions, product, requestLogin, setShowedModal }) => {
|
||||
const [showChildSelector, setShowChildSelector] = useState(false);
|
||||
const [selectedChildIds, setSelectedChildIds] = useState([]);
|
||||
|
||||
@@ -33,8 +33,7 @@ const ProductDetail = ({ subscriptions, product, setPostLoginAction, setShowedMo
|
||||
const token = tokenCookie ? tokenCookie.split('=')[1] : '';
|
||||
|
||||
if (!token) {
|
||||
setPostLoginAction(() => () => setShowedModal('product'));
|
||||
setShowedModal('login');
|
||||
requestLogin('checkout');
|
||||
return;
|
||||
}
|
||||
if (product.type == 'product') {
|
||||
|
||||
Reference in New Issue
Block a user