Skip to content

Commit 005cfad

Browse files
committed
refactor: Simplify signIn function by removing providerName parameter
1 parent 18f5ac4 commit 005cfad

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

src/features/auth/components/AuthModal.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type AuthModalProps = {
1717
export const AuthModal = ({ showAuth }: AuthModalProps) => {
1818
const { closeAuthModal, initState } = useAuth()
1919

20-
const signIn = (provider: AuthProvider, providerName: string) => {
20+
const signIn = (provider: AuthProvider) => {
2121
signInWithPopup(firebaseAuth, provider)
2222
.then((result) => {
2323
const credential = OAuthProvider.credentialFromResult(result)
@@ -26,7 +26,7 @@ export const AuthModal = ({ showAuth }: AuthModalProps) => {
2626
const name = result.user.displayName
2727
const imageURL = result.user.photoURL
2828
if (idToken && name && email && imageURL) {
29-
trackUserConnect(providerName)
29+
trackUserConnect(provider.providerId)
3030
closeAuthModal()
3131
initState({
3232
idToken: idToken,
@@ -40,7 +40,7 @@ export const AuthModal = ({ showAuth }: AuthModalProps) => {
4040
})
4141
.catch((error) => {
4242
console.log(error)
43-
toast(`We couldn't login to your ${providerName} account!!`, { theme: 'failure' })
43+
toast(`We couldn't login to your ${provider.providerId} account!!`, { theme: 'failure' })
4444
})
4545
}
4646

@@ -70,17 +70,11 @@ export const AuthModal = ({ showAuth }: AuthModalProps) => {
7070
</button>
7171
</div>
7272
<div className="buttons">
73-
<Button
74-
startIcon={<FaGithub />}
75-
onClick={() => signIn(githubAuthProvider, 'Github')}
76-
size="large">
73+
<Button startIcon={<FaGithub />} onClick={() => signIn(githubAuthProvider)} size="large">
7774
Connect with Github
7875
</Button>
7976

80-
<Button
81-
startIcon={<FcGoogle />}
82-
onClick={() => signIn(googleAuthProvider, 'Google')}
83-
size="large">
77+
<Button startIcon={<FcGoogle />} onClick={() => signIn(googleAuthProvider)} size="large">
8478
Connect with Google
8579
</Button>
8680
</div>

0 commit comments

Comments
 (0)