fix signup bug

This commit is contained in:
Ruidy Nemausat 2020-05-19 13:43:59 +02:00
parent e02262ce19
commit 9b47db07dc
2 changed files with 23 additions and 25 deletions

View file

@ -6,8 +6,8 @@ import Repo from '../types/Repo';
/** Shorter dev interface */ /** Shorter dev interface */
export interface DevSummary { export interface DevSummary {
id?: string; id?: string;
displayName: string; displayName?: string;
avatarUrl: string; avatarUrl?: string;
description: string; description: string;
status: string; status: string;
company: string; company: string;
@ -40,18 +40,15 @@ export const getDescription = (status?: string, company?: string): string => {
* new Dev() returns a placeholder used when initializing a new profile. * new Dev() returns a placeholder used when initializing a new profile.
* id is not specified to not overwrite document uid. * id is not specified to not overwrite document uid.
*/ */
export class Dev implements IDev { export const blankDev: IDev = {
id?: string; isActive: true,
isActive = true; status: 'Developer',
displayName = ''; company: '',
status = 'Developer'; description: '',
company = ''; location: '',
avatarUrl = ''; skills: [],
description = ''; github: '',
location = ''; links: {
skills: string[] = [];
github: string = '';
links: Links = {
website: '', website: '',
instagram: '', instagram: '',
facebook: '', facebook: '',
@ -59,12 +56,12 @@ export class Dev implements IDev {
twitter: '', twitter: '',
github: '', github: '',
youtube: '', youtube: '',
}; },
bio = ''; bio: '',
experiences: Experience[] = []; experiences: [],
educations: Education[] = []; educations: [],
repos: Repo[] = []; repos: [],
} };
/** /**
* sample Dev for development and tests * sample Dev for development and tests

View file

@ -5,17 +5,18 @@ import Routes from '../constants/routes';
// Redux // Redux
import {WithFirebaseProps} from 'react-redux-firebase'; import {WithFirebaseProps} from 'react-redux-firebase';
import {enhance} from '../store/firebase'; import {enhance} from '../store/firebase';
import User, {newUser} from '../models/User';
// Style // Style
import GoogleButton from 'react-google-button'; import GoogleButton from 'react-google-button';
import Alert from '../components/Alert'; import Alert from '../components/Alert';
import Header from '../components/Header'; import Header from '../components/Header';
// Typing
import IDev, {blankDev} from '../models/Dev';
import User, {newUser} from '../models/User';
// Form // Form
import useForm from '../hooks'; import useForm from '../hooks';
import {Dev} from '../models/Dev';
// extends withFirebaseProps type to ad profile info // extends withFirebaseProps type to ad profile info
interface IProps extends Dev, WithFirebaseProps<User> { interface IProps extends IDev, WithFirebaseProps<User> {
isEmpty: boolean; isEmpty: boolean;
isLoaded: boolean; isLoaded: boolean;
} }
@ -57,7 +58,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
firebase firebase
.createUser({email, password}, newUser(name, email)) .createUser({email, password}, newUser(name, email))
.then(() => { .then(() => {
firebase.updateProfile(new Dev(), {useSet: true, merge: true}); firebase.updateProfile(blankDev, {useSet: true, merge: true});
resetForm(); resetForm();
}) })
.catch(err => setError(err)); .catch(err => setError(err));
@ -82,7 +83,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
) )
.then(() => { .then(() => {
if (!exists) if (!exists)
firebase.updateProfile(new Dev(), {useSet: true, merge: true}); firebase.updateProfile(blankDev, {useSet: true, merge: true});
}); });
}) })
.catch(err => setError(err)); .catch(err => setError(err));