ente/src/pages/success.tsx

47 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-03-10 03:24:33 +00:00
import Container from 'components/Container';
2021-03-12 11:43:02 +00:00
import router from 'next/router';
2021-03-10 03:24:33 +00:00
import { useEffect, useState } from 'react';
2021-03-12 17:38:06 +00:00
import { Button, Spinner } from 'react-bootstrap';
import billingService, { Subscription } from 'services/billingService';
2021-03-12 17:38:06 +00:00
import constants from 'utils/strings/constants';
2021-03-10 03:24:33 +00:00
export default function SuccessRedirect() {
2021-03-12 17:38:06 +00:00
const [subscription, setSubscription] = useState<Subscription>(null);
2021-03-10 03:24:33 +00:00
useEffect(() => {
const urlParams = new URLSearchParams(window.location.search);
const sessionId = urlParams.get('session_id');
if (sessionId) {
(async () => {
const subscription = await billingService.verifySubscription(
2021-03-10 03:24:33 +00:00
sessionId
);
2021-03-12 17:38:06 +00:00
setSubscription(subscription);
2021-03-10 03:24:33 +00:00
})();
}
}, []);
return (
2021-03-12 11:43:02 +00:00
<Container style={{ color: '#fff' }}>
2021-03-10 03:24:33 +00:00
<div>
2021-03-12 17:38:06 +00:00
{subscription ? (
<>
<h1>Your payment succeeded</h1>
<h4>
{constants.RENEWAL_ACTIVE_SUBSCRIPTION_INFO(
2021-03-12 17:38:06 +00:00
subscription?.expiryTime
)}
</h4>
2021-04-09 08:53:13 +00:00
<Button
variant="success"
onClick={() => router.push('/gallery')}
>
2021-03-12 17:38:06 +00:00
Go Back To Gallery
</Button>
</>
) : (
<Spinner animation="border" />
)}
2021-03-10 03:24:33 +00:00
</div>
</Container>
);
}