Spaces:
Running

baohanh / components /policy_section.py
thuvien's picture
Update components/policy_section.py
05b27d9 verified
Raw History Blame Contribute Delete
1.92 kB
# components/policy_section.py
import pandas as pd
import streamlit as st
from config.settings import STORAGE_ASSETS
from config.warranty_rules import WARRANTY_TERMS
from services.policy_service import fetch_active_policies
def render_policy_expander(supabase):
with st.expander("📄 Tóm tắt điều kiện bảo hành", expanded=False):
st.markdown("### ⏱️ Thời hạn bảo hành")
st.info("Bảo hành được tính theo thời gian hoặc định mức sử dụng **(tuỳ theo điều kiện nào đến trước)**")
pdf_url = STORAGE_ASSETS["policy_pdf_url"]
docx_url = STORAGE_ASSETS["policy_docx_url"]
col_btn1, col_btn2 = st.columns(2)
with col_btn1:
st.link_button("🚀 Xem chi tiết chính sách (PDF)", pdf_url, use_container_width=True)
with col_btn2:
st.link_button("⬇️ Tải file Word", docx_url, use_container_width=True)
if st.checkbox("📖 Xem nhanh trực tiếp trên trang", key="preview_policy_doc"):
viewer_url = f"https://docs.google.com/gview?url={pdf_url}&embedded=true"
st.components.v1.iframe(viewer_url, height=600, scrolling=True)
policy_rows = fetch_active_policies(supabase)
st.dataframe(pd.DataFrame(policy_rows), hide_index=True, use_container_width=True)
st.markdown("---")
col1, col2 = st.columns(2, gap="large")
with col1:
st.markdown("### ✅ Điều kiện được bảo hành")
st.success("\n".join(f"- {line}" for line in WARRANTY_TERMS["eligible"]))
with col2:
st.markdown("### ❌ Trường hợp từ chối bảo hành")
st.error("\n".join(f"- {line}" for line in WARRANTY_TERMS["rejected"]))
st.markdown("---")
st.markdown("### 📌 Lưu ý")
st.warning("\n".join(f"- {line}" for line in WARRANTY_TERMS["notes"]))