mirror of
https://github.com/rjNemo/devbook_ts
synced 2026-06-09 03:56:49 +00:00
refactor: add Dashboard Education section
This commit is contained in:
parent
276e4fdaa0
commit
bf32c9a4a6
3 changed files with 60 additions and 35 deletions
49
src/pages/Dashboard/EducationSection.tsx
Normal file
49
src/pages/Dashboard/EducationSection.tsx
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
import React, {FC} from 'react';
|
||||
// Typing
|
||||
import Education from '../../types/Education';
|
||||
|
||||
import {getTimePeriod} from '../../types/TimePeriod';
|
||||
|
||||
interface IProps {
|
||||
educations: Education[];
|
||||
handleDelete: (
|
||||
id: number,
|
||||
entries: Education[],
|
||||
) => (e: React.MouseEvent<HTMLButtonElement>) => void;
|
||||
}
|
||||
const DashboardEducationSection: FC<IProps> = ({educations, handleDelete}) => {
|
||||
return (
|
||||
<>
|
||||
<h2 className="my-2">Education Credentials</h2>
|
||||
<table className="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>School</th>
|
||||
<th className="hide-sm">Degree</th>
|
||||
<th className="hide-sm">Years</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{educations?.map((edu: Education, i: number) => (
|
||||
<tr key={edu.id}>
|
||||
<td>{edu.school}</td>
|
||||
<td className="hide-sm">{edu.degree}</td>
|
||||
<td className="hide-sm">{getTimePeriod(edu.from, edu.to)}</td>
|
||||
<td>
|
||||
<button
|
||||
className="btn btn-danger"
|
||||
onClick={handleDelete(edu.id, educations)}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default DashboardEducationSection;
|
||||
|
|
@ -27,7 +27,7 @@ const DashboardExperienceSection: FC<IProps> = ({
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{experiences.map((exp: Experience) => (
|
||||
{experiences?.map((exp: Experience) => (
|
||||
<tr key={exp.id}>
|
||||
<td>{exp.company}</td>
|
||||
<td className="hide-sm">{exp.position}</td>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import Experience from '../../types/Experience';
|
|||
import {getTimePeriod} from '../../types/TimePeriod';
|
||||
import Education from '../../types/Education';
|
||||
import DashboardExperienceSection from './ExperienceSection';
|
||||
import DashboardEducationSection from './EducationSection';
|
||||
|
||||
interface IProps extends Dev, WithFirebaseProps<User> {}
|
||||
/**
|
||||
|
|
@ -62,41 +63,16 @@ const Dashboard: FC<IProps> = ({
|
|||
<Header title="Dashboard" lead={`Welcome ${displayName}`} />
|
||||
<DashBoardButtons />
|
||||
|
||||
{!!experiences && (
|
||||
<DashboardExperienceSection
|
||||
experiences={experiences}
|
||||
handleDelete={deleteExpEntry}
|
||||
/>
|
||||
)}
|
||||
<DashboardExperienceSection
|
||||
experiences={experiences}
|
||||
handleDelete={deleteExpEntry}
|
||||
/>
|
||||
|
||||
<DashboardEducationSection
|
||||
educations={educations}
|
||||
handleDelete={deleteEduEntry}
|
||||
/>
|
||||
|
||||
<h2 className="my-2">Education Credentials</h2>
|
||||
<table className="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>School</th>
|
||||
<th className="hide-sm">Degree</th>
|
||||
<th className="hide-sm">Years</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{educations?.map((edu: Education, i: number) => (
|
||||
<tr key={edu.id}>
|
||||
<td>{edu.school}</td>
|
||||
<td className="hide-sm">{edu.degree}</td>
|
||||
<td className="hide-sm">{getTimePeriod(edu.from, edu.to)}</td>
|
||||
<td>
|
||||
<button
|
||||
className="btn btn-danger"
|
||||
onClick={deleteEduEntry(edu.id, educations)}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
<div className="my-2">
|
||||
<button className="btn btn-danger" onClick={deleteAccount}>
|
||||
<FontAwesomeIcon icon={faUserSlash} /> Delete my Account
|
||||
|
|
|
|||
Loading…
Reference in a new issue