Skip to content

Commit

Permalink
Add from url in sign in href
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 5, 2024
1 parent 1a48950 commit 72977d8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/auth/AuthorizationPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { Button } from 'antd'
import { getCurrentUrlOrigin } from 'src/utils/url'
import urlJoin from 'src/utils/url-join'
import { NotificationsBell, useNotifCounterContext } from '../activity/NotifCounter'
import { NewPostButtonInTopMenu } from '../posts/NewPostButtonInTopMenu'
import { MyAccountPopup } from '../profiles/address-views'
import { isServerSide } from '../utils'
import { useMyAddress } from './MyAccountsContext'

function getCurrentPathanme() {
if (isServerSide()) return ''
return encodeURIComponent(window.location.href.replace(getCurrentUrlOrigin(), ''))
}

export const AuthorizationPanel = () => {
const address = useMyAddress()
const { unreadCount } = useNotifCounterContext()
Expand All @@ -17,7 +25,7 @@ export const AuthorizationPanel = () => {
<MyAccountPopup className='profileName' />
</>
) : (
<a href='/c/widget/login'>
<a href={urlJoin('/c/widget/login', `?from=${getCurrentPathanme()}`)}>
<Button type='default'>Sign in</Button>
</a>
)}
Expand Down

0 comments on commit 72977d8

Please sign in to comment.