Skip to content

Commit

Permalink
clients/web/docs: fix login return_to link when under docs.polar.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
frankie567 committed Jul 10, 2024
1 parent a250c80 commit 0900cb9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import LogoIcon from '@/components/Brand/LogoIcon'
import PolarMenu from '@/components/Layout/PolarMenu'
import { BrandingMenu } from '@/components/Layout/Public/BrandingMenu'
import { OrganizationPublicPageNav } from '@/components/Organization/OrganizationPublicPageNav'
import { OrganizationPublicSidebar } from '@/components/Organization/OrganizationPublicSidebar'
Expand All @@ -13,7 +14,6 @@ import {
} from '@polar-sh/sdk'
import { notFound } from 'next/navigation'
import React from 'react'
import { PolarMenu } from './LayoutPolarMenu'

const cacheConfig = {
next: {
Expand Down
2 changes: 1 addition & 1 deletion clients/apps/web/src/app/[organization]/[repo]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import LogoIcon from '@/components/Brand/LogoIcon'
import PolarMenu from '@/components/Layout/PolarMenu'
import { BrandingMenu } from '@/components/Layout/Public/BrandingMenu'
import { getServerSideAPI } from '@/utils/api/serverside'
import { organizationPageLink } from '@/utils/nav'
Expand All @@ -7,7 +8,6 @@ import Link from 'next/link'
import { notFound } from 'next/navigation'
import Avatar from 'polarkit/components/ui/atoms/avatar'
import React from 'react'
import { PolarMenu } from '../(sidebar)/LayoutPolarMenu'

const cacheConfig = {
next: {
Expand Down
2 changes: 1 addition & 1 deletion clients/apps/web/src/components/Documentation/UserMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use client'

import { PolarMenu } from '@/app/[organization]/(sidebar)/LayoutPolarMenu'
import { useClientSideLoadedUser } from '@/hooks/docs'
import { useListAdminOrganizations } from '@/hooks/queries'
import { Skeleton } from 'polarkit/components/ui/skeleton'
import PolarMenu from '../Layout/PolarMenu'

const UserMenu = () => {
const { user, loaded } = useClientSideLoadedUser()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,20 @@ import Link from 'next/link'
import { usePathname } from 'next/navigation'
import Button from 'polarkit/components/ui/atoms/button'

export const PolarMenu = ({
const PolarMenu = ({
authenticatedUser,
userAdminOrganizations,
}: {
authenticatedUser?: UserRead
userAdminOrganizations: Organization[]
}) => {
const pathname = usePathname()
const loginReturnTo = pathname ?? '/feed'
const createWithPolarReturnTo = '/me'
const host = window.location.protocol + '//' + window.location.host
const returnToPrefix = host !== CONFIG.FRONTEND_BASE_URL ? host : ''
const loginReturnTo = pathname
? `${returnToPrefix}${pathname}`
: `${returnToPrefix}/feed`
const createWithPolarReturnTo = `${returnToPrefix}/me`

// Fallback to client side user loading (needed as we're loading data in the layout, and it isn't refreshed on navigation)
const { currentUser: clientCurrentUser } = useAuth()
Expand Down Expand Up @@ -83,3 +87,5 @@ const CreateWithPolar = ({ returnTo }: { returnTo: string }) => {
/>
)
}

export default PolarMenu

0 comments on commit 0900cb9

Please sign in to comment.