From 0b13e204036dfdbcbf13857b34eb12548fda940b Mon Sep 17 00:00:00 2001 From: Owen <91054189+satanakorn@users.noreply.github.com> Date: Mon, 25 Nov 2024 23:36:28 +0700 Subject: [PATCH 1/2] update profile page skill --- frontend/src/profile.jsx | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/frontend/src/profile.jsx b/frontend/src/profile.jsx index 16df86e..630f118 100644 --- a/frontend/src/profile.jsx +++ b/frontend/src/profile.jsx @@ -150,8 +150,42 @@ EditProfileModal.propTypes = { const AddSkillModal = ({ isOpen, onClose, onSave }) => { const [skill, setSkill] = useState(''); - const handleSubmit = () => { - onSave(skill); + const handleSubmit = async () => { + try { + // Create the new skill + const createResponse = await Axios.post('http://localhost:3000/skill/create', { + skillName: skill, + }); + + const newSkill = createResponse.data; + + // Add the new skill to the user + const userID = localStorage.getItem('UserID'); + await Axios.post('http://localhost:3000/skill/add-to-user', { + userID, + skillName: newSkill.Skill_Name, + }); + + onSave(newSkill); + + Swal.fire({ + title: "Good job!", + text: "Skill Added Successfully!", + icon: "success" + }); + setTimeout(() => { + Swal.close(); + }, 3000); + + onClose(); + } catch (error) { + console.error('Error creating skill:', error); + Swal.fire({ + title: "Error", + text: "There was an error adding the skill.", + icon: "error" + }); + } }; if (!isOpen) return null; @@ -198,6 +232,7 @@ AddSkillModal.propTypes = { }; + // AddPersonalTypeModal component const AddPersonalTypeModal = ({ isOpen, onClose, onSave }) => { const [personalType, setPersonalType] = useState(''); From 8d0552712453379480ee9f2d33e1db8f2252e385 Mon Sep 17 00:00:00 2001 From: Thawanrat Rojamornrat Date: Wed, 27 Nov 2024 01:19:17 +0700 Subject: [PATCH 2/2] navbar and main --- frontend/src/components/Navbar.jsx | 1 - frontend/src/main.jsx | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index 7a1d623..92477f6 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -243,7 +243,6 @@ function Navbar() { โปรไฟล์ ->>>>>>>>> Temporary merge branch 2