diff --git a/asm_app/public/hospital.png b/asm_app/public/hospital.png new file mode 100644 index 0000000..a0165d9 Binary files /dev/null and b/asm_app/public/hospital.png differ diff --git a/asm_app/src/components/KpiMonthlyReportCard.tsx b/asm_app/src/components/KpiMonthlyReportCard.tsx index fc2d36f..361c408 100644 --- a/asm_app/src/components/KpiMonthlyReportCard.tsx +++ b/asm_app/src/components/KpiMonthlyReportCard.tsx @@ -243,8 +243,14 @@ const KpiMonthlyReportCard: React.FC = ({ const logoExtension: 'png' | 'jpeg' = 'png'; try { const baseUrl = import.meta.env.BASE_URL || '/'; - const logoUrl = `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${DEFAULT_HOSPITAL_LOGO}`; - const logoRes = await fetch(logoUrl); + const logoUrl = DEFAULT_HOSPITAL_LOGO.startsWith('/') || DEFAULT_HOSPITAL_LOGO.startsWith('http') + ? DEFAULT_HOSPITAL_LOGO + : `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${DEFAULT_HOSPITAL_LOGO}`; + let logoRes = await fetch(logoUrl); + if (!logoRes.ok && DEFAULT_HOSPITAL_LOGO.startsWith('/files/')) { + const fallbackUrl = `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${DEFAULT_HOSPITAL_LOGO.replace('/files/', '')}`; + logoRes = await fetch(fallbackUrl); + } if (logoRes.ok) { const arrayBuffer = await logoRes.arrayBuffer(); logoBase64 = btoa(String.fromCharCode(...new Uint8Array(arrayBuffer))); diff --git a/asm_app/src/components/PpmKpiReportCard.tsx b/asm_app/src/components/PpmKpiReportCard.tsx index c6ba4e7..428169b 100644 --- a/asm_app/src/components/PpmKpiReportCard.tsx +++ b/asm_app/src/components/PpmKpiReportCard.tsx @@ -154,8 +154,14 @@ const PpmKpiReportCard: React.FC = ({ const loadLogo = async (path: string): Promise => { try { const baseUrl = import.meta.env.BASE_URL || '/'; - const url = `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${path}`; - const res = await fetch(url); + const url = path.startsWith('/') || path.startsWith('http') + ? path + : `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${path}`; + let res = await fetch(url); + if (!res.ok && path.startsWith('/files/')) { + const fallback = `${baseUrl}${baseUrl.endsWith('/') ? '' : '/'}${path.replace('/files/', '')}`; + res = await fetch(fallback); + } if (!res.ok) return null; const buf = await res.arrayBuffer(); return btoa(String.fromCharCode(...new Uint8Array(buf))); diff --git a/asm_app/src/config/defaults.ts b/asm_app/src/config/defaults.ts index cf97d07..de90eb3 100644 --- a/asm_app/src/config/defaults.ts +++ b/asm_app/src/config/defaults.ts @@ -11,8 +11,10 @@ export const DEFAULT_REPORT_HOSPITAL = 'King Fahad Specialist Hospital'; export const DEFAULT_CLUSTER_NAME = 'Eastern Health Cluster'; // Default logos -export const DEFAULT_HOSPITAL_LOGO = 'kfsh-logo.png'; -export const DEFAULT_CLUSTER_LOGO = 'ehc-logo.png'; +export const DEFAULT_HOSPITAL_LOGO = '/files/hospital.png'; +export const DEFAULT_CLUSTER_LOGO = '/files/hospital.png'; + + // Fallback Frappe Backend Base URL export const DEFAULT_FRAPPE_BASE_URL = 'https://kfsh-dammam-asm.seeraarabia.com'; diff --git a/asm_ui_app/public/asm_app/hospital.png b/asm_ui_app/public/asm_app/hospital.png new file mode 100644 index 0000000..a0165d9 Binary files /dev/null and b/asm_ui_app/public/asm_app/hospital.png differ