mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
ensure translation of default report name
This commit is contained in:
parent
440676ef21
commit
aa341d1dd2
@ -2,18 +2,20 @@ import { produce } from 'immer';
|
|||||||
import { useCallback, useEffect, useState } from 'react';
|
import { useCallback, useEffect, useState } from 'react';
|
||||||
import { useTimezone } from './useTimezone';
|
import { useTimezone } from './useTimezone';
|
||||||
import useApi from './useApi';
|
import useApi from './useApi';
|
||||||
|
import useMessages from './useMessages';
|
||||||
const baseParameters = {
|
|
||||||
name: 'Untitled',
|
|
||||||
description: '',
|
|
||||||
parameters: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
export function useReport(reportId, defaultParameters) {
|
export function useReport(reportId, defaultParameters) {
|
||||||
const [report, setReport] = useState(null);
|
const [report, setReport] = useState(null);
|
||||||
const [isRunning, setIsRunning] = useState(false);
|
const [isRunning, setIsRunning] = useState(false);
|
||||||
const { get, post } = useApi();
|
const { get, post } = useApi();
|
||||||
const [timezone] = useTimezone();
|
const [timezone] = useTimezone();
|
||||||
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
|
const baseParameters = {
|
||||||
|
name: formatMessage(labels.untitled),
|
||||||
|
description: '',
|
||||||
|
parameters: {},
|
||||||
|
};
|
||||||
|
|
||||||
const loadReport = async id => {
|
const loadReport = async id => {
|
||||||
const data = await get(`/reports/${id}`);
|
const data = await get(`/reports/${id}`);
|
||||||
|
@ -20,6 +20,7 @@ export function ReportHeader({ icon }) {
|
|||||||
|
|
||||||
const { name, description, parameters } = report || {};
|
const { name, description, parameters } = report || {};
|
||||||
const { websiteId, dateRange } = parameters || {};
|
const { websiteId, dateRange } = parameters || {};
|
||||||
|
const defaultName = formatMessage(labels.untitled);
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
if (!report.id) {
|
if (!report.id) {
|
||||||
@ -39,7 +40,7 @@ export function ReportHeader({ icon }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleNameChange = name => {
|
const handleNameChange = name => {
|
||||||
updateReport({ name: name || 'Untitled' });
|
updateReport({ name: name || defaultName });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDescriptionChange = description => {
|
const handleDescriptionChange = description => {
|
||||||
@ -54,7 +55,7 @@ export function ReportHeader({ icon }) {
|
|||||||
key={name}
|
key={name}
|
||||||
name="name"
|
name="name"
|
||||||
value={name}
|
value={name}
|
||||||
placeholder={formatMessage(labels.untitled)}
|
placeholder={defaultName}
|
||||||
onCommit={handleNameChange}
|
onCommit={handleNameChange}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user