Skip to content

Commit

Permalink
chore: example refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Apr 15, 2024
1 parent 99d093d commit 500589d
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 84 deletions.
82 changes: 0 additions & 82 deletions src/components/BudgetExpiryAlertAndModal/data/expiryThresholds.js

This file was deleted.

139 changes: 139 additions & 0 deletions src/components/BudgetExpiryAlertAndModal/data/expiryThresholds.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { MailtoLink } from '@edx/paragon';
import { PLAN_EXPIRY_VARIANTS } from './constants';

const expiryThresholds = {
120: ({ date }) => ({
notificationTemplate: {
title: 'Your Learner Credit plan expires soon',
variant: 'info',
message: ({ contactEmail }) => (
<p>
Your Learner Credit plan expires ${date}. Contact
{contactEmail ? <MailtoLink to={contactEmail}>support</MailtoLink> : 'support'} today
to renew your plan and keep people learning.
</p>
),
dismissible: true,
},
modalTemplate: {
title: 'Your plan expires soon',
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support today to
renew your plan and keep people learning.
</p>
),
},
variant: PLAN_EXPIRY_VARIANTS.expiring,
}),
90: ({ date }) => ({
notificationTemplate: {
title: 'Reminder: Your Learner Credit plan expires soon',
variant: 'info',
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support today
to renew your plan and keep people learning.
</p>
),
dismissible: true,
},
modalTemplate: {
title: 'Reminder: Your plan expires soon',
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support today to
renew your plan and keep people learning.
</p>
),
},
variant: PLAN_EXPIRY_VARIANTS.expiring,
}),
60: ({ date }) => ({
notificationTemplate: {
title: `Your Learner Credit plan expires ${date}`,
variant: 'warning',
message: () => (
<p>
When your Learner Credit plan expires, you will no longer have access to administrative
functions and the remaining balance of your budget(s) will be unusable. Contact support
today to renew your plan.
</p>
),
dismissible: true,
},
modalTemplate: {
title: `Your Learner Credit plan expires ${date}`,
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support
today to renew your plan and keep people learning.
</p>
),
},
variant: PLAN_EXPIRY_VARIANTS.expiring,
}),
30: ({ date }) => ({
notificationTemplate: {
title: 'Your Learner Credit plan expires in less than 30 days',
variant: 'danger',
message: () => (
<p>
When your plan expires you will lose access to administrative functions and the remaining
balance of your plan&apos;s budget(s) will be unusable. Contact support today to renew your plan.
</p>
),
},
modalTemplate: {
title: 'Your Learner Credit plan expires in less than 30 days',
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support today
to renew your plan and keep people learning.
</p>
),
},
variant: PLAN_EXPIRY_VARIANTS.expiring,
}),
10: ({ date, days, hours }) => ({
notificationTemplate: {
title: `Reminder: Your Learner Credit plan expires ${date}`,
variant: 'danger',
message: () => (
<p>
Your Learner Credit plan expires in <strong>{days} days and {hours} hours</strong>. Contact
support today to renew your plan.
</p>
),
},
modalTemplate: {
title: `Reminder: Your Learner Credit plan expires ${date}`,
message: () => (
<p>
Your Learner Credit plan expires {date}. Contact support today to
renew your plan and keep people learning.
</p>
),
},
variant: PLAN_EXPIRY_VARIANTS.expiring,
}),
0: ({ date }) => ({
notificationTemplate: null,
modalTemplate: {
title: 'Your Learner Credit plan has expired',
message: () => (
<>
<p>
Your Learner Credit Plan expired on {date}. You are no longer have
access to administrative functions and the remaining balance of your
plan&apos;s budget(s) are no longer available to spend
</p>
<p>Please contact support if you have any questions or concerns.</p>
</>
),
},
variant: PLAN_EXPIRY_VARIANTS.expired,
}),
};

export default expiryThresholds;
7 changes: 5 additions & 2 deletions src/components/BudgetExpiryAlertAndModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ const BudgetExpiryAlertAndModal = ({ enterpriseUUID, enterpriseFeatures }) => {
alertOpen,
alertClose,
);
const NotificationMessage = notification?.message;
const ModalMessage = modal?.message;

const trackEventMetadata = useMemo(() => {
if (modal === null && notification === null) { return {}; }
Expand Down Expand Up @@ -88,7 +90,7 @@ const BudgetExpiryAlertAndModal = ({ enterpriseUUID, enterpriseFeatures }) => {
data-testid="expiry-notification-alert"
>
<Alert.Heading>{notification.title}</Alert.Heading>
<p>{notification.message}</p>
<NotificationMessage />
</Alert>
)}

Expand Down Expand Up @@ -116,7 +118,8 @@ const BudgetExpiryAlertAndModal = ({ enterpriseUUID, enterpriseFeatures }) => {
</ActionRow>
)}
>
{modal.message}
{/* <ModalMessage contactEmail={getContactEmail(enterpriseCustomer)} */}
<ModalMessage />
</AlertModal>
)}
</>
Expand Down

0 comments on commit 500589d

Please sign in to comment.