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

Commit ca63c0c

Browse files
committed
fix: write cookie only when clicking on the button
1 parent 61af3fa commit ca63c0c

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

frontend/components/home/helmholtz/index.tsx

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ export default function Home() {
4848
const {session} = useAuth()
4949
const status = session?.status || 'loading'
5050

51-
let getStartedHref:string
52-
if (status !== 'authenticated') {
53-
getStartedHref = providers[0]?.redirectUrl ?? ''
54-
if (typeof document !== 'undefined' ) {
55-
document.cookie = `rsd_pathname=${location.href}software/add;path=/auth;SameSite=None;Secure`
56-
}
57-
} else {
58-
getStartedHref = '/software/add'
59-
}
60-
6151
useEffect(() => {
6252
// Initialize AOS library
6353
AOS.init()
@@ -92,15 +82,17 @@ export default function Home() {
9282
event.target.style.backgroundImage = 'url("/images/pexels-olena-bohovyk-3646172.jpg")'
9383
}
9484

95-
// Only required if we have the "Add your software button"
96-
const handleClickOpen = () => {
97-
const loginButton = document.querySelector('.rsd-login-button')
98-
if (loginButton) {
99-
const evt = new MouseEvent('click', {
100-
bubbles: true
101-
})
102-
loginButton.dispatchEvent(evt)
85+
const handleClickAddSoftware = () => {
86+
let getStartedHref:string
87+
if (status !== 'authenticated') {
88+
getStartedHref = providers[0]?.redirectUrl ?? ''
89+
if (typeof document !== 'undefined' ) {
90+
document.cookie = `rsd_pathname=${location.href}software/add;path=/auth;SameSite=None;Secure`
91+
}
92+
} else {
93+
getStartedHref = '/software/add'
10394
}
95+
window.location.href = getStartedHref
10496
}
10597

10698
const backgroundTransitionStyle = {
@@ -149,11 +141,11 @@ export default function Home() {
149141
The Helmholtz RSD is now <span className="hgf-text-highlight">ready to use for all Helmholtz users</span>.
150142
If you have an account at a Helmholtz institution, login and promote your Research Software now:
151143
</div>
152-
<Link href={getStartedHref} passHref>
144+
<a onClick={handleClickAddSoftware}>
153145
<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">
154146
Add your software
155147
</div>
156-
</Link>
148+
</a>
157149
</div>
158150
</div>
159151
</div>

0 commit comments

Comments
 (0)