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
10 changes: 8 additions & 2 deletions frontend/src/app/api/medical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,19 @@ export async function analyzeMedicalOcr(
return parseEnvelope<MedicalOcrResult>(res);
}

export async function uploadMedicalRecord(body: MedicalUploadBody): Promise<MedicalRecordApi> {
export async function uploadMedicalRecord(body: MedicalUploadBody): Promise<MedicalRecordApi | null> {
const petId = Number(getPetId());
const res = await safeFetch(`${API_BASE}/api/upload/medical`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...authHeaders() },
body: JSON.stringify({ ...body, petId }),
});
return parseEnvelope<MedicalRecordApi>(res);
if (!res.ok) return parseEnvelope<MedicalRecordApi>(res);
try {
return await parseEnvelope<MedicalRecordApi>(res);
} catch {
return null;
}
}

export async function getLatestMedicalSummary(): Promise<MedicalLatestSummary> {
Expand All @@ -174,3 +179,4 @@ export async function getLatestMedicalSummary(): Promise<MedicalLatestSummary> {
});
return parseEnvelope<MedicalLatestSummary>(res);
}

2 changes: 1 addition & 1 deletion frontend/src/app/components/ForgotPasswordScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { useNavigate } from 'react-router';
import MobileFrame from './MobileFrame';
import { ChevronLeft, Mail, CheckCircle2, ArrowRight, RefreshCw } from 'lucide-react';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

type Phase = 'input' | 'sent';

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/components/HealthLogScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const symptomChips = [
{ id: 'itch', label: '가려움', emoji: '🐾' },
{ id: 'appetite', label: '식욕부진', emoji: '🍽️' },
{ id: 'lethargy', label: '기력저하', emoji: '😴' },
{ id: 'limp', label: '跛行', emoji: '🦵' },
{ id: 'limp', label: '파행', emoji: '🦵' },
{ id: 'eye', label: '눈 분비물', emoji: '👁️' },
{ id: 'ear', label: '귀 긁음', emoji: '👂' },
];
Expand Down Expand Up @@ -601,3 +601,4 @@ export default function HealthLogScreen() {
</MobileFrame>
);
}

2 changes: 1 addition & 1 deletion frontend/src/app/components/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useNavigate } from 'react-router';
import { GoogleLogin, type CredentialResponse } from '@react-oauth/google';
import MobileFrame from './MobileFrame';
import { Eye, EyeOff, ChevronLeft } from 'lucide-react';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

const GOOGLE_CLIENT_ID = import.meta.env.VITE_GOOGLE_CLIENT_ID as string | undefined;

Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/components/MedicalRecordsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export default function MedicalRecordsScreen() {
<p style={{ fontSize: '11px', color: '#6A9FD4' }}>처방 내역이 없어요</p>
)}
</div>

</div>
</div>
)}
Expand Down
20 changes: 6 additions & 14 deletions frontend/src/app/components/MedicalUploadScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function MedicalUploadScreen() {
const [analyzeStep, setAnalyzeStep] = useState(0);
const [ocrData, setOcrData] = useState<OcrData>({ hospital: '', date: '', items: '', diagnosis: '', amount: '' });
const [showTypePicker, setShowTypePicker] = useState(false);
const [ocrImageUrls, setOcrImageUrls] = useState<string[]>([]);
const [ocrError, setOcrError] = useState<string | null>(null);
const [saving, setSaving] = useState(false);
const [saveError, setSaveError] = useState<string | null>(null);
Expand Down Expand Up @@ -80,13 +81,6 @@ export default function MedicalUploadScreen() {
});
};

const readAsDataUrl = (file: File): Promise<string> => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(String(reader.result ?? ''));
reader.onerror = () => reject(new Error('Failed to read file'));
reader.readAsDataURL(file);
});

const handleAnalyze = async () => {
setScreenState('analyzing');
setAnalyzeStep(0);
Expand All @@ -103,7 +97,8 @@ export default function MedicalUploadScreen() {

clearInterval(interval);

const { extracted } = result;
const { extracted, imageUrls } = result;
setOcrImageUrls(imageUrls ?? []);
setOcrData({
hospital: extracted.clinicName ?? '',
date: extracted.visitDate || selectedDate,
Expand All @@ -113,6 +108,7 @@ export default function MedicalUploadScreen() {
});
} catch (e) {
clearInterval(interval);
setOcrImageUrls([]);
setOcrData({ hospital: '', date: selectedDate, items: '', diagnosis: '', amount: '' });
setOcrError(e instanceof Error ? e.message : 'OCR 분석에 실패했습니다. 직접 입력해주세요.');
}
Expand All @@ -125,19 +121,14 @@ export default function MedicalUploadScreen() {
setSaving(true);
setSaveError(null);
try {
const base64List = await Promise.all(receiptFiles.map(readAsDataUrl));
const imageBase64 = base64List.map(b => {
const idx = b.indexOf(',');
return idx >= 0 ? b.substring(idx + 1) : b;
});
await uploadMedicalRecord({
type: TYPE_MAP[medType],
clinicName: ocrData.hospital,
visitDate: ocrData.date,
content: ocrData.items,
diagnosis: ocrData.diagnosis,
totalCost: ocrData.amount,
image: imageBase64,
image: ocrImageUrls,
});
navigate('/medical-records', { replace: true });
} catch (e) {
Expand Down Expand Up @@ -417,3 +408,4 @@ export default function MedicalUploadScreen() {
</MobileFrame>
);
}

2 changes: 1 addition & 1 deletion frontend/src/app/components/NavHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChevronLeft } from 'lucide-react';
import { useNavigate } from 'react-router';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

Check warning on line 3 in frontend/src/app/components/NavHeader.tsx

View workflow job for this annotation

GitHub Actions / Typecheck / Lint / Build

'lionLogo' is defined but never used. Allowed unused vars must match /^[A-Z_]/u

interface NavHeaderProps {
title: string;
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/PasswordResetScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { useNavigate } from 'react-router';
import MobileFrame from './MobileFrame';
import { Eye, EyeOff, CheckCircle2, ShieldCheck, ChevronLeft } from 'lucide-react';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

type Phase = 'form' | 'done';

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/Screen1Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { useNavigate } from 'react-router';
import MobileFrame from './MobileFrame';
import { getPets, PetApiError, PetNetworkError } from '../api/onboarding';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

export default function Screen1Welcome() {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/SignupMethodScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigate } from 'react-router';
import MobileFrame from './MobileFrame';
import { ChevronLeft, ChevronRight, Mail } from 'lucide-react';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

export default function SignupMethodScreen() {
const navigate = useNavigate();
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/components/SignupTermsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from 'react';
import { useNavigate, useSearchParams } from 'react-router';
import MobileFrame from './MobileFrame';
import { ChevronLeft, ChevronRight, CheckCircle2 } from 'lucide-react';
import lionLogo from 'figma:asset/3d187befbd5f5281436e6022002bcf4bb8f9a5bd.png';
import lionLogo from 'figma:asset/49bb8708313cd2aee9d6c816e878c53a7e094241.png';

interface Term {
id: string;
Expand Down
Loading