Skip to content

Commit

Permalink
feat(fe): Add subcom recruitment notification and contribution notifi…
Browse files Browse the repository at this point in the history
…cation with a flag (#1210)

* Add subcom recruitment and contribution flags. The notification can now be activated via a boolean
  • Loading branch information
matthew-lim-matthew-lim authored Feb 22, 2025
1 parent 6306c19 commit cf302d7
Showing 1 changed file with 74 additions and 41 deletions.
115 changes: 74 additions & 41 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,56 +22,89 @@ const Page404 = React.lazy(() => import('./pages/Page404'));
const ProgressionChecker = React.lazy(() => import('./pages/ProgressionChecker'));
const TermPlanner = React.lazy(() => import('./pages/TermPlanner'));

// Subcommittee Recruitment flag
const activeRecruitment = true;

const App = () => {
const { theme } = useSelector((state: RootState) => state.settings);

const degree = useSelector((state: RootState) => state.degree);

useEffect(() => {
// using local storage since I don't want to risk invalidating the redux state right now
const cooldownMs = 1000 * 60 * 60 * 24 * 7; // every 7 days
const lastSeen = localStorage.getItem('last-seen-contribution');
// If actively recruiting subcommittee, notify every 11 hours. Otherwise, notify every 7 days.
const cooldownMs = activeRecruitment ? 1000 * 60 * 60 * 11 : 1000 * 60 * 60 * 24 * 7;
const lastSeen = localStorage.getItem('last-seen-contribution-recruitment');
if (lastSeen !== null && Date.now() - parseInt(lastSeen, 10) < cooldownMs) return;

localStorage.setItem('last-seen-contribution', Date.now().toString());
localStorage.setItem('last-seen-contribution-recruitment', Date.now().toString());

openNotification({
type: 'info',
message: 'Want to contribute?',
description: (
<>
Found a bug or have feedback? Open an issue on{' '}
<a
href="https://github.com/devsoc-unsw/circles/issues"
target="_blank"
rel="noopener noreferrer"
>
GitHub
</a>{' '}
or share your thoughts on{' '}
<a href="https://discord.gg/u9p34WUTcs" target="_blank" rel="noopener noreferrer">
Discord
</a>
!
<br />
<br />
Feeling brave? You can even fix it yourself by submitting a{' '}
<a
href="https://github.com/devsoc-unsw/circles/pulls"
target="_blank"
rel="noopener noreferrer"
>
pull request
</a>
!
<br />
<br />
Let&apos;s make <strong>Circles</strong> even better, together! &#128156;
</>
),
duration: 20,
icon: <NotificationOutlined style={{ color: lightTheme.purplePrimary }} />
});
if (activeRecruitment) {
// Actively recruiting for subcommittee
openNotification({
type: 'info',
message: 'Subcommittee Recruitment!',
description: (
<>
Interested in working on Circles or one of our other student-led projects? DevSoc is
currently recruiting subcommittee members!
<br />
<br />
This is a fantastic opportunity to contribute to a project with a substantial userbase
and learn from other programmers.
<br />
<br />
Find out more at{' '}
<a href="https://devsoc.app/get-involved" target="_blank" rel="noopener noreferrer">
devsoc.app/get-involved
</a>
<br />
<br />
Let&apos;s make <strong>Circles</strong> even better, together! &#128156;
</>
),
duration: 0, // Doesn't automatically expire
icon: <NotificationOutlined style={{ color: lightTheme.purplePrimary }} />
});
} else {
// Not actively recruiting for subcommittee
openNotification({
type: 'info',
message: 'Want to contribute?',
description: (
<>
Found a bug or have feedback? Open an issue on{' '}
<a
href="https://github.com/devsoc-unsw/circles/issues"
target="_blank"
rel="noopener noreferrer"
>
GitHub
</a>{' '}
or share your thoughts on{' '}
<a href="https://discord.gg/u9p34WUTcs" target="_blank" rel="noopener noreferrer">
Discord
</a>
!
<br />
<br />
Feeling brave? You can even fix it yourself by submitting a{' '}
<a
href="https://github.com/devsoc-unsw/circles/pulls"
target="_blank"
rel="noopener noreferrer"
>
pull request
</a>
!
<br />
<br />
Let&apos;s make <strong>Circles</strong> even better, together! &#128156;
</>
),
duration: 20, // Automatically expires after 20s
icon: <NotificationOutlined style={{ color: lightTheme.purplePrimary }} />
});
}
}, []);

return (
Expand Down

0 comments on commit cf302d7

Please sign in to comment.