mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-07 19:16:44 +00:00
fix signup bug
This commit is contained in:
parent
e02262ce19
commit
9b47db07dc
2 changed files with 23 additions and 25 deletions
|
|
@ -6,8 +6,8 @@ import Repo from '../types/Repo';
|
|||
/** Shorter dev interface */
|
||||
export interface DevSummary {
|
||||
id?: string;
|
||||
displayName: string;
|
||||
avatarUrl: string;
|
||||
displayName?: string;
|
||||
avatarUrl?: string;
|
||||
description: string;
|
||||
status: 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.
|
||||
* id is not specified to not overwrite document uid.
|
||||
*/
|
||||
export class Dev implements IDev {
|
||||
id?: string;
|
||||
isActive = true;
|
||||
displayName = '';
|
||||
status = 'Developer';
|
||||
company = '';
|
||||
avatarUrl = '';
|
||||
description = '';
|
||||
location = '';
|
||||
skills: string[] = [];
|
||||
github: string = '';
|
||||
links: Links = {
|
||||
export const blankDev: IDev = {
|
||||
isActive: true,
|
||||
status: 'Developer',
|
||||
company: '',
|
||||
description: '',
|
||||
location: '',
|
||||
skills: [],
|
||||
github: '',
|
||||
links: {
|
||||
website: '',
|
||||
instagram: '',
|
||||
facebook: '',
|
||||
|
|
@ -59,12 +56,12 @@ export class Dev implements IDev {
|
|||
twitter: '',
|
||||
github: '',
|
||||
youtube: '',
|
||||
};
|
||||
bio = '';
|
||||
experiences: Experience[] = [];
|
||||
educations: Education[] = [];
|
||||
repos: Repo[] = [];
|
||||
}
|
||||
},
|
||||
bio: '',
|
||||
experiences: [],
|
||||
educations: [],
|
||||
repos: [],
|
||||
};
|
||||
|
||||
/**
|
||||
* sample Dev for development and tests
|
||||
|
|
|
|||
|
|
@ -5,17 +5,18 @@ import Routes from '../constants/routes';
|
|||
// Redux
|
||||
import {WithFirebaseProps} from 'react-redux-firebase';
|
||||
import {enhance} from '../store/firebase';
|
||||
import User, {newUser} from '../models/User';
|
||||
// Style
|
||||
import GoogleButton from 'react-google-button';
|
||||
import Alert from '../components/Alert';
|
||||
import Header from '../components/Header';
|
||||
// Typing
|
||||
import IDev, {blankDev} from '../models/Dev';
|
||||
import User, {newUser} from '../models/User';
|
||||
// Form
|
||||
import useForm from '../hooks';
|
||||
import {Dev} from '../models/Dev';
|
||||
|
||||
// extends withFirebaseProps type to ad profile info
|
||||
interface IProps extends Dev, WithFirebaseProps<User> {
|
||||
interface IProps extends IDev, WithFirebaseProps<User> {
|
||||
isEmpty: boolean;
|
||||
isLoaded: boolean;
|
||||
}
|
||||
|
|
@ -57,7 +58,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
|
|||
firebase
|
||||
.createUser({email, password}, newUser(name, email))
|
||||
.then(() => {
|
||||
firebase.updateProfile(new Dev(), {useSet: true, merge: true});
|
||||
firebase.updateProfile(blankDev, {useSet: true, merge: true});
|
||||
resetForm();
|
||||
})
|
||||
.catch(err => setError(err));
|
||||
|
|
@ -82,7 +83,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
|
|||
)
|
||||
.then(() => {
|
||||
if (!exists)
|
||||
firebase.updateProfile(new Dev(), {useSet: true, merge: true});
|
||||
firebase.updateProfile(blankDev, {useSet: true, merge: true});
|
||||
});
|
||||
})
|
||||
.catch(err => setError(err));
|
||||
|
|
|
|||
Loading…
Reference in a new issue