Add defaultLocale, EN names, and dashboard activity endpoints.
Expose branding.defaultLocale, optional user EN name fields, and lightweight dual daily activity for orders/customers; update project context and rules. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
4598add88c
commit
43e3912662
@@ -4,8 +4,10 @@ import {
|
||||
} from './business-primary-colors';
|
||||
import {
|
||||
BusinessSettings,
|
||||
DEFAULT_BUSINESS_DASHBOARD_LOCALE,
|
||||
DEFAULT_BUSINESS_SETTINGS,
|
||||
DEFAULT_ORDER_PROCESS_STEPS,
|
||||
type DashboardLocale,
|
||||
OrderProcessStep,
|
||||
} from './business-settings.types';
|
||||
import {
|
||||
@@ -17,6 +19,10 @@ function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
||||
}
|
||||
|
||||
export function normalizeDashboardLocale(value: unknown): DashboardLocale {
|
||||
return value === 'en' || value === 'fa' ? value : DEFAULT_BUSINESS_DASHBOARD_LOCALE;
|
||||
}
|
||||
|
||||
function readBoolean(value: unknown, fallback: boolean) {
|
||||
return typeof value === 'boolean' ? value : fallback;
|
||||
}
|
||||
@@ -32,9 +38,18 @@ function readOrderProcessSteps(value: unknown): OrderProcessStep[] {
|
||||
const id = typeof item.id === 'string' ? item.id.trim() : '';
|
||||
const label = typeof item.label === 'string' ? item.label.trim() : '';
|
||||
if (!id || !label) return null;
|
||||
const defaults = DEFAULT_ORDER_PROCESS_STEPS.find((step) => step.id === id);
|
||||
const byEnglishLabel = DEFAULT_ORDER_PROCESS_STEPS.find(
|
||||
(step) => step.label.toLowerCase() === label.toLowerCase(),
|
||||
);
|
||||
const labelFaRaw =
|
||||
typeof item.labelFa === 'string' ? item.labelFa.trim() : '';
|
||||
return {
|
||||
id,
|
||||
label,
|
||||
// Never fall back to the English label — that leaks EN into FA UIs.
|
||||
labelFa:
|
||||
labelFaRaw || defaults?.labelFa || byEnglishLabel?.labelFa || '',
|
||||
color: normalizeOrderStepColor(
|
||||
item.color,
|
||||
defaultOrderStepColor(id, index),
|
||||
@@ -59,6 +74,7 @@ export function normalizeBusinessSettings(raw: unknown): BusinessSettings {
|
||||
return {
|
||||
branding: {
|
||||
primaryColor: normalizeBusinessPrimaryColorId(branding.primaryColor),
|
||||
defaultLocale: normalizeDashboardLocale(branding.defaultLocale),
|
||||
},
|
||||
dashboard: {
|
||||
comments: {
|
||||
@@ -92,6 +108,8 @@ export function mergeBusinessSettings(
|
||||
branding: {
|
||||
primaryColor:
|
||||
patch.branding?.primaryColor ?? current.branding.primaryColor,
|
||||
defaultLocale:
|
||||
patch.branding?.defaultLocale ?? current.branding.defaultLocale,
|
||||
},
|
||||
dashboard: {
|
||||
comments: {
|
||||
|
||||
Reference in New Issue
Block a user