Feat: Dashboard accuracy, Staff & Settings modules, and File Auth fix

This commit is contained in:
Hamza-Ayed
2026-04-19 15:25:43 +03:00
parent 3acd9f261b
commit ef9baf33f7
7 changed files with 415 additions and 12 deletions

View File

@@ -282,7 +282,8 @@ export const InvoicesPage = () => {
<button
onClick={(e) => {
e.stopPropagation();
window.open(`${apiClient.defaults.baseURL}/invoices/${inv.id}/file`, '_blank');
const token = localStorage.getItem('access_token');
window.open(`${apiClient.defaults.baseURL}/invoices/${inv.id}/file?token=${token}`, '_blank');
}}
className="w-full text-right px-4 py-2 text-sm text-slate-700 hover:bg-slate-50 flex items-center gap-2"
>
@@ -439,12 +440,13 @@ export const InvoicesPage = () => {
<div className="flex-1 overflow-auto bg-slate-100 p-8 flex justify-center items-start">
<div className="bg-white shadow-2xl rounded-sm overflow-hidden max-w-full">
<img
src={`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file`}
src={`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${localStorage.getItem('access_token')}`}
alt="Invoice"
className="max-w-full h-auto"
onError={(e) => {
// Fallback for PDF or Error
e.currentTarget.style.display = 'none';
const token = localStorage.getItem('access_token');
e.currentTarget.parentElement!.innerHTML = `
<div class="p-20 text-center">
<div class="w-20 h-20 bg-slate-50 rounded-full flex items-center justify-center mx-auto mb-4 border border-slate-200">
@@ -452,7 +454,7 @@ export const InvoicesPage = () => {
</div>
<h4 class="text-xl font-bold text-slate-900 mb-2">تعذر عرض الصورة مباشرة</h4>
<p class="text-slate-500 mb-6">قد يكون الملف بتنسيق PDF أو حدث خطأ أثناء التحميل.</p>
<a href="${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file" target="_blank" class="btn-primary px-8 py-3 rounded-xl inline-block">فتح الملف في نافذة جديدة</a>
<a href="${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${token}" target="_blank" class="btn-primary px-8 py-3 rounded-xl inline-block">فتح الملف في نافذة جديدة</a>
</div>
`;
}}
@@ -474,7 +476,10 @@ export const InvoicesPage = () => {
</div>
<div className="flex gap-4">
<button
onClick={() => window.open(`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file`, '_blank')}
onClick={() => {
const token = localStorage.getItem('access_token');
window.open(`${apiClient.defaults.baseURL}/invoices/${viewingInvoice.id}/file?token=${token}`, '_blank');
}}
className="px-6 py-3 rounded-xl bg-white border border-slate-200 text-slate-700 font-bold flex items-center gap-2 hover:bg-slate-50 transition-all shadow-sm"
>
<Download className="w-4 h-4" />