Files

60 lines
2.4 KiB
Python

from __future__ import annotations
import sys
from pathlib import Path
import streamlit as st
# Streamlit executes this file as a script, so ensure absolute dashboard imports
# resolve identically to package imports used by tests.
if __package__ in (None, ""):
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
st.set_page_config(page_title="Jarca Ledger", page_icon="💰", layout="wide")
from dashboard.common import clear_cache, get_db_path, get_transfer_review_items, inject_app_css, render_sidebar_nav # noqa: F401
from dashboard.page_views.accounts import page_accounts
from dashboard.page_views.assets import page_assets
from dashboard.page_views.categories import page_categories
from dashboard.page_views.cross_transfer_review import page_cross_transfer_review
from dashboard.page_views.imports import page_imports
from dashboard.page_views.monthly_settlement import page_monthly_settlement
from dashboard.page_views.overview import page_overview
from dashboard.page_views.rules import page_rules
from dashboard.page_views.transactions import page_transactions
from dashboard.page_views.uncategorized import page_uncategorized
def main() -> None:
db_path = get_db_path()
inject_app_css()
pages = ["월정산", "요약", "자산/마감", "거래내역", "확인필요 큐", "미분류", "분류 규칙", "카테고리", "계좌", "Import"]
query_page = st.query_params.get("page", "요약")
page = query_page if query_page in pages else "요약"
st.session_state["page"] = page
with st.sidebar:
st.markdown("## 💰 Jarca Ledger")
st.caption("가계부 · 분류 · Import 운영 콘솔")
st.markdown('<div class="jarca-nav-title">메뉴</div>', unsafe_allow_html=True)
render_sidebar_nav(pages, page)
if st.button("새로고침", key="refresh_button", use_container_width=True):
clear_cache()
st.rerun()
dispatch = {
"월정산": page_monthly_settlement,
"요약": page_overview,
"자산/마감": page_assets,
"거래내역": page_transactions,
"확인필요 큐": page_cross_transfer_review,
"미분류": page_uncategorized,
"분류 규칙": page_rules,
"카테고리": page_categories,
"계좌": page_accounts,
"Import": page_imports,
}
dispatch[page](db_path)
if __name__ == "__main__":
main()