Files
Compass/web/lib/util/signup.ts
Martin Braquet ba9b3cfb06 Add pretty formatting (#29)
* Test

* Add pretty formatting

* Fix Tests

* Fix Tests

* Fix Tests

* Fix

* Add pretty formatting fix

* Fix

* Test

* Fix tests

* Clean typeckech

* Add prettier check

* Fix api tsconfig

* Fix api tsconfig

* Fix tsconfig

* Fix

* Fix

* Prettier
2026-02-20 17:32:27 +01:00

28 lines
730 B
TypeScript

import {getProfileRow} from 'common/profiles/profile'
import Router from 'next/router'
import toast from 'react-hot-toast'
import {firebaseLogin} from 'web/lib/firebase/users'
import {db} from 'web/lib/supabase/db'
export const signupThenMaybeRedirectToSignup = async () => {
try {
const creds = await firebaseLogin()
const userId = creds?.user.uid
if (userId) {
const profile = await getProfileRow(userId, db)
if (profile) {
await Router.push('/')
} else {
await Router.push('/onboarding')
}
}
} catch (e: any) {
console.error(e)
toast.error('Failed to sign in: ' + e.message)
}
}
export async function signupRedirect() {
await Router.push('/register')
}