diff --git a/src/models/Dev.ts b/src/models/Dev.ts index 792b170..7d3567d 100644 --- a/src/models/Dev.ts +++ b/src/models/Dev.ts @@ -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 diff --git a/src/pages/SignUp.tsx b/src/pages/SignUp.tsx index ef7d19b..dc654aa 100644 --- a/src/pages/SignUp.tsx +++ b/src/pages/SignUp.tsx @@ -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 { +interface IProps extends IDev, WithFirebaseProps { isEmpty: boolean; isLoaded: boolean; } @@ -57,7 +58,7 @@ const SignUp: FC = ({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 = ({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));