chore: format project automatically before starting dev server
This commit is contained in:
+7
-16
@@ -1,6 +1,5 @@
|
||||
import axios from 'axios';
|
||||
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: process.env.NEXT_PUBLIC_API_BASE_URL || 'https://api.example.com',
|
||||
timeout: 15000,
|
||||
@@ -9,32 +8,26 @@ const api = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
api.interceptors.request.use(
|
||||
(config) => {
|
||||
const token =
|
||||
typeof window !== 'undefined' ? window.localStorage.getItem('rm-auth-token') : null;
|
||||
config => {
|
||||
const token = typeof window !== 'undefined' ? window.localStorage.getItem('rm-auth-token') : null;
|
||||
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
|
||||
// console.log('[API request]', config.method?.toUpperCase(), config.url);
|
||||
// console.log('[API request]', config.method?.toUpperCase(), config.url);
|
||||
|
||||
return config;
|
||||
|
||||
|
||||
},
|
||||
(error) => Promise.reject(error)
|
||||
error => Promise.reject(error),
|
||||
);
|
||||
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
response => response,
|
||||
|
||||
(error) => {
|
||||
error => {
|
||||
if (error.response) {
|
||||
|
||||
const status = error.response.status;
|
||||
|
||||
if (status === 401) {
|
||||
@@ -50,10 +43,8 @@ api.interceptors.response.use(
|
||||
// TODO: Display a network connection error.
|
||||
}
|
||||
|
||||
|
||||
return Promise.reject(error);
|
||||
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export default api;
|
||||
|
||||
+12
-5
@@ -33,12 +33,19 @@ export async function downloadInvoiceExcel(order: CustomerOrder, filename: strin
|
||||
{header: 'قیمت واحد (ریال)', key: 'unitPrice', width: 22},
|
||||
{header: 'جمع (ریال)', key: 'total', width: 22},
|
||||
];
|
||||
order.items.forEach(item => sheet.addRow({
|
||||
name: item.name, model: item.model, modules: item.modules.join('، '), quantity: item.quantity,
|
||||
unitPrice: item.unitPrice, total: item.unitPrice * item.quantity,
|
||||
}));
|
||||
order.items.forEach(item =>
|
||||
sheet.addRow({
|
||||
name: item.name,
|
||||
model: item.model,
|
||||
modules: item.modules.join('، '),
|
||||
quantity: item.quantity,
|
||||
unitPrice: item.unitPrice,
|
||||
total: item.unitPrice * item.quantity,
|
||||
}),
|
||||
);
|
||||
const subtotal = order.items.reduce((sum, item) => sum + item.unitPrice * item.quantity, 0);
|
||||
const total = subtotal - (order.invoice?.discount || 0) + (order.invoice?.shipping || 0) + (order.invoice?.tax || 0);
|
||||
const total =
|
||||
subtotal - (order.invoice?.discount || 0) + (order.invoice?.shipping || 0) + (order.invoice?.tax || 0);
|
||||
sheet.addRow({name: 'مبلغ نهایی', total});
|
||||
sheet.getRow(1).font = {bold: true, color: {argb: 'FFFFFFFF'}};
|
||||
sheet.getRow(1).fill = {type: 'pattern', pattern: 'solid', fgColor: {argb: 'FF00A693'}};
|
||||
|
||||
Reference in New Issue
Block a user