mirror of
https://github.com/umami-software/umami.git
synced 2026-02-06 05:37:20 +01:00
add dropdown logic for revenue report, defaults to USD for unknown currency code
This commit is contained in:
parent
214396f4b6
commit
be50e8a575
8 changed files with 155 additions and 12 deletions
|
|
@ -5,12 +5,13 @@ import { TimezoneTest, UnitTypeTest } from 'lib/yup';
|
|||
import { NextApiResponse } from 'next';
|
||||
import { methodNotAllowed, ok, unauthorized } from 'next-basics';
|
||||
import { getRevenue } from 'queries/analytics/reports/getRevenue';
|
||||
import { getRevenueValues } from 'queries/analytics/reports/getRevenueValues';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export interface RevenueRequestBody {
|
||||
websiteId: string;
|
||||
currency: string;
|
||||
timezone: string;
|
||||
currency?: string;
|
||||
timezone?: string;
|
||||
dateRange: { startDate: string; endDate: string; unit?: string };
|
||||
}
|
||||
|
||||
|
|
@ -37,6 +38,21 @@ export default async (
|
|||
await useAuth(req, res);
|
||||
await useValidate(schema, req, res);
|
||||
|
||||
if (req.method === 'GET') {
|
||||
const { websiteId, startDate, endDate } = req.query;
|
||||
|
||||
if (!(await canViewWebsite(req.auth, websiteId))) {
|
||||
return unauthorized(res);
|
||||
}
|
||||
|
||||
const data = await getRevenueValues(websiteId, {
|
||||
startDate: new Date(startDate),
|
||||
endDate: new Date(endDate),
|
||||
});
|
||||
|
||||
return ok(res, data);
|
||||
}
|
||||
|
||||
if (req.method === 'POST') {
|
||||
const {
|
||||
websiteId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue