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 { TZDate } from "@date-fns/tz";
|
||||||
import {
|
import {
|
||||||
add,
|
|
||||||
differenceInMonths,
|
differenceInMonths,
|
||||||
endOfMonth,
|
endOfMonth,
|
||||||
format,
|
format,
|
||||||
|
|
@ -44,11 +43,11 @@ const reportStatusTitles: Record<string, string> = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getMonthKey = (unix: number) => {
|
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}`;
|
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
|
* 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 monthsToShow = differenceInMonths(now, START_DATE) + 1;
|
||||||
|
|
||||||
const mappings = Array.from({ length: monthsToShow }, (_, i) => {
|
const mappings = Array.from({ length: monthsToShow }, (_, i) => {
|
||||||
const m = add(START_DATE, { months: i });
|
const d = new TZDate(2026, i, "UTC");
|
||||||
const em = endOfMonth(m);
|
|
||||||
const um = getUnixTime(m);
|
const em = endOfMonth(d);
|
||||||
|
const um = getUnixTime(d);
|
||||||
const uem = getUnixTime(em);
|
const uem = getUnixTime(em);
|
||||||
return {
|
return {
|
||||||
title: format(m, "MMMM yyyy", { locale: it }),
|
title: format(d, "MMMM yyyy", { locale: it }),
|
||||||
start: um,
|
start: um,
|
||||||
end: uem,
|
end: uem,
|
||||||
};
|
};
|
||||||
|
|
@ -86,7 +86,6 @@ const StripeReports: NextPageWithLayout = () => {
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|
||||||
if (isLoading) return <LoadingPage />;
|
if (isLoading) return <LoadingPage />;
|
||||||
if (!data) return <Status500 />;
|
if (!data) return <Status500 />;
|
||||||
return (
|
return (
|
||||||
|
|
@ -267,7 +266,9 @@ const MonthRow = ({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow className="grid grid-cols-2">
|
<TableRow className="grid grid-cols-2">
|
||||||
<TableCell>{title}</TableCell>
|
<TableCell>
|
||||||
|
{title} ({start})
|
||||||
|
</TableCell>
|
||||||
<TableCell className="flex items-center gap-2">
|
<TableCell className="flex items-center gap-2">
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
loading={isGenerating}
|
loading={isGenerating}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue