Skip to content

Commit

Permalink
Merge pull request #122 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 13, 2024
2 parents be775d6 + f4d7cf9 commit a5e8eea
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 95 deletions.
120 changes: 60 additions & 60 deletions src/app/components/coverletter/CovletSave.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,80 +101,77 @@ const CovletSave = () => {
}
}

// const saveCovData = async () => {
// const {
// answer,
// question,
// shareType,
// keyword1,
// keyword2,
// jobKeyword,
// coverLetterId,
// } = coverletterData
const saveCovData = async () => {
const {
answer,
question,
shareType,
keyword1,
keyword2,
jobKeyword,
coverLetterId,
} = coverletterData

// if (!coverLetterId) {
// console.error('coverLetterId가 없습니다.')
// return
// }
if (!coverLetterId) {
console.error('coverLetterId가 없습니다.')
return
}

// if (
// !answer ||
// !question ||
// !shareType ||
// !keyword1 ||
// !keyword2 ||
// !jobKeyword
// ) {
// console.error('모든 필드를 채워주세요.')
// return
// }
if (
!answer ||
!question ||
!shareType ||
!keyword1 ||
!keyword2 ||
!jobKeyword
) {
console.error('모든 필드를 채워주세요.')
return
}

// const response = await fetch(`/api/coverletters/save?id=${coverLetterId}`, {
// method: 'PATCH',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// answer,
// question,
// shareType,
// keyword1,
// keyword2,
// jobKeyword,
// }),
// })
const response = await fetch(`/api/coverletters/save?id=${coverLetterId}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
answer,
question,
shareType,
keyword1,
keyword2,
jobKeyword,
}),
})

// const resData = await response.json()
// setCoverLetterData({
// ...coverletterData,
// coverLetterId: resData.result.coverLetterId
// })
// if (!response.ok) {
// console.error('데이터 저장에 실패했습니다.')
// } else {
// // 성공적으로 데이터가 저장되었을 때 필요한 로직 추가 (예: 페이지 이동)
// console.log('데이터가 성공적으로 저장되었습니다.', resData)
// console.log('데이터가 성공적으로 저장되었습니다.', coverletterData)
// // AI 피드백 요청 함수 호출
// }
// }
const resData = await response.json()
setCoverLetterData({
...coverletterData,
coverLetterId: resData.result.coverLetterId
})
if (!response.ok) {
console.error('데이터 저장에 실패했습니다.')
} else {
// 성공적으로 데이터가 저장되었을 때 필요한 로직 추가 (예: 페이지 이동)
console.log('데이터가 성공적으로 저장되었습니다.', resData)
console.log('데이터가 성공적으로 저장되었습니다.', coverletterData)
requestAIFeedback();
// AI 피드백 요청 함수 호출
}
}

// AI 피드백 요청 함수
const requestAIFeedback = async () => {
const { keyword1, keyword2, jobKeyword,coverLetterId } = coverletterData;
console.log('자소서 데이터',coverletterData.keyword1)
console.log('자소서 데이터',coverletterData.keyword2)
console.log('자소서 데이터',coverletterData.jobKeyword)


const feedbackResponse = await fetch(`/api/coverletters/feedback?id=${coverLetterId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
keyword1,
keyword2,
job_keyword: jobKeyword,

}),
});
const feedbackData = await feedbackResponse.json();
Expand All @@ -187,6 +184,9 @@ const requestAIFeedback = async () => {
} else {
console.log('AI 피드백 요청이 성공적으로 처리되었습니다.',feedbackData);
console.log('자소서 아이디',coverLetterId)
console.log('자소서 데이터',coverletterData.keyword1)
console.log('자소서 데이터',coverletterData.keyword2)
console.log('자소서 데이터',coverletterData.jobKeyword)
router.push('/coverletter/feedback'); // 피드백 결과 페이지로 이동
}
};
Expand Down Expand Up @@ -408,7 +408,7 @@ const requestAIFeedback = async () => {
</div> */}
<button
className="text-white bg-stone-300 border-0 py-[18px] px-[360px] focus:outline-none hover:bg-gray-800 rounded-[30px] text-xl font-semibold"
onClick={requestAIFeedback}
onClick={saveCovData}
>
{feedbackClicked ? 'AI 피드백 결과 보러가기' : '자기소개서 작성 완료'}
</button>
Expand Down
52 changes: 17 additions & 35 deletions src/app/components/mypage/EditUserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const EditUserInfo = () => {
아이디
</div>
</div>
<div className="w-[700px] h-[90px] mt-[40px] relative">
<div className="w-[700px] h-[90px] mt-[20px] relative">
<div className="flex gap-x-[175px]">
<div className="w-auto text-xl font-semibold leading-[30px] pl-1.5">
변경할 비밀번호
Expand All @@ -239,25 +239,28 @@ const EditUserInfo = () => {
</div>
<div className="flex gap-x-3 items-center">
<Input
inputType={isOpen ? '' : 'password'}
type={'login'}
onChange={(e) => setPw(e.target.value)}
placeholder="현재 비밀번호"
inputType="password"
type={'password'}
onChange={(e) => setPassWord(e.target.value)}
placeholder={SIGNUP.Password}
textValue={password}
/>
<Input
inputType="password"
type={'password'}
onChange={(e) => setCheckPW(e.target.value)}
placeholder={SIGNUP.Password}
textValue={checkPW}
/>
<div
className="cursor-pointer absolute right-2"
onMouseDown={() => setIsOpen(true)}
onMouseUp={() => setIsOpen(false)}
className={`flex items-center justify-center w-[72px] p-2 text-lg font-semibold rounded-[10px] ${isSame ? 'bg-[#486283] text-white' : 'bg-white text-[#6D727C]'}`}
>
<Icons name={eye} />
{isSame ? '일치' : '불일치'}
</div>
</div>
</div>
<div className="w-[700px] h-[90px] relative z-20">
<div className="w-[138px] left-[6px] top-0 absolute text-gray-900 text-xl font-semibold leading-[30px]">
학과
</div>
<div className="w-[700px] h-[90px] relative mt-[20px] z-20">
<div className="w-[700px] h-[90px] relative z-20">
<div className="w-[138px] left-[6px] top-0 absolute text-gray-900 text-xl font-semibold leading-[30px]">
학과
</div>
Expand Down Expand Up @@ -302,28 +305,7 @@ const EditUserInfo = () => {
</div>
</div>
</div>
<div className="w-[700px] h-[90px] mt-[60px] relative z-10">
<div className="w-auto text-xl font-semibold leading-[30px] pl-1.5">
학년 및 학적
</div>
<DropDownOB
options={GRADE}
title={grade}
onSelect={(option) => setGrade(option)}
/>
</div>
<div className="w-[700px] h-[89px] relative z-0">
<div className="w-auto text-xl font-semibold leading-[30px] pl-1.5 pb-[10px]">
희망직무
</div>
<div className="flex gap-x-[35px]">
{JOBKEYWORD.map((str, index) => (
<div key={index} onClick={() => handleClick(str)}>
<Keyword keyword={str} clickKeyword={clickedKeyword} />
</div>
))}
</div>
</div>

</div>
<div className="w-[700px] h-[80px] left-[80px] top-[750px] absolute">
<Button
Expand Down
1 change: 1 addition & 0 deletions src/app/service/postReq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const postBoardDetail = async (accessToken: string, id: string) => {

export const postAiFeedback = async (accessToken: string, id: string) => {
const url = `${G_SERVER_URL}/api/coverLetter-feedbacks/${id}`
console.log()
return await postRequest(url, null, accessToken)
}

Expand Down

0 comments on commit a5e8eea

Please sign in to comment.