HumanPlusX / src /pages /upload.py
FajarHidaa's picture
Upload 3 files
ed5d5d7 verified
Raw History Blame Contribute Delete
3.93 kB
"""
Human+ β€” Page 1: Upload Lab PDF
Refactored: semua konten pakai Streamlit native.
"""
import streamlit as st
from ui.components import (
render_trust_badges,
render_section_label,
render_info_card,
render_highlight_quote,
render_error_state,
)
def render_upload_page():
render_trust_badges()
# ── Cara kerja ────────────────────────────────────────────────
render_section_label("CARA KERJA", "πŸ”„")
col1, col2, col3 = st.columns(3)
with col1:
st.markdown("**1 Β· πŸ“€ Upload PDF**")
st.caption("Hasil lab dari klinik manapun")
with col2:
st.markdown("**2 · 🧠 AI Analisis**")
st.caption("Gemini baca & identifikasi biomarker")
with col3:
st.markdown("**3 Β· πŸ’‰ Terima Protocol**")
st.caption("IV drip + suplemen hyperpersonal")
st.write("")
# ── Upload zone ───────────────────────────────────────────────
render_section_label("UPLOAD HASIL LAB", "πŸ“‹")
uploaded_file = st.file_uploader(
label="Upload PDF hasil lab (maks 10MB)",
type=["pdf"],
help="Format: PDF Β· Maksimal 10MB Β· Data tidak disimpan di server",
)
st.caption("πŸ”’ PDF Β· Maks 10MB Β· Semua data hanya diproses sementara")
# ── Validasi & lanjut ─────────────────────────────────────────
if uploaded_file is not None:
if uploaded_file.size > 10 * 1024 * 1024:
render_error_state(
title="File Terlalu Besar",
message="Maksimal ukuran file adalah 10MB. Silakan compress PDF terlebih dahulu.",
)
return
size_kb = uploaded_file.size / 1024
size_str = f"{size_kb:.1f} KB" if size_kb < 1024 else f"{size_kb/1024:.2f} MB"
# File preview β€” native columns
col_icon, col_info, col_ok = st.columns([1, 6, 1])
with col_icon:
st.write("πŸ“„")
with col_info:
st.markdown(f"**{uploaded_file.name}**")
st.caption(f"{size_str} Β· PDF siap dianalisis")
with col_ok:
st.write("βœ…")
# Simpan ke session state SEBELUM tombol ditekan
if st.session_state.uploaded_pdf_bytes is None:
st.session_state.uploaded_pdf_bytes = uploaded_file.read()
st.session_state.pdf_filename = uploaded_file.name
st.write("")
if st.button("πŸ”¬ Analisis Hasil Lab Saya", type="primary", use_container_width=True):
st.session_state.step = 2
st.rerun()
else:
st.caption("↑ Upload file PDF untuk memulai")
# ── Quote ─────────────────────────────────────────────────────
st.write("")
render_highlight_quote(
"Tubuh manusia luar biasa jika diberi apa yang dibutuhkannya. "
"Mulai dari data lab Anda, lalu ambil action."
)
# ── Biomarker list ────────────────────────────────────────────
render_section_label("BIOMARKER YANG DIANALISIS", "🧬")
render_info_card(
title="LONGEVITY MARKERS",
icon="🎯",
body=(
"hs-CRP Β· Homocysteine Β· Vitamin D Β· HbA1c Β· Testosterone Β· Magnesium Β· "
"Zinc Β· Vitamin B12 Β· Ferritin Β· ApoB Β· Triglycerides Β· HDL Β· "
"TSH Β· Cortisol Β· DHEA-S Β· Fasting Insulin Β· dan lainnya. "
"Semua dibandingkan dengan optimal longevity range Human+, "
"bukan sekadar range lab standar."
),
)