Skip to content

Commit

Permalink
feat: updated the custom expiration model design and truly blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
jajjibhai008 committed Oct 17, 2024
1 parent 91b9efe commit 2f5433c
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions src/components/expired-subscription-modal/index.jsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
import {
StandardModal, useToggle,
useToggle, AlertModal, Button, ActionRow,
} from '@openedx/paragon';
import { Link } from 'react-router-dom';
import { useSubscriptions } from '../app/data';

const ExpiredSubscriptionModal = () => {
const { data: { customerAgreement } } = useSubscriptions();
const [isOpen, ,close] = useToggle(true);
const [isOpen] = useToggle(true);
if (!customerAgreement?.hasCustomLicenseExpirationMessaging) {
return null;
}
const onClickHandler = () => {
let url = customerAgreement?.urlForButtonInModal;

if (url) {
// Check if the URL starts with 'http://' or 'https://'
if (!url.startsWith('http://') && !url.startsWith('https://')) {
// Prepend 'https://' if the URL is missing the protocol
url = `https://${url}`;
}

// Navigate to the full URL
window.open(url, '_blank'); // Opening in a new tab
}
};
return (
<StandardModal
<AlertModal
title={customerAgreement?.modalHeaderText}
isOpen={isOpen}
className="d-flex justify-content-center align-items-center text-wrap text-right "
hasCloseButton
onClose={close}
onClose={() => {}}
isBlocking
footerNode={(
<ActionRow>
<Button
onClick={onClickHandler}
>
{customerAgreement?.buttonLabelInModal}
</Button>
</ActionRow>
)}
>
<p className="text-center">
{customerAgreement?.expiredSubscriptionModalMessaging}
<Link className="text-decoration-none" to={customerAgreement?.urlForExpiredModal}> {customerAgreement?.hyperLinkTextForExpiredModal}</Link>
</p>
</StandardModal>
{/* eslint-disable-next-line react/no-danger */}
<div dangerouslySetInnerHTML={{ __html: customerAgreement?.expiredSubscriptionModalMessaging }} />
</AlertModal>
);
};

Expand Down

0 comments on commit 2f5433c

Please sign in to comment.