Skip to content

Commit 29d33b2

Browse files
feat: chatbot 클릭시 공고 상세보기로 이동
1 parent c78c813 commit 29d33b2

2 files changed

Lines changed: 58 additions & 36 deletions

File tree

‎app/dashboard/jobs/[id]/page.tsx‎

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,18 @@ export default function JobDetailPage() {
223223
useEffect(() => {
224224
const fetchScreenshot = async () => {
225225
const jobId = params.id as string
226-
if (!jobId) return
226+
if (!jobId) {
227+
console.log('스크린샷: jobId가 없습니다')
228+
return
229+
}
230+
231+
// job.screenShotUrl이 있으면 우선 사용
232+
if (job?.screenShotUrl) {
233+
console.log('스크린샷 URL (job에서):', job.screenShotUrl)
234+
setScreenshotUrl(job.screenShotUrl)
235+
setIsLoadingScreenshot(false)
236+
return
237+
}
227238

228239
try {
229240
setIsLoadingScreenshot(true)
@@ -236,18 +247,20 @@ export default function JobDetailPage() {
236247

237248
// API 프록시를 통해 스크린샷 가져오기
238249
const screenshotApiUrl = `/api/posts/${jobId}/screenshot?${queryParams.toString()}`
250+
console.log('스크린샷 URL (API에서):', screenshotApiUrl)
239251
setScreenshotUrl(screenshotApiUrl)
252+
setIsLoadingScreenshot(false)
240253
} catch (err) {
254+
console.error('스크린샷 URL 설정 오류:', err)
241255
const errorMessage = err instanceof Error ? err.message : '스크린샷을 불러오는 중 오류가 발생했습니다.'
242256
setScreenshotError(errorMessage)
243257
setScreenshotUrl(null)
244-
} finally {
245258
setIsLoadingScreenshot(false)
246259
}
247260
}
248261

249262
fetchScreenshot()
250-
}, [params.id])
263+
}, [params.id, job])
251264

252265
// 매칭된 직무 생성
253266
useEffect(() => {
@@ -474,16 +487,20 @@ export default function JobDetailPage() {
474487
<div className="text-center py-12">
475488
<p className="text-red-500 text-sm">{screenshotError}</p>
476489
</div>
477-
) : (screenshotUrl || job.screenShotUrl) ? (
490+
) : screenshotUrl ? (
478491
<div className="flex justify-center">
479492
<img
480-
src={screenshotUrl || job.screenShotUrl || ''}
481-
alt={`${job.title} 공고 스크린샷`}
493+
src={screenshotUrl}
494+
alt={`${job?.title || '공고'} 스크린샷`}
482495
className="max-w-full h-auto rounded-lg border border-gray-200 shadow-sm"
483496
onError={() => {
484497
setScreenshotError('스크린샷을 불러올 수 없습니다.')
485498
setScreenshotUrl(null)
486499
}}
500+
onLoad={() => {
501+
// 이미지 로드 성공 시 에러 상태 초기화
502+
setScreenshotError(null)
503+
}}
487504
/>
488505
</div>
489506
) : (

‎components/dashboard/AIChatbot.tsx‎

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useState, useRef, useEffect } from 'react'
44
import { useRouter, usePathname } from 'next/navigation'
5+
import Link from 'next/link'
56
import { Button } from '@/components/ui/button'
67
import { Input } from '@/components/ui/input'
78
import { Card } from '@/components/ui/card'
@@ -826,42 +827,46 @@ export default function AIChatbot() {
826827
관련 채용 공고 ({message.jobPostings.length}개)
827828
</div>
828829
{message.jobPostings.map((job) => (
829-
<Card
830+
<Link
830831
key={job.id}
831-
className="p-3 border border-gray-200"
832+
href={`/dashboard/jobs/${job.id}`}
833+
className="block"
832834
>
833-
<div className="flex items-start gap-3">
834-
<div className="flex-1 min-w-0">
835-
<div className="flex items-start justify-between gap-2 mb-1">
836-
<h4 className="font-semibold text-sm text-gray-900 line-clamp-1">
837-
{job.title || '제목 없음'}
838-
</h4>
839-
</div>
840-
{job.companyName && (
841-
<p className="text-xs text-gray-600 mb-1">
842-
{job.companyName}
843-
</p>
844-
)}
845-
<div className="flex flex-wrap gap-2 mt-2">
846-
{job.role && (
847-
<span className="text-xs px-2 py-0.5 bg-blue-100 text-blue-700 rounded">
848-
{job.role}
849-
</span>
835+
<Card className="p-3 border border-gray-200 hover:bg-gray-50 cursor-pointer transition-all hover:border-gray-300 hover:shadow-md">
836+
<div className="flex items-start gap-3">
837+
<div className="flex-1 min-w-0">
838+
<div className="flex items-start justify-between gap-2 mb-1">
839+
<h4 className="font-semibold text-sm text-gray-900 line-clamp-1">
840+
{job.title || '제목 없음'}
841+
</h4>
842+
<ExternalLink className="w-3 h-3 text-gray-400 flex-shrink-0" />
843+
</div>
844+
{job.companyName && (
845+
<p className="text-xs text-gray-600 mb-1">
846+
{job.companyName}
847+
</p>
850848
)}
851-
{job.experience && (
852-
<span className="text-xs px-2 py-0.5 bg-purple-100 text-purple-700 rounded">
853-
{job.experience}
854-
</span>
849+
<div className="flex flex-wrap gap-2 mt-2">
850+
{job.role && (
851+
<span className="text-xs px-2 py-0.5 bg-blue-100 text-blue-700 rounded">
852+
{job.role}
853+
</span>
854+
)}
855+
{job.experience && (
856+
<span className="text-xs px-2 py-0.5 bg-purple-100 text-purple-700 rounded">
857+
{job.experience}
858+
</span>
859+
)}
860+
</div>
861+
{job.postedAt && (
862+
<p className="text-xs text-gray-500 mt-2">
863+
등록일: {job.postedAt.year}.{String(job.postedAt.month).padStart(2, '0')}.{String(job.postedAt.day).padStart(2, '0')}
864+
</p>
855865
)}
856866
</div>
857-
{job.postedAt && (
858-
<p className="text-xs text-gray-500 mt-2">
859-
등록일: {job.postedAt.year}.{String(job.postedAt.month).padStart(2, '0')}.{String(job.postedAt.day).padStart(2, '0')}
860-
</p>
861-
)}
862867
</div>
863-
</div>
864-
</Card>
868+
</Card>
869+
</Link>
865870
))}
866871
</div>
867872
)}

0 commit comments

Comments
 (0)