estratti unix
This commit is contained in:
parent
ae4068fb85
commit
f1e60728e0
1 changed files with 10 additions and 9 deletions
|
|
@ -1,6 +1,5 @@
|
|||
import { TZDate } from "@date-fns/tz";
|
||||
import {
|
||||
add,
|
||||
differenceInMonths,
|
||||
endOfMonth,
|
||||
format,
|
||||
|
|
@ -44,11 +43,11 @@ const reportStatusTitles: Record<string, string> = {
|
|||
};
|
||||
|
||||
const getMonthKey = (unix: number) => {
|
||||
const date = new Date(unix * 1000); // Unix is usually in seconds, JS needs ms
|
||||
const date = fromUnixTime(unix);
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}`;
|
||||
};
|
||||
|
||||
const START_DATE = new TZDate("2026-01-01", "UTC");
|
||||
const START_DATE = new TZDate(2026, 0, "UTC");
|
||||
/**
|
||||
* Pagina di gestione reports stripe per admin: /area-riservata/admin/stripe-reports
|
||||
*/
|
||||
|
|
@ -60,12 +59,13 @@ const StripeReports: NextPageWithLayout = () => {
|
|||
const monthsToShow = differenceInMonths(now, START_DATE) + 1;
|
||||
|
||||
const mappings = Array.from({ length: monthsToShow }, (_, i) => {
|
||||
const m = add(START_DATE, { months: i });
|
||||
const em = endOfMonth(m);
|
||||
const um = getUnixTime(m);
|
||||
const d = new TZDate(2026, i, "UTC");
|
||||
|
||||
const em = endOfMonth(d);
|
||||
const um = getUnixTime(d);
|
||||
const uem = getUnixTime(em);
|
||||
return {
|
||||
title: format(m, "MMMM yyyy", { locale: it }),
|
||||
title: format(d, "MMMM yyyy", { locale: it }),
|
||||
start: um,
|
||||
end: uem,
|
||||
};
|
||||
|
|
@ -86,7 +86,6 @@ const StripeReports: NextPageWithLayout = () => {
|
|||
|
||||
return map;
|
||||
}, [data]);
|
||||
|
||||
if (isLoading) return <LoadingPage />;
|
||||
if (!data) return <Status500 />;
|
||||
return (
|
||||
|
|
@ -267,7 +266,9 @@ const MonthRow = ({
|
|||
|
||||
return (
|
||||
<TableRow className="grid grid-cols-2">
|
||||
<TableCell>{title}</TableCell>
|
||||
<TableCell>
|
||||
{title} ({start})
|
||||
</TableCell>
|
||||
<TableCell className="flex items-center gap-2">
|
||||
<LoadingButton
|
||||
loading={isGenerating}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue