Skip to content

Commit

Permalink
Merge pull request #219 from Meetfolio-Project-CodeZ-Team/fix/#219/경험…
Browse files Browse the repository at this point in the history
…카드달달력수정

Fix/#219/경험카드 달력 수정
  • Loading branch information
NAKDO authored May 28, 2024
2 parents b944801 + c89f33f commit 86963aa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
29 changes: 28 additions & 1 deletion src/app/components/coverletter/CovletMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,33 @@ const CovletMain = ({ isEdit, id }: CovletFinishContainerProps) => {
}
goToNextPage()
}
const updateCovData = async () => {
const { ...dataToSend } = coverletterData

const urlPath = isEdit
? `/api/coverletters/save?id=${id}`
: `/api/coverletters`
const methodType = isEdit ? 'PATCH' : 'POST'
const response = await fetch(urlPath, {
method: methodType,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
...dataToSend,
}),
})
const resData = await response.json()
setCoverLetterData({
...coverletterData,
coverLetterId: resData.result.coverLetterId,
})

if (!response.ok) {
console.error('데이터 저장에 실패했습니다.')
}
router.push('/mypage')
}

return (
<div className="w-[1440px] h-[1319px] relative">
Expand Down Expand Up @@ -340,7 +367,7 @@ const CovletMain = ({ isEdit, id }: CovletFinishContainerProps) => {
<div className="w-[870px] h-[60px] left-[59px] top-[750px] absolute">
<button
className="text-white bg-stone-300 border-0 py-[18px] px-[380px] focus:outline-none hover:bg-gray-800 rounded-[30px] text-xl font-semibold"
onClick={saveCovData}
onClick={isEdit? updateCovData : saveCovData}
type="button"
>
{isEdit ? '수정하기' : '저장하기'}
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/experience/ExpInfoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const ExpInfoContainer = ({ isEdit, id }: ExpFinishContainerProps) => {
<div className="w-[742px] h-[117px] left-[74px] top-[240px] absolute">
<div className="w-[737px] h-[78px] left-[5px] top-[39px] absolute">
<input
type="text"
type="date"
value={experienceData.startDate}
onChange={handleInputChange}
id="startDate"
Expand All @@ -123,7 +123,7 @@ const ExpInfoContainer = ({ isEdit, id }: ExpFinishContainerProps) => {
</div>
<div className="w-[290px] h-[55px] left-[452px] top-[39px] absolute">
<input
type="text"
type="date"
value={experienceData.endDate}
onChange={handleInputChange}
id="endDate"
Expand Down

0 comments on commit 86963aa

Please sign in to comment.