Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Try using history instead of window.loc.href #3706

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Try using history instead of window.loc.href
  • Loading branch information
calvin-codecov committed Feb 3, 2025
commit 5658f520a538c203ab93a734a536391ec3176a5e
13 changes: 10 additions & 3 deletions src/pages/TermsOfService/TermsOfService.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { zodResolver } from '@hookform/resolvers/zod'
import { useEffect, useLayoutEffect } from 'react'
import { SubmitHandler, useForm } from 'react-hook-form'
import { useHistory, useLocation } from 'react-router-dom'
import { z } from 'zod'

import config from 'config'
@@ -132,6 +133,9 @@ export default function TermsOfService() {
}
}, [currentUser, isDirty, reset])

const location = useLocation()
const history = useHistory()

const { mutate, isLoading: isMutationLoading } = useSaveTermsAgreement({
onSuccess: ({ data }) => {
if (data?.saveTermsAgreement?.error) {
@@ -140,9 +144,12 @@ export default function TermsOfService() {
return
}

const url = new URL(window.location.href)
url.searchParams.set('source', ONBOARDING_SOURCE)
window.location.href = url.toString()
const params = new URLSearchParams(location.search)
params.set('source', ONBOARDING_SOURCE)
history.push(`${location.pathname}?${params.toString()}`)
// const url = new URL(window.location.href)
// url.searchParams.set('source', ONBOARDING_SOURCE)
// window.location.href = url.toString()
},
onError: (error) => setError('apiError', error),
})