mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
5b29729e9b
[web] Fix loading plans page with group plan modal hash (#groups) does not enable the group plan table GitOrigin-RevId: acd2e683d8e8d3f2b3325c3745856fe27c96eed6
52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
import { GROUP_PLAN_MODAL_HASH } from '@/features/plans/group-plan-modal'
|
|
|
|
export function getViewInfoFromHash() {
|
|
const hashValue = window.location.hash.replace('#', '')
|
|
|
|
const groupPlanModalHashValue = GROUP_PLAN_MODAL_HASH.replace('#', '')
|
|
|
|
switch (hashValue) {
|
|
case 'individual-monthly':
|
|
return ['individual', 'monthly']
|
|
case 'individual-annual':
|
|
return ['individual', 'annual']
|
|
case groupPlanModalHashValue:
|
|
case 'group':
|
|
return ['group', 'annual']
|
|
case 'student-monthly':
|
|
return ['student', 'monthly']
|
|
case 'student-annual':
|
|
return ['student', 'annual']
|
|
default:
|
|
return ['individual', 'monthly']
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param {individual | group | student} viewTab
|
|
* @param {monthly | annual} period
|
|
*/
|
|
export function setHashFromViewTab(viewTab, period) {
|
|
const newHash = viewTab === 'group' ? 'group' : `${viewTab}-${period}`
|
|
if (window.location.hash.replace('#', '') !== newHash) {
|
|
window.location.hash = newHash
|
|
}
|
|
}
|
|
|
|
// this is only for the students link in footer
|
|
export function handleForStudentsLinkInFooter() {
|
|
const links = document.querySelectorAll('[data-ol-for-students-link]')
|
|
|
|
links.forEach(function (link) {
|
|
link.addEventListener('click', function () {
|
|
if (window.location.pathname === '/user/subscription/plans') {
|
|
// reload location with the correct hash
|
|
const newURL =
|
|
'/user/subscription/plans?itm_referrer=footer-for-students#student-annual'
|
|
history.replaceState(null, '', newURL)
|
|
location.reload()
|
|
}
|
|
})
|
|
})
|
|
}
|