mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-06 02:36:39 +00:00
add Dev class, IDev interface, remove blankDev and getDescription method
This commit is contained in:
parent
bdcee6d6f9
commit
fa353664fb
2 changed files with 59 additions and 28 deletions
|
|
@ -5,7 +5,7 @@ import Repo from '../types/Repo';
|
|||
|
||||
/** Shorter dev interface */
|
||||
export interface DevSummary {
|
||||
id: string;
|
||||
id?: string;
|
||||
displayName: string;
|
||||
avatarUrl: string;
|
||||
description: string;
|
||||
|
|
@ -16,7 +16,7 @@ export interface DevSummary {
|
|||
/** Full developer profile information.
|
||||
* @extends DevSummary to avoid duplication
|
||||
*/
|
||||
interface Dev extends DevSummary {
|
||||
interface IDev extends DevSummary {
|
||||
isActive: boolean;
|
||||
bio: string;
|
||||
status: string;
|
||||
|
|
@ -27,23 +27,25 @@ interface Dev extends DevSummary {
|
|||
repos: Repo[];
|
||||
}
|
||||
|
||||
/** create profile tagline */
|
||||
export const getDescription = (status: string, company: string) =>
|
||||
`${status} at ${company}`;
|
||||
|
||||
/** blank Dev serve as placeholder when initializing a new profile
|
||||
/** class implementing IDev.
|
||||
* No constructor is provided.
|
||||
* new Dev() returns a placeholder used when initializing a new profile.
|
||||
* id is not specified to not overwrite document uid.
|
||||
*/
|
||||
export const blankDev = {
|
||||
isActive: true,
|
||||
displayName: '',
|
||||
status: 'Developer',
|
||||
company: '',
|
||||
avatarUrl: '',
|
||||
description: '',
|
||||
location: '',
|
||||
skills: [],
|
||||
links: {
|
||||
export class Dev implements IDev {
|
||||
id?: string;
|
||||
isActive = true;
|
||||
displayName = '';
|
||||
status = 'Developer';
|
||||
company = '';
|
||||
avatarUrl = '';
|
||||
/** create profile tagline */
|
||||
get description(): string {
|
||||
return `${this.status} at ${this.company}`;
|
||||
}
|
||||
location = '';
|
||||
skills: string[] = [];
|
||||
links: Links = {
|
||||
website: '',
|
||||
instagram: '',
|
||||
facebook: '',
|
||||
|
|
@ -51,17 +53,46 @@ export const blankDev = {
|
|||
twitter: '',
|
||||
github: '',
|
||||
youtube: '',
|
||||
},
|
||||
bio: '',
|
||||
experiences: [],
|
||||
educations: [],
|
||||
repos: [],
|
||||
};
|
||||
};
|
||||
bio = '';
|
||||
experiences: Experience[] = [];
|
||||
educations: Education[] = [];
|
||||
repos: Repo[] = [];
|
||||
}
|
||||
//
|
||||
// export const getDescription = (status: string, company: string) =>
|
||||
// `${status} at ${company}`;
|
||||
|
||||
/**
|
||||
*/
|
||||
// export const blankDev = {
|
||||
// isActive: true,
|
||||
// displayName: '',
|
||||
// status: 'Developer',
|
||||
// company: '',
|
||||
// avatarUrl: '',
|
||||
// description: '',
|
||||
// location: '',
|
||||
// skills: [],
|
||||
// links: {
|
||||
// website: '',
|
||||
// instagram: '',
|
||||
// facebook: '',
|
||||
// linkedin: '',
|
||||
// twitter: '',
|
||||
// github: '',
|
||||
// youtube: '',
|
||||
// },
|
||||
// bio: '',
|
||||
// experiences: [],
|
||||
// educations: [],
|
||||
// repos: [],
|
||||
// };
|
||||
|
||||
/**
|
||||
* sample Dev for development and tests
|
||||
*/
|
||||
export const dummyDev: Dev = {
|
||||
export const dummyDev: IDev = {
|
||||
id: '0',
|
||||
isActive: true,
|
||||
displayName: 'John Doe',
|
||||
|
|
@ -170,4 +201,4 @@ export const developers: DevSummary[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export default Dev;
|
||||
export default IDev;
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import Alert from '../components/Alert';
|
|||
import Header from '../components/Header';
|
||||
// Form
|
||||
import useForm from '../hooks';
|
||||
import Dev, {blankDev} from '../models/Dev';
|
||||
import {Dev} from '../models/Dev';
|
||||
|
||||
// extends withFirebaseProps type to ad profile info
|
||||
interface IProps extends Dev, WithFirebaseProps<User> {
|
||||
|
|
@ -57,7 +57,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
|
|||
firebase
|
||||
.createUser({email, password}, newUser(name, email))
|
||||
.then(() => {
|
||||
firebase.updateProfile(blankDev, {useSet: true, merge: true});
|
||||
firebase.updateProfile(new Dev(), {useSet: true, merge: true});
|
||||
resetForm();
|
||||
})
|
||||
.catch(err => setError(err));
|
||||
|
|
@ -82,7 +82,7 @@ const SignUp: FC<IProps> = ({firebase, isEmpty, isLoaded, isActive}) => {
|
|||
)
|
||||
.then(() => {
|
||||
if (!exists)
|
||||
firebase.updateProfile(blankDev, {useSet: true, merge: true});
|
||||
firebase.updateProfile(new Dev(), {useSet: true, merge: true});
|
||||
});
|
||||
})
|
||||
.catch(err => setError(err));
|
||||
|
|
|
|||
Loading…
Reference in a new issue