Skip to content

Commit

Permalink
bug: fix add certification incorrect endpoint
Browse files Browse the repository at this point in the history
Change createExperience to createCertification endpoint in addcertificationmodal handle submit
  • Loading branch information
Ayobami6 committed Oct 20, 2023
1 parent 5d5b559 commit e8d43bb
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 340 deletions.
8 changes: 3 additions & 5 deletions client/src/actions/experience.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ export const getExperiencesTalent =

export const ExperienceUpdate = (id, ExperienceData) => async (dispatch) => {
try {
// dispatch({ type: 'START_LOADING' });
const { data } = await updateExperience(id, ExperienceData);
dispatch({ type: 'UPDATE_TALENT_EXPERIENCE', payload: data });
// dispatch({ type: 'END_LOADING' });
} catch (error) {
console.log(error.message);
console.log(error);
}
};

Expand All @@ -39,7 +37,7 @@ export const ExperienceDelete = (id) => async (dispatch) => {
dispatch({ type: 'DELETE_TALENT_EXPERIENCE', payload: id });
// setLoading(false);
} catch (error) {
console.log(error.message);
console.log(error);
}
};

Expand All @@ -51,6 +49,6 @@ export const ExperienceCreate =
dispatch({ type: 'CREATE_TALENT_EXPERIENCE', payload: data });
setLoading(false);
} catch (error) {
console.log(error.message);
console.log(error);
}
};
100 changes: 50 additions & 50 deletions client/src/components/Modal/AddCertificateModal.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
import { modalProps } from "./interfaces/modaInterface.ts";
import TButton from "../Button/TButton.tsx";
import "./styles/AddProjectModal.css";
import { useContext } from "react";
import { TalentContext } from "../../pages/Talent/Talent.tsx";
import { createExperience } from "../../api/experience.ts";
import { modalProps } from './interfaces/modaInterface.ts';
import TButton from '../Button/TButton.tsx';
import './styles/AddProjectModal.css';
import { useContext } from 'react';
import { TalentContext } from '../../pages/Talent/Talent.tsx';
import { createCertification } from '../../api/certifications.ts';

function AddCertificateModal({ show, setShow }: modalProps) {
const modalStyle = show ? "showModal" : "";
const tp = useContext(TalentContext);
const modalStyle = show ? 'showModal' : '';
const tp = useContext(TalentContext);

const { talentProfile } = localStorage;
const tal = talentProfile ? JSON.parse(talentProfile as string).talent : {};
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
formData.append("talentId", tal._id);
const data = Object.fromEntries(formData);
const { talentProfile } = localStorage;
const tal = talentProfile ? JSON.parse(talentProfile as string).talent : {};
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.target as HTMLFormElement);
formData.append('talentId', tal._id);
const data = Object.fromEntries(formData);

await createExperience(data);
tp.setRefresh(!tp.refresh);
const formElement = e.target as HTMLFormElement;
formElement.reset();
setShow(false);
};
await createCertification(data);
tp.setRefresh(!tp.refresh);
const formElement = e.target as HTMLFormElement;
formElement.reset();
setShow(false);
};

return (
<div className={"Modal " + modalStyle}>
<div className="content">
<div className={"header-11"}>
<h1>Add Certification Modal</h1>{" "}
<TButton value={"X"} onClick={() => setShow(false)} />
</div>
<hr />
<form onSubmit={handleSubmit}>
<div className="form-control">
<label htmlFor="title">Title</label>
<input type="text" name={"title"} />
</div>
<div className="form-control">
<label htmlFor="link">Link</label>
<input type="url" name={"link"} />
</div>
return (
<div className={'Modal ' + modalStyle}>
<div className='content'>
<div className={'header-11'}>
<h1>Add Certification Modal</h1>{' '}
<TButton value={'X'} onClick={() => setShow(false)} />
</div>
<hr />
<form onSubmit={handleSubmit}>
<div className='form-control'>
<label htmlFor='title'>Title</label>
<input type='text' name={'title'} />
</div>
<div className='form-control'>
<label htmlFor='link'>Link</label>
<input type='url' name={'link'} />
</div>

<div className="form-control">
<label htmlFor={"description"}>Description</label>
<textarea name={"description"} />
</div>
{/* add a save button */}
<div className="form-control">
<TButton value={"Save"} type={"submit"} />
</div>
</form>
</div>
</div>
);
<div className='form-control'>
<label htmlFor={'description'}>Description</label>
<textarea name={'description'} />
</div>
{/* add a save button */}
<div className='form-control'>
<TButton value={'Save'} type={'submit'} />
</div>
</form>
</div>
</div>
);
}

export default AddCertificateModal;
142 changes: 88 additions & 54 deletions client/src/components/TalentDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,112 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { getExperiencesTalent } from '../actions/experience';
import { useDispatch, useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
import Showwcase from '../components/talentProfile/Showwcase.tsx';
import {
CertificationShowwcaseCard,

Check failure on line 7 in client/src/components/TalentDetails.tsx

View workflow job for this annotation

GitHub Actions / lint

'CertificationShowwcaseCard' is defined but never used
EducationShowwcaseCard,

Check failure on line 8 in client/src/components/TalentDetails.tsx

View workflow job for this annotation

GitHub Actions / lint

'EducationShowwcaseCard' is defined but never used
ExperienceShowwcaseCard,
ProjectShowwcaseCard,

Check failure on line 10 in client/src/components/TalentDetails.tsx

View workflow job for this annotation

GitHub Actions / lint

'ProjectShowwcaseCard' is defined but never used
SkillShowwcaseCard,

Check failure on line 11 in client/src/components/TalentDetails.tsx

View workflow job for this annotation

GitHub Actions / lint

'SkillShowwcaseCard' is defined but never used
} from '../components/talentProfile/ShowwcaseCard.tsx';

const TalentDetails = ({ talent }) => {
const { id } = useParams();
const dispatch = useDispatch();
const [loading, setLoading] = useState();
const experiences = useSelector((state) => state.talentData.experiences);

useEffect(() => {
dispatch(getExperiencesTalent(id, setLoading));
}, []);

Check warning on line 22 in client/src/components/TalentDetails.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has missing dependencies: 'dispatch' and 'id'. Either include them or remove the dependency array

console.log(experiences);

return (
<>
<div className='m-10 mx-[100px]'>
<div>
<div className='md:flex flex-row'>
<div className='w-[170px] h-[170px] border-gray rounded-full flex justify-center'>
<img
src={
!talent.profileImg
? '/assets/talents/no_image.png'
: talent.profileImg
}
alt={talent.name}
className='object-cover'
/>
{!loading && (
<div className='m-10 mx-[100px]'>
<div>
<div className='md:flex flex-row'>
<div className='w-[170px] h-[170px] border-gray rounded-full flex justify-center'>
<img
src={
!talent.profileImg
? '/assets/talents/no_image.png'
: talent.profileImg
}
alt={talent.name}
className='object-cover'
/>
</div>
<div className='md:basis-1/2 my-20 mx-5 '>
<h1 className='text-3xl font-bold'>
{talent.name}
</h1>
<h2>Id: {talent._id}</h2>
</div>
</div>
<div className='md:basis-1/2 my-20 mx-5 '>
<h1 className='text-3xl font-bold'>
{talent.name}
</h1>
<h2>Id: {talent._id}</h2>
<div className='mx-5'>
<p className='text-gray-400'>Socials</p>
<p>Bio</p>
</div>
</div>
<div className='mx-5'>
<p className='text-gray-400'>Socials</p>
<p>Bio</p>
</div>
</div>

<hr className='my-5' />
<div>
<h2 className='text-3xl font-semibold'>Experience</h2>
<div className='my-5'>
<h3>All Experience</h3>
<hr className='my-5' />
<div>
<h2 className='text-3xl font-semibold'>Experience</h2>
<div className='my-5'>
<Showwcase>
{experiences.map((exp) => (
<ExperienceShowwcaseCard
experience={exp}
key={exp?._id}
showEdit={false}
/>
))}
</Showwcase>
</div>
</div>
</div>

<hr className='my-5' />
<hr className='my-5' />

<div>
<h2 className='text-3xl font-semibold'>Education</h2>
<div className='my-5'>
<h3>All Education</h3>
<div>
<h2 className='text-3xl font-semibold'>Education</h2>
<div className='my-5'>
<h3>All Education</h3>
</div>
</div>
</div>

<hr className='my-5' />
<hr className='my-5' />

<div>
<h2 className='text-3xl font-semibold'>Project</h2>
<div className='my-5'>
<h3>All Projects</h3>
<div>
<h2 className='text-3xl font-semibold'>Project</h2>
<div className='my-5'>
<h3>All Projects</h3>
</div>
</div>
</div>

<hr className='my-5' />
<hr className='my-5' />

<div>
<h2 className='text-3xl font-semibold'>Skills</h2>
<div className='my-5'>
<h3>All Skills</h3>
<div>
<h2 className='text-3xl font-semibold'>Skills</h2>
<div className='my-5'>
<h3>All Skills</h3>
</div>
</div>
</div>
<hr className='my-5' />
<hr className='my-5' />

<div>
<h2 className='text-3xl font-semibold'>Certification</h2>
<div className='my-5'>
<h3>All Certifications</h3>
<div>
<h2 className='text-3xl font-semibold'>
Certification
</h2>
<div className='my-5'>
<h3>All Certifications</h3>
</div>
</div>
</div>
</div>
)}
</>
);
};
Expand Down
Loading

0 comments on commit e8d43bb

Please sign in to comment.