Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #111 from hifis-net/fix-get-started-button
Browse files Browse the repository at this point in the history
fix: write cookie only when clicking on the button
  • Loading branch information
cmeessen authored Feb 16, 2023
2 parents 61af3fa + ca63c0c commit 8c338c0
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions frontend/components/home/helmholtz/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ export default function Home() {
const {session} = useAuth()
const status = session?.status || 'loading'

let getStartedHref:string
if (status !== 'authenticated') {
getStartedHref = providers[0]?.redirectUrl ?? ''
if (typeof document !== 'undefined' ) {
document.cookie = `rsd_pathname=${location.href}software/add;path=/auth;SameSite=None;Secure`
}
} else {
getStartedHref = '/software/add'
}

useEffect(() => {
// Initialize AOS library
AOS.init()
Expand Down Expand Up @@ -92,15 +82,17 @@ export default function Home() {
event.target.style.backgroundImage = 'url("/images/pexels-olena-bohovyk-3646172.jpg")'
}

// Only required if we have the "Add your software button"
const handleClickOpen = () => {
const loginButton = document.querySelector('.rsd-login-button')
if (loginButton) {
const evt = new MouseEvent('click', {
bubbles: true
})
loginButton.dispatchEvent(evt)
const handleClickAddSoftware = () => {
let getStartedHref:string
if (status !== 'authenticated') {
getStartedHref = providers[0]?.redirectUrl ?? ''
if (typeof document !== 'undefined' ) {
document.cookie = `rsd_pathname=${location.href}software/add;path=/auth;SameSite=None;Secure`
}
} else {
getStartedHref = '/software/add'
}
window.location.href = getStartedHref
}

const backgroundTransitionStyle = {
Expand Down Expand Up @@ -149,11 +141,11 @@ export default function Home() {
The Helmholtz RSD is now <span className="hgf-text-highlight">ready to use for all Helmholtz users</span>.
If you have an account at a Helmholtz institution, login and promote your Research Software now:
</div>
<Link href={getStartedHref} passHref>
<a onClick={handleClickAddSoftware}>
<div className="mx-auto mt-10 w-[250px] bg-[#05e5ba] hover:bg-primary text-secondary text-center font-medium text-2xl py-4 px-6 rounded-full">
Add your software
</div>
</Link>
</a>
</div>
</div>
</div>
Expand Down

0 comments on commit 8c338c0

Please sign in to comment.