This commit is contained in:
2026-05-12 17:35:38 +03:00
parent d9ffcb4b92
commit e3f3e62482
51 changed files with 882 additions and 3413 deletions
+12 -12
View File
@@ -1,21 +1,21 @@
import { Revenue } from './definitions';
import type { Revenue } from "./definitions";
export const formatCurrency = (amount: number) => {
return (amount / 100).toLocaleString('en-US', {
style: 'currency',
currency: 'USD',
return (amount / 100).toLocaleString("en-US", {
style: "currency",
currency: "USD",
});
};
export const formatDateToLocal = (
dateStr: string,
locale: string = 'en-US',
locale: string = "en-US",
) => {
const date = new Date(dateStr);
const options: Intl.DateTimeFormatOptions = {
day: 'numeric',
month: 'short',
year: 'numeric',
day: "numeric",
month: "short",
year: "numeric",
};
const formatter = new Intl.DateTimeFormat(locale, options);
return formatter.format(date);
@@ -45,13 +45,13 @@ export const generatePagination = (currentPage: number, totalPages: number) => {
// If the current page is among the first 3 pages,
// show the first 3, an ellipsis, and the last 2 pages.
if (currentPage <= 3) {
return [1, 2, 3, '...', totalPages - 1, totalPages];
return [1, 2, 3, "...", totalPages - 1, totalPages];
}
// If the current page is among the last 3 pages,
// show the first 2, an ellipsis, and the last 3 pages.
if (currentPage >= totalPages - 2) {
return [1, 2, '...', totalPages - 2, totalPages - 1, totalPages];
return [1, 2, "...", totalPages - 2, totalPages - 1, totalPages];
}
// If the current page is somewhere in the middle,
@@ -59,11 +59,11 @@ export const generatePagination = (currentPage: number, totalPages: number) => {
// another ellipsis, and the last page.
return [
1,
'...',
"...",
currentPage - 1,
currentPage,
currentPage + 1,
'...',
"...",
totalPages,
];
};