Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apis/certification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const postCertification = async ({ image, certificationSource, recycleGui
formData.append('image', image);
formData.append('certificationSource', certificationSource);

if (recycleGuideId !== null) {
if (recycleGuideId !== null && recycleGuideId !== undefined) {
formData.append('recycleGuideId', recycleGuideId.toString());
}

Expand Down
67 changes: 34 additions & 33 deletions src/pages/cameara-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ export default function CamearaPage() {
try {
const file = await base64ToFile(img);

// 신규 인증
if (from === 'certification') {
const data = await postCertification({ image: file, certificationSource, recycleGuideId: guideId });

// 신규 인증 성공
// 재인증
if (certificationId) {
const data = await postCertificationRetry(certificationId, file);
// 재인증 성공
if (data.result?.status === 'PASSED') {
navigate('/certification/success', {
state: {
Expand All @@ -49,7 +48,7 @@ export default function CamearaPage() {
},
});
}
// 신규 인증 실패
// 재인증 실패
else if (data.result?.status === 'FAILED') {
// AI 판정 실패
if (data.result.failureType === 'VLM_JUDGEMENT_FAILED') {
Expand All @@ -60,12 +59,10 @@ export default function CamearaPage() {
retryGuide: data.result.retryGuide,
retryAllowed: data.result.retryAllowed,
certificationId: data.result.certificationId,
certificationSource,
guideId,
},
});
}
// 동일 품목 인증 시도
// 동일 품목 재인증 시도
else if (data.result.failureType === 'DUPLICATE_GUIDE_TODAY') {
navigate('/certification/fail', {
state: {
Expand All @@ -74,34 +71,17 @@ export default function CamearaPage() {
retryGuide: data.result.retryGuide,
retryAllowed: data.result.retryAllowed,
certificationId: data.result.certificationId,
certificationSource,
guideId,
},
});
}
}
}
// 배출 정보 검색
else if (from === 'info') {
const data = await postGuideImageSearch(file);

// 검색 성공
if (data.result?.identified) {
navigate('/disposal-info/detail', {
state: {
guide: data.result?.guideDetail,
},
});
}
// 검색 실패
else {
navigate('/disposal-info/fail');
}
}
// 재인증
else if (certificationId) {
const data = await postCertificationRetry(certificationId, file);
// 재인증 성공
// 신규 인증
else if (from === 'certification') {
const data = await postCertification({ image: file, certificationSource, recycleGuideId: guideId });

// 신규 인증 성공
if (data.result?.status === 'PASSED') {
navigate('/certification/success', {
state: {
Expand All @@ -111,7 +91,7 @@ export default function CamearaPage() {
},
});
}
// 재인증 실패
// 신규 인증 실패
else if (data.result?.status === 'FAILED') {
// AI 판정 실패
if (data.result.failureType === 'VLM_JUDGEMENT_FAILED') {
Expand All @@ -122,10 +102,12 @@ export default function CamearaPage() {
retryGuide: data.result.retryGuide,
retryAllowed: data.result.retryAllowed,
certificationId: data.result.certificationId,
certificationSource,
guideId,
},
});
}
// 동일 품목 재인증 시도
// 동일 품목 인증 시도
else if (data.result.failureType === 'DUPLICATE_GUIDE_TODAY') {
navigate('/certification/fail', {
state: {
Expand All @@ -134,11 +116,30 @@ export default function CamearaPage() {
retryGuide: data.result.retryGuide,
retryAllowed: data.result.retryAllowed,
certificationId: data.result.certificationId,
certificationSource,
guideId,
},
});
}
}
}
// 배출 정보 검색
else if (from === 'info') {
const data = await postGuideImageSearch(file);

// 검색 성공
if (data.result?.identified) {
navigate('/disposal-info/detail', {
state: {
guide: data.result?.guideDetail,
},
});
}
// 검색 실패
else {
navigate('/disposal-info/fail');
}
}
} catch (e) {
alert('접속이 원활하지 않습니다. 잠시 후 다시 시도해 주세요.');
console.error('camera error', e);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/certification-page/fail-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function FailPage() {
if (failureType === 'VLM_JUDGEMENT_FAILED' && retryAllowed && certificationId) {
navigate('/camera', {
state: {
from: 'certification',
certificationId,
},
});
Expand All @@ -32,7 +33,6 @@ export default function FailPage() {
from: 'certification',
certificationSource,
guideId,
// certificationId
},
});
} else {
Expand Down
Loading