fix: expense date timezone, receipt popup blocker
This commit is contained in:
@@ -269,16 +269,16 @@ export default function Invoices() {
|
|||||||
|
|
||||||
const handleViewReceipt = async (expense) => {
|
const handleViewReceipt = async (expense) => {
|
||||||
if (!expense.receipt_path) return;
|
if (!expense.receipt_path) return;
|
||||||
const { data, error } = await supabase.storage.from(RECEIPT_BUCKET).createSignedUrl(expense.receipt_path, 3600, {
|
const win = window.open('', '_blank', 'noopener,noreferrer');
|
||||||
download: expense.receipt_name || undefined,
|
const { data, error } = await supabase.storage.from(RECEIPT_BUCKET).createSignedUrl(expense.receipt_path, 3600);
|
||||||
});
|
|
||||||
if (error || !data?.signedUrl) {
|
if (error || !data?.signedUrl) {
|
||||||
|
win?.close();
|
||||||
const message = error?.message || 'Failed to open receipt.';
|
const message = error?.message || 'Failed to open receipt.';
|
||||||
setExpensesError(message);
|
setExpensesError(message);
|
||||||
alert(message);
|
alert(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window.open(data.signedUrl, '_blank', 'noopener,noreferrer');
|
win.location.href = data.signedUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateSubcontractorPO = async (po, updates, errorLabel = 'Failed to update PO') => {
|
const updateSubcontractorPO = async (po, updates, errorLabel = 'Failed to update PO') => {
|
||||||
@@ -1210,7 +1210,7 @@ export default function Invoices() {
|
|||||||
return exp[key] || '';
|
return exp[key] || '';
|
||||||
}).map(exp => (
|
}).map(exp => (
|
||||||
<tr key={exp.id} style={{ cursor: 'pointer' }} onClick={() => startEditExpense(exp)}>
|
<tr key={exp.id} style={{ cursor: 'pointer' }} onClick={() => startEditExpense(exp)}>
|
||||||
<td>{new Date(exp.date).toLocaleDateString()}</td>
|
<td>{new Date(exp.date + 'T12:00:00').toLocaleDateString('en-US', { month: 'short', day: 'numeric', year: 'numeric' })}</td>
|
||||||
<td style={{ fontWeight: 400 }}>{exp.description}</td>
|
<td style={{ fontWeight: 400 }}>{exp.description}</td>
|
||||||
<td>{exp.category}</td>
|
<td>{exp.category}</td>
|
||||||
<td style={{ color: 'var(--text-muted)' }}>
|
<td style={{ color: 'var(--text-muted)' }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user