Skip to content

Commit

Permalink
feat: fetch app url after login
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <[email protected]>
  • Loading branch information
Innei committed Sep 18, 2024
1 parent 86c114a commit 32a21b4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/modules/shared/GoToAdminEditingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Props {
}
export const GoToAdminEditingButton: Component<Props> = (props) => {
const isLogin = useIsLogged()
console.log(isLogin)
const resolveAdminUrl = useResolveAdminUrl()
const { id, type, className } = props
if (!isLogin) return null
Expand Down
7 changes: 5 additions & 2 deletions src/providers/root/auth-session-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { nanoid } from 'nanoid'
import type { AdapterUser } from 'next-auth/adapters'
import { useEffect } from 'react'

import { isLoggedAtom } from '~/atoms'
import { fetchAppUrl, isLoggedAtom } from '~/atoms'
import { setSessionReader } from '~/atoms/hooks/reader'
import { apiClient } from '~/lib/request'
import { jotaiStore } from '~/lib/store'
Expand All @@ -30,7 +30,10 @@ export const AuthSessionProvider: Component = ({ children }) => {
if (!session) return
const transformedData = simpleCamelcaseKeys(session)
setSessionReader(transformedData)
if (transformedData.isOwner) jotaiStore.set(isLoggedAtom, true)
if (transformedData.isOwner) {
jotaiStore.set(isLoggedAtom, true)
fetchAppUrl()
}
}, [session])
return children
}

0 comments on commit 32a21b4

Please sign in to comment.