Skip to content

Commit

Permalink
fix: signup toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
sasicodes committed Feb 27, 2024
1 parent ce98ea9 commit 27519f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
5 changes: 5 additions & 0 deletions apps/web/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const moduleExports = {
destination: '/u/:namespace/:handle',
permanent: true
},
{
source: '/signup',
destination: '/login?signup=true',
permanent: true
},
{
source: '/discord',
destination:
Expand Down
16 changes: 12 additions & 4 deletions apps/web/src/components/Login/Authenticate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import {
WarningOutline
} from '@tape.xyz/ui'
import { useRouter } from 'next/router'
import React, { memo, useCallback, useMemo, useState } from 'react'
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react'
import toast from 'react-hot-toast'
import { useAccount, useSignMessage } from 'wagmi'

import Signup from './Signup'

const Authenticate = () => {
const {
query: { as }
query: { as, signup }
} = useRouter()

const [loading, setLoading] = useState(false)
Expand All @@ -46,6 +46,12 @@ const Authenticate = () => {
const { address, connector, isConnected } = useAccount()
const { resetStore: resetApolloStore } = useApolloClient()

useEffect(() => {
if (signup) {
setShowSignup(true)
}
}, [signup])

const onError = () => {
signOut()
}
Expand All @@ -63,7 +69,6 @@ const Authenticate = () => {
onCompleted: (data) => {
const profiles = data?.profilesManaged.items
if (profiles?.length) {
setShowSignup(false)
const profile = [...profiles].reverse()[0]
setSelectedProfileId(as || profile.id)
} else {
Expand Down Expand Up @@ -178,7 +183,10 @@ const Authenticate = () => {
<div className="space-y-4 text-left">
{!IS_MAINNET && showSignup ? (
<Signup
onSuccess={() => refetch()}
onSuccess={() => {
setShowSignup(false)
refetch()
}}
setShowSignup={setShowSignup}
showLogin={Boolean(profile)}
/>
Expand Down

0 comments on commit 27519f9

Please sign in to comment.