-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: display warning when plan is about to expire #1177
Merged
adamstankiewicz
merged 1 commit into
openedx:master
from
zwidekalanga:zwidekalanga/ent-7934
Apr 11, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export const SEEN_ENTERPRISE_EXPIRATION_ALERT_COOKIE_PREFIX = 'seen-enterprise-expiration-alert-'; | ||
|
||
export const SEEN_ENTERPRISE_EXPIRATION_MODAL_COOKIE_PREFIX = 'seen-enterprise-expiration-modal-'; | ||
|
||
export const PLAN_EXPIRY_VARIANTS = { | ||
expired: 'Expired', | ||
expiring: 'Expiring', | ||
}; |
82 changes: 82 additions & 0 deletions
82
src/components/BudgetExpiryAlertAndModal/data/expiryThresholds.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import sanitizeHTML from 'sanitize-html'; | ||
import parse from 'html-react-parser'; | ||
import { PLAN_EXPIRY_VARIANTS } from './constants'; | ||
|
||
const expiryThresholds = { | ||
120: ({ date }) => ({ | ||
notificationTemplate: { | ||
title: 'Your Learner Credit plan expires soon', | ||
variant: 'info', | ||
message: `Your Learner Credit plan expires ${date}. Contact support today to renew your plan and keep people learning.`, | ||
dismissible: true, | ||
}, | ||
modalTemplate: { | ||
title: 'Your plan expires soon', | ||
message: parse(sanitizeHTML(`Your Learner Credit plan expires ${date}. Contact support today to renew your plan and keep people learning.`)), | ||
}, | ||
variant: PLAN_EXPIRY_VARIANTS.expiring, | ||
}), | ||
90: ({ date }) => ({ | ||
notificationTemplate: { | ||
title: 'Reminder: Your Learner Credit plan expires soon', | ||
variant: 'info', | ||
message: `Your Learner Credit plan expires ${date}. Contact support today to renew your plan and keep people learning.`, | ||
dismissible: true, | ||
}, | ||
modalTemplate: { | ||
title: 'Reminder: Your plan expires soon', | ||
message: parse(sanitizeHTML(`Your Learner Credit plan expires ${date}. Contact support today to renew your plan and keep people learning.`)), | ||
}, | ||
variant: PLAN_EXPIRY_VARIANTS.expiring, | ||
}), | ||
60: ({ date }) => ({ | ||
notificationTemplate: { | ||
title: `Your Learner Credit plan expires ${date}`, | ||
variant: 'warning', | ||
message: '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.', | ||
dismissible: true, | ||
}, | ||
modalTemplate: { | ||
title: `Your Learner Credit plan expires ${date}`, | ||
message: parse(sanitizeHTML(`Your Learner Credit plan expires ${date}. Contact support today to renew your plan and keep people learning.`)), | ||
}, | ||
variant: PLAN_EXPIRY_VARIANTS.expiring, | ||
}), | ||
30: ({ date }) => ({ | ||
notificationTemplate: { | ||
title: 'Your Learner Credit plan expires in less than 30 days', | ||
variant: 'danger', | ||
message: 'When your plan expires you will lose access to administrative functions and the remaining balance of your plan’s budget(s) will be unusable. Contact support today to renew your plan.', | ||
}, | ||
modalTemplate: { | ||
title: 'Your Learner Credit plan expires in less than 30 days', | ||
message: parse(sanitizeHTML(`<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: parse(sanitizeHTML(`Your Learner Credit plan expires in <strong>${days} days and ${hours} hours</strong>. Contact support today to renew your plan.`)), | ||
}, | ||
modalTemplate: { | ||
title: `Reminder: Your Learner Credit plan expires ${date}`, | ||
message: parse(sanitizeHTML(`<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: parse(sanitizeHTML( | ||
`<p>Your Learner Credit Plan expired on ${date}. You are no longer have access to administrative functions and the remaining balance of your plan's budget(s) are no longer available to spend</p>` | ||
+ '<p>Please contact your representative if you have any questions or concerns.</p>', | ||
)), | ||
}, | ||
variant: PLAN_EXPIRY_VARIANTS.expired, | ||
}), | ||
}; | ||
|
||
export default expiryThresholds; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if no alert is rendered, it appears (per the Admin.test.jsx.snap snapshot file) this renders an empty div with
mt-4
. Is this adding extra whitespace to the Learner Progress Report when there is no budget expiry alert?Perhaps the
.mt-4
could be rendered within thediv.col
below where we render the<h2>
heading, which already has a.mt-4
specified all the time.