From 9f9af3ec2a9365c884cbf82ed6201708085dba6c Mon Sep 17 00:00:00 2001 From: Ayobami Date: Wed, 25 Oct 2023 03:00:12 +0100 Subject: [PATCH] fix: fix cancel offer bug using employer id instead of talent id --- client/index.html | 4 +- client/package-lock.json | 52 ++++- client/package.json | 1 + client/src/components/Navbar/TalentNav.tsx | 17 +- client/src/components/TalentCard.tsx | 139 ++++++------ client/src/pages/Employer/Employer.tsx | 2 +- client/src/pages/Employer/EmployerOffer.tsx | 7 +- client/src/pages/Talent/TalentHire.tsx | 165 +++++++------- client/src/pages/Talent/TalentOfferCard.tsx | 163 +++++++------- client/tailwind.config.js | 12 +- server/controllers/talentController.ts | 233 ++++++++++---------- 11 files changed, 412 insertions(+), 383 deletions(-) diff --git a/client/index.html b/client/index.html index 00f7415..66edfdd 100644 --- a/client/index.html +++ b/client/index.html @@ -1,9 +1,9 @@ - + = 8" } }, + "node_modules/css-selector-tokenizer": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/css-selector-tokenizer/-/css-selector-tokenizer-0.8.0.tgz", + "integrity": "sha512-Jd6Ig3/pe62/qe5SBPTN8h8LeUg/pT4lLgtavPf7updwwHpvFzxvOQBHYj2LZDMjUnBzgvIUSjRcf6oT5HzHFg==", + "dev": true, + "dependencies": { + "cssesc": "^3.0.0", + "fastparse": "^1.1.2" + } + }, "node_modules/cssesc": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz", @@ -1725,6 +1742,26 @@ "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz", "integrity": "sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ==" }, + "node_modules/daisyui": { + "version": "3.9.3", + "resolved": "https://registry.npmjs.org/daisyui/-/daisyui-3.9.3.tgz", + "integrity": "sha512-8li177QCu6dqlEOzE3h/dAV1y9Movbjx5bzJIO/hNqMNZtJkbHM0trjTzbDejV7N57eNGdjBvAGtxZYKzS4jow==", + "dev": true, + "dependencies": { + "colord": "^2.9", + "css-selector-tokenizer": "^0.8", + "postcss": "^8", + "postcss-js": "^4", + "tailwindcss": "^3.1" + }, + "engines": { + "node": ">=16.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/daisyui" + } + }, "node_modules/date-fns": { "version": "2.30.0", "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", @@ -2173,6 +2210,12 @@ "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", "dev": true }, + "node_modules/fastparse": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz", + "integrity": "sha512-483XLLxTVIwWK3QTrMGRqUfUpoOs/0hbQrl2oz4J0pAcm3A3bu84wxTFqGqkJzewCLdME38xJLJAxBABfQT8sQ==", + "dev": true + }, "node_modules/fastq": { "version": "1.15.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", @@ -2417,7 +2460,6 @@ "react-is": "^16.7.0" } }, - "node_modules/hoist-non-react-statics/node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", @@ -3169,7 +3211,11 @@ "react-is": "^16.13.1" } }, - + "node_modules/prop-types/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + }, "node_modules/proxy-from-env": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", @@ -3258,7 +3304,6 @@ } }, "node_modules/react-is": { - "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" @@ -3328,7 +3373,6 @@ } } }, - "node_modules/react-refresh": { "version": "0.14.0", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", diff --git a/client/package.json b/client/package.json index 20032b9..258dc68 100644 --- a/client/package.json +++ b/client/package.json @@ -31,6 +31,7 @@ "@typescript-eslint/parser": "^6.0.0", "@vitejs/plugin-react": "^4.0.3", "autoprefixer": "^10.4.16", + "daisyui": "^3.9.3", "eslint": "^8.45.0", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.3", diff --git a/client/src/components/Navbar/TalentNav.tsx b/client/src/components/Navbar/TalentNav.tsx index 5ddad42..18edf94 100644 --- a/client/src/components/Navbar/TalentNav.tsx +++ b/client/src/components/Navbar/TalentNav.tsx @@ -37,21 +37,15 @@ function TalentNav(): JSX.Element { return (
- +
- + fine girl setOpenProfile((prev) => !prev)} />

{user.data ? user.data.name : user.talent.name}

- {openProfile && }
diff --git a/client/src/components/TalentCard.tsx b/client/src/components/TalentCard.tsx index c12c6a8..232fc98 100644 --- a/client/src/components/TalentCard.tsx +++ b/client/src/components/TalentCard.tsx @@ -4,84 +4,83 @@ import { AiFillGithub } from 'react-icons/ai'; import { BsLinkedin } from 'react-icons/bs'; interface TalentProps { - name: string; - jobRole: string; - bio: string; - location: string; - github: string; - profileImg: string; - id: string; - rank: number; + name: string; + jobRole: string; + bio: string; + location: string; + github: string; + profileImg: string; + id: string; + rank: number; } const TalentCard: React.FC = ({ - name, - jobRole, - location, - bio, - github, - profileImg, - id, - rank, + name, + jobRole, + location, + bio, + github, + profileImg, + id, + rank, }) => { - return ( -
-
- {name} -

- Percentile -
- {rank}% -

- {/*
+ return ( +
+
+
+ {name} +
+ +

+ Percentile +
+ {rank}% +

+ {/*

{rank}

*/} -
+
-
-

{name}

-

{jobRole}

-

{location}

-

{bio}

- -
-
- - - - - - -
+
+

{name}

+

{jobRole}

+

{location}

+

{bio}

+ - ); +
+
+ + + + + + +
+
+ ); }; export default TalentCard; diff --git a/client/src/pages/Employer/Employer.tsx b/client/src/pages/Employer/Employer.tsx index 3caf90b..48f9ee5 100644 --- a/client/src/pages/Employer/Employer.tsx +++ b/client/src/pages/Employer/Employer.tsx @@ -28,7 +28,7 @@ const Employer = () => { <> -
+
diff --git a/client/src/pages/Employer/EmployerOffer.tsx b/client/src/pages/Employer/EmployerOffer.tsx index 5841baf..ce0cc8b 100644 --- a/client/src/pages/Employer/EmployerOffer.tsx +++ b/client/src/pages/Employer/EmployerOffer.tsx @@ -25,7 +25,6 @@ const EmployerOffer = () => { useEffect(() => { dispatch(getOffersEmployer(id, setLoading)); }, [id, dispatch]); - console.log(offers); return ( <> @@ -40,11 +39,7 @@ const EmployerOffer = () => { ) : ( offers.map((offer) => ( - + )) )} diff --git a/client/src/pages/Talent/TalentHire.tsx b/client/src/pages/Talent/TalentHire.tsx index ee55e8d..ce5129b 100644 --- a/client/src/pages/Talent/TalentHire.tsx +++ b/client/src/pages/Talent/TalentHire.tsx @@ -10,100 +10,95 @@ import { getTalent } from '../../actions/talent'; import TalentDetails from '../../components/TalentDetails'; interface ProfileData { - _id: string; - name: string; + _id: string; + name: string; } const TalentHire = () => { - const { id } = useParams(); - const dispatch = useDispatch(); - const [title, setTitle] = useState(''); - const [description, setDescription] = useState(''); - const [loading, setLoading] = useState(false); - type profile = null | { data: ProfileData }; - const employerProfileString = localStorage.getItem('employerProfile'); - const employer: profile = employerProfileString - ? JSON.parse(employerProfileString) - : null; + const { id } = useParams(); + const dispatch = useDispatch(); + const [title, setTitle] = useState(''); + const [description, setDescription] = useState(''); + const [loading, setLoading] = useState(false); + type profile = null | { data: ProfileData }; + const employerProfileString = localStorage.getItem('employerProfile'); + const employer: profile = employerProfileString + ? JSON.parse(employerProfileString) + : null; - const [employerId, setEmployerId] = useState(employer?.data._id); - const talentUser = useSelector((state) => state.talents.talent); + const [employerId, setEmployerId] = useState(employer?.data._id); + const talentUser = useSelector((state) => state.talents.talent); - useEffect(() => { - dispatch(getTalent(setLoading, id)); - }, [dispatch, id]); + useEffect(() => { + dispatch(getTalent(setLoading, id)); + }, [dispatch, id]); - const handleSendOffer = () => { - const offerData = { - talentId: id, - employerId, - title, - description, - }; - dispatch(offerCreate(offerData, setLoading)); + const handleSendOffer = () => { + const offerData = { + talentId: id, + employerId, + title, + description, }; - console.log(talentUser); - return ( - <> - - {talentUser && ( -
- -
-
-
-

- Send Offer -

+ dispatch(offerCreate(offerData, setLoading)); + }; + return ( + <> + + {talentUser && ( +
+ +
+
+
+

+ Send Offer +

-
- - setTitle(e.target.value) - } - /> - - setDescription(e.target.value) - } - /> -
- {loading ? ( -
- ) : ( - '' - )} -
-
- {talentUser.hasOffer ? ( - - ) : ( - - )} -
-
-
-
-
+
+ setTitle(e.target.value)} + /> +