Skip to content

Commit

Permalink
Merge pull request #220 from Meetfolio-Project-CodeZ-Team/develop
Browse files Browse the repository at this point in the history
merge to main
  • Loading branch information
NAKDO authored May 28, 2024
2 parents 03635a2 + 86963aa commit f765062
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/app/(route)/mypage/myCovletDetail/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ const MyCovletDetailPage = ({ params }: { params: { id: string } }) => {
<UserNavContainer
isGuest={isGuest || ''}
selected={'portfolio'}
nickname={writerName||userInfo?.memberName}
profile={profile||userInfo?.profile}
nickname={
writerName === 'undefined' ? userInfo?.memberName : writerName || ''
}
profile={profile === 'undefined' ? userInfo?.profile : profile || ''}
/>
<div className="flex-grow">
<MyCovletCardDetail
Expand Down
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 f765062

Please sign in to comment.