Skip to content

Commit 108b224

Browse files
author
Osamah Ahmad
committed
warning
1 parent 5be159d commit 108b224

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/pages/Landing.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,7 @@ const Landing: React.FC<LandingProps> = () => {
527527
</Card>
528528
<Card className={sections[4]} variant='outlined'>
529529
<Typography level='h2' color='success'>{sectionTitles[sections[4]]}</Typography>
530-
<Button color='success' sx={{ width: 'fit-content' }} onClick={() => navigate(Paths.QuestionBank)}>Access the Question Bank</Button>
531-
{auth && auth.currentUser && <Typography>You're currently signed in as {auth.currentUser.email}. <Link onClick={() => auth.signOut()}>Sign Out</Link>.</Typography>}
530+
<Button color='success' sx={{ width: 'fit-content' }} onClick={() => navigate(auth.currentUser ? Paths.QuestionBank : Paths.SignUp)}>{auth.currentUser ? 'Access' : 'Sign up to'} the Question Bank</Button>
532531
</Card>
533532
<footer>
534533
<Typography>

src/pages/QuestionBank.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ const QuestionBank: React.FC = ({ }) => {
156156

157157
/* subscription */
158158
const [subscriptionChecked, setSubscriptionChecked] = useState<boolean>(false);
159+
const [subscriptionWillRenew, setSubscriptionWillRenew] = useState<boolean>();
159160
const [subscriptionExpiryDate, setSubscriptionExpiryDate] = useState<Date>();
160161

161162
const checkSubscription = useCallback(async () => {
@@ -178,6 +179,7 @@ const QuestionBank: React.FC = ({ }) => {
178179
}, [checkSubscription]);
179180

180181
const hasSubscriptionExpired = subscriptionExpiryDate && (subscriptionExpiryDate < new Date(Date.now()));
182+
const willSubscriptionExpireThisWeek = !subscriptionWillRenew && subscriptionExpiryDate && (subscriptionExpiryDate < new Date(Date.now() + (7 * 86400000)));
181183

182184
/* parse data */
183185
const [paragraphs, setParagraphs] = useState<string[]>([]);
@@ -213,16 +215,16 @@ const QuestionBank: React.FC = ({ }) => {
213215
)}
214216
{subscriptionExpiryDate && (
215217
<>
216-
<Alert color={hasSubscriptionExpired ? 'danger' : 'success'}>
218+
<Alert color={hasSubscriptionExpired ? 'danger' : (willSubscriptionExpireThisWeek ? 'warning' : 'success')}>
217219
<Typography
218220
level="body-sm"
219221
sx={{ color: "inherit", display: "flex", gap: ".25em", alignItems: "center" }}
220222
>
221-
Your subscription {hasSubscriptionExpired ? 'expired' : 'will renew'} on {
223+
Your subscription {hasSubscriptionExpired ? 'expired' : (subscriptionWillRenew ? 'will renew' : 'will expire')} at {
222224
subscriptionExpiryDate && (
223225
subscriptionExpiryDate.toLocaleString('en-GB', {
224-
hour: '2-digit',
225-
minute: '2-digit',
226+
hour: 'numeric',
227+
minute: 'numeric',
226228
hour12: true
227229
}) +
228230
' on ' +
@@ -233,6 +235,7 @@ const QuestionBank: React.FC = ({ }) => {
233235
year: 'numeric'
234236
}))
235237
}.
238+
{subscriptionWillRenew && <Typography><Link>Cancel Renewal</Link>.</Typography>}
236239
</Typography>
237240
</Alert>
238241
{paragraphs.map((paragraph, index) => (

src/resources/Strings.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
enum Strings {
22
AppName = 'Radiology Interview Prep.',
33
TermsOfService = 'Terms of Service',
4-
PrivacyPolicy = 'Privacy Policy'
4+
PrivacyPolicy = 'Privacy Policy',
5+
SignUp = 'Create Account'
56
}
67

78
export default Strings;

0 commit comments

Comments
 (0)