Skip to content

Commit

Permalink
fix: payment page (#243)
Browse files Browse the repository at this point in the history
* fix:remove playground and unnecessary files

* feat: added payment

* fix: env vars

* fix: env vars

* fix: hydration err
  • Loading branch information
Srish-ty authored Nov 3, 2024
1 parent c55adf3 commit 2e6113d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
32 changes: 14 additions & 18 deletions src/app/payment/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,35 @@ import { PayContainer } from './payment.styles';
import Cookies from 'js-cookie';

const PaymentPage = () => {
const [isClient, setIsClient] = useState(false);
const [userEmail, setUserEmail] = useState('');
const [userEmail, setUserEmail] = useState(null);

useEffect(() => {
setIsClient(true);
const userData = Cookies.get('userData');
const email = (userData && JSON.parse(userData).email) || '';
setUserEmail(email);
}, []);

const validEmails = [
const validMails = [
'[email protected]',
'[email protected]',
'[email protected]',
];

if (!isClient) {
return null;
if (userEmail === null) {
return <div>Loading...</div>;
}

return (
<div>
<PayContainer>
{validEmails.includes(userEmail) ? (
<>
<h1>Payment Page</h1>
<PayButton />
</>
) : (
<h1>404 page not found</h1>
)}
</PayContainer>
</div>
<PayContainer>
{validMails.includes(userEmail) ? (
<div>
<h1>Payment Page</h1>
<PayButton />
</div>
) : (
<h1>404 page not found</h1>
)}
</PayContainer>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/app/payment/payButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PayButton = () => {
body: JSON.stringify({
amount: 100,
orderId: 'unique_order_id_12345',
callbackUrl: `${window.location.origin}/callback`,
callbackUrl: `${window.location.origin}`,
}),
});

Expand Down

0 comments on commit 2e6113d

Please sign in to comment.