updates
This commit is contained in:
Binary file not shown.
@@ -1435,6 +1435,10 @@ class UpdateCompanySettingsRequest(BaseModel):
|
||||
tax_rate: Optional[float] = None
|
||||
chat_working_hours_start: Optional[int] = None
|
||||
chat_working_hours_end: Optional[int] = None
|
||||
bank_name: Optional[str] = None
|
||||
bank_account_number: Optional[str] = None
|
||||
bank_account_holder: Optional[str] = None
|
||||
bank_code: Optional[str] = None
|
||||
|
||||
@router.get("/company")
|
||||
async def get_company_settings(
|
||||
@@ -1452,6 +1456,10 @@ async def get_company_settings(
|
||||
"tax_rate",
|
||||
"chat_working_hours_start",
|
||||
"chat_working_hours_end",
|
||||
"bank_name",
|
||||
"bank_account_number",
|
||||
"bank_account_holder",
|
||||
"bank_code",
|
||||
]
|
||||
|
||||
settings_dict = {}
|
||||
@@ -1488,6 +1496,10 @@ async def get_company_settings(
|
||||
"tax_rate": float(settings_dict.get("tax_rate", 0)) if settings_dict.get("tax_rate") else 0.0,
|
||||
"chat_working_hours_start": int(settings_dict.get("chat_working_hours_start", 9)) if settings_dict.get("chat_working_hours_start") else 9,
|
||||
"chat_working_hours_end": int(settings_dict.get("chat_working_hours_end", 17)) if settings_dict.get("chat_working_hours_end") else 17,
|
||||
"bank_name": settings_dict.get("bank_name", ""),
|
||||
"bank_account_number": settings_dict.get("bank_account_number", ""),
|
||||
"bank_account_holder": settings_dict.get("bank_account_holder", ""),
|
||||
"bank_code": settings_dict.get("bank_code", ""),
|
||||
"updated_at": updated_at,
|
||||
"updated_by": updated_by,
|
||||
}
|
||||
@@ -1533,6 +1545,14 @@ async def update_company_settings(
|
||||
db_settings["chat_working_hours_start"] = str(request_data.chat_working_hours_start)
|
||||
if request_data.chat_working_hours_end is not None:
|
||||
db_settings["chat_working_hours_end"] = str(request_data.chat_working_hours_end)
|
||||
if request_data.bank_name is not None:
|
||||
db_settings["bank_name"] = request_data.bank_name
|
||||
if request_data.bank_account_number is not None:
|
||||
db_settings["bank_account_number"] = request_data.bank_account_number
|
||||
if request_data.bank_account_holder is not None:
|
||||
db_settings["bank_account_holder"] = request_data.bank_account_holder
|
||||
if request_data.bank_code is not None:
|
||||
db_settings["bank_code"] = request_data.bank_code
|
||||
|
||||
for key, value in db_settings.items():
|
||||
|
||||
@@ -1581,7 +1601,7 @@ async def update_company_settings(
|
||||
|
||||
|
||||
updated_settings = {}
|
||||
for key in ["company_name", "company_tagline", "company_logo_url", "company_favicon_url", "company_phone", "company_email", "company_address", "tax_rate", "chat_working_hours_start", "chat_working_hours_end"]:
|
||||
for key in ["company_name", "company_tagline", "company_logo_url", "company_favicon_url", "company_phone", "company_email", "company_address", "tax_rate", "chat_working_hours_start", "chat_working_hours_end", "bank_name", "bank_account_number", "bank_account_holder", "bank_code"]:
|
||||
setting = db.query(SystemSettings).filter(
|
||||
SystemSettings.key == key
|
||||
).first()
|
||||
@@ -1619,6 +1639,10 @@ async def update_company_settings(
|
||||
"tax_rate": float(updated_settings.get("tax_rate", 0)) if updated_settings.get("tax_rate") else 0.0,
|
||||
"chat_working_hours_start": int(updated_settings.get("chat_working_hours_start", 9)) if updated_settings.get("chat_working_hours_start") else 9,
|
||||
"chat_working_hours_end": int(updated_settings.get("chat_working_hours_end", 17)) if updated_settings.get("chat_working_hours_end") else 17,
|
||||
"bank_name": updated_settings.get("bank_name", ""),
|
||||
"bank_account_number": updated_settings.get("bank_account_number", ""),
|
||||
"bank_account_holder": updated_settings.get("bank_account_holder", ""),
|
||||
"bank_code": updated_settings.get("bank_code", ""),
|
||||
"updated_at": updated_at,
|
||||
"updated_by": updated_by,
|
||||
}
|
||||
@@ -1851,6 +1875,7 @@ class UpdateThemeSettingsRequest(BaseModel):
|
||||
theme_primary_light: Optional[str] = None
|
||||
theme_primary_dark: Optional[str] = None
|
||||
theme_primary_accent: Optional[str] = None
|
||||
theme_layout_mode: Optional[str] = None # 'dark' or 'light'
|
||||
|
||||
@router.get("/theme")
|
||||
async def get_theme_settings(
|
||||
@@ -1863,6 +1888,7 @@ async def get_theme_settings(
|
||||
"theme_primary_light",
|
||||
"theme_primary_dark",
|
||||
"theme_primary_accent",
|
||||
"theme_layout_mode",
|
||||
]
|
||||
|
||||
settings_dict = {}
|
||||
@@ -1893,6 +1919,7 @@ async def get_theme_settings(
|
||||
"theme_primary_light": settings_dict.get("theme_primary_light", "#f5d76e"),
|
||||
"theme_primary_dark": settings_dict.get("theme_primary_dark", "#c9a227"),
|
||||
"theme_primary_accent": settings_dict.get("theme_primary_accent", "#e8c547"),
|
||||
"theme_layout_mode": settings_dict.get("theme_layout_mode", "dark"),
|
||||
"updated_at": updated_at,
|
||||
"updated_by": updated_by,
|
||||
}
|
||||
@@ -1953,6 +1980,14 @@ async def update_theme_settings(
|
||||
)
|
||||
db_settings["theme_primary_accent"] = request_data.theme_primary_accent
|
||||
|
||||
if request_data.theme_layout_mode is not None:
|
||||
if request_data.theme_layout_mode not in ["dark", "light"]:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="Invalid theme_layout_mode. Must be 'dark' or 'light'"
|
||||
)
|
||||
db_settings["theme_layout_mode"] = request_data.theme_layout_mode
|
||||
|
||||
# Update or create settings
|
||||
for key, value in db_settings.items():
|
||||
setting = db.query(SystemSettings).filter(
|
||||
@@ -1975,7 +2010,7 @@ async def update_theme_settings(
|
||||
|
||||
# Get updated settings
|
||||
updated_settings = {}
|
||||
for key in ["theme_primary_color", "theme_primary_light", "theme_primary_dark", "theme_primary_accent"]:
|
||||
for key in ["theme_primary_color", "theme_primary_light", "theme_primary_dark", "theme_primary_accent", "theme_layout_mode"]:
|
||||
setting = db.query(SystemSettings).filter(
|
||||
SystemSettings.key == key
|
||||
).first()
|
||||
@@ -1988,6 +2023,7 @@ async def update_theme_settings(
|
||||
"theme_primary_light": "#f5d76e",
|
||||
"theme_primary_dark": "#c9a227",
|
||||
"theme_primary_accent": "#e8c547",
|
||||
"theme_layout_mode": "dark",
|
||||
}
|
||||
updated_settings[key] = defaults.get(key)
|
||||
|
||||
@@ -2009,6 +2045,7 @@ async def update_theme_settings(
|
||||
"theme_primary_light": updated_settings.get("theme_primary_light", "#f5d76e"),
|
||||
"theme_primary_dark": updated_settings.get("theme_primary_dark", "#c9a227"),
|
||||
"theme_primary_accent": updated_settings.get("theme_primary_accent", "#e8c547"),
|
||||
"theme_layout_mode": updated_settings.get("theme_layout_mode", "dark"),
|
||||
"updated_at": updated_at,
|
||||
"updated_by": updated_by,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user