Skip to content

Commit edb7022

Browse files
committed
Merge branch 'dev' into jajaja
# Conflicts: # package.json # src/components/hooks/useTimezone.ts # yarn.lock
2 parents 1c5ef97 + 7bb89b2 commit edb7022

File tree

13 files changed

+117
-109
lines changed

13 files changed

+117
-109
lines changed

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

src/app/(main)/settings/teams/TeamJoinForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
import { useApi, useMessages, useModified } from '@/components/hooks';
1212

1313
export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose: () => void }) {
14-
const { formatMessage, labels, getMessage } = useMessages();
14+
const { formatMessage, labels } = useMessages();
1515
const { post, useMutation } = useApi();
1616
const { mutate, error } = useMutation({ mutationFn: (data: any) => post('/teams/join', data) });
1717
const ref = useRef(null);
@@ -28,7 +28,7 @@ export function TeamJoinForm({ onSave, onClose }: { onSave: () => void; onClose:
2828
};
2929

3030
return (
31-
<Form ref={ref} onSubmit={handleSubmit} error={error && getMessage(error)}>
31+
<Form ref={ref} onSubmit={handleSubmit} error={error}>
3232
<FormRow label={formatMessage(labels.accessCode)}>
3333
<FormInput name="accessCode" rules={{ required: formatMessage(labels.required) }}>
3434
<TextField autoComplete="off" />

src/app/(main)/websites/[websiteId]/realtime/RealtimeLog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function RealtimeLog({ data }: { data: RealtimeData }) {
5252
},
5353
];
5454

55-
const getTime = ({ createdAt, firstAt }) => formatTimezoneDate(firstAt || createdAt, 'h:mm:ss');
55+
const getTime = ({ createdAt, firstAt }) => formatTimezoneDate(firstAt || createdAt, 'pp');
5656

5757
const getColor = ({ id, sessionId }) => stringToColor(sessionId || id);
5858

src/app/(main)/websites/[websiteId]/sessions/SessionsWeekly.tsx

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ export function SessionsWeekly({ websiteId }: { websiteId: string }) {
1010
const { data, ...props } = useWebsiteSessionsWeekly(websiteId);
1111
const { dateLocale } = useLocale();
1212
const { labels, formatMessage } = useMessages();
13+
const { weekStartsOn } = dateLocale.options;
14+
const daysOfWeek = Array(7)
15+
.fill(weekStartsOn)
16+
.map((d, i) => (d + i) % 7);
1317

1418
const [, max] = data
1519
? data.reduce((arr: number[], hours: number[], index: number) => {
@@ -40,41 +44,45 @@ export function SessionsWeekly({ websiteId }: { websiteId: string }) {
4044
{Array(24)
4145
.fill(null)
4246
.map((_, i) => {
43-
const label = format(addHours(startOfDay(new Date()), i), 'haaa');
47+
const label = format(addHours(startOfDay(new Date()), i), 'p', { locale: dateLocale })
48+
.replace(/\D00 ?/, '')
49+
.toLowerCase();
4450
return (
4551
<div key={i} className={styles.hour}>
4652
{label}
4753
</div>
4854
);
4955
})}
5056
</div>
51-
{data?.map((day: number[], index: number) => {
52-
return (
53-
<div key={index} className={styles.day}>
54-
<div className={styles.header}>
55-
{format(getDayOfWeekAsDate(index), 'EEE', { locale: dateLocale })}
57+
{data &&
58+
daysOfWeek.map((index: number) => {
59+
const day = data[index];
60+
return (
61+
<div key={index} className={styles.day}>
62+
<div className={styles.header}>
63+
{format(getDayOfWeekAsDate(index), 'EEE', { locale: dateLocale })}
64+
</div>
65+
{day?.map((hour: number) => {
66+
const pct = hour / max;
67+
return (
68+
<div key={hour} className={classNames(styles.cell)}>
69+
{hour > 0 && (
70+
<TooltipPopup
71+
label={`${formatMessage(labels.visitors)}: ${hour}`}
72+
position="right"
73+
>
74+
<div
75+
className={styles.block}
76+
style={{ opacity: pct, transform: `scale(${pct})` }}
77+
/>
78+
</TooltipPopup>
79+
)}
80+
</div>
81+
);
82+
})}
5683
</div>
57-
{day?.map((hour: number, n) => {
58-
const pct = hour / max;
59-
return (
60-
<div key={n} className={classNames(styles.cell)}>
61-
{hour > 0 && (
62-
<TooltipPopup
63-
label={`${formatMessage(labels.visitors)}: ${hour}`}
64-
position="right"
65-
>
66-
<div
67-
className={styles.block}
68-
style={{ opacity: pct, transform: `scale(${pct})` }}
69-
/>
70-
</TooltipPopup>
71-
)}
72-
</div>
73-
);
74-
})}
75-
</div>
76-
);
77-
})}
84+
);
85+
})}
7886
</div>
7987
</LoadingPanel>
8088
);

src/app/(main)/websites/[websiteId]/sessions/[sessionId]/SessionActivity.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export function SessionActivity({
3434
return (
3535
<Fragment key={eventId}>
3636
{showHeader && (
37-
<div className={styles.header}>{formatTimezoneDate(createdAt, 'EEEE, PPP')}</div>
37+
<div className={styles.header}>{formatTimezoneDate(createdAt, 'PPPP')}</div>
3838
)}
3939
<div key={eventId} className={styles.row}>
4040
<div className={styles.time}>

src/app/(main)/websites/[websiteId]/sessions/[sessionId]/SessionInfo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ export function SessionInfo({ data }) {
2020
</dd>
2121

2222
<dt>{formatMessage(labels.lastSeen)}</dt>
23-
<dd>{formatTimezoneDate(data?.lastAt, 'EEEE, PPPpp')}</dd>
23+
<dd>{formatTimezoneDate(data?.lastAt, 'PPPPpp')}</dd>
2424

2525
<dt>{formatMessage(labels.firstSeen)}</dt>
26-
<dd>{formatTimezoneDate(data?.firstAt, 'EEEE, PPPpp')}</dd>
26+
<dd>{formatTimezoneDate(data?.firstAt, 'PPPPpp')}</dd>
2727

2828
<dt>{formatMessage(labels.country)}</dt>
2929
<dd>

src/app/api/reports/journey/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { reportParms } from '@/lib/schema';
88
export async function POST(request: Request) {
99
const schema = z.object({
1010
...reportParms,
11-
steps: z.number().min(3).max(7),
11+
steps: z.coerce.number().min(3).max(7),
1212
startStep: z.string(),
1313
endStep: z.string(),
1414
});

src/app/api/teams/[teamId]/users/route.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { z } from 'zod';
22
import { unauthorized, json, badRequest } from '@/lib/response';
3-
import { canAddUserToTeam, canUpdateTeam } from '@/lib/auth';
3+
import { canAddUserToTeam, canViewTeam } from '@/lib/auth';
44
import { parseRequest } from '@/lib/request';
55
import { pagingParams, roleParam } from '@/lib/schema';
66
import { createTeamUser, getTeamUser, getTeamUsers } from '@/queries';
@@ -18,7 +18,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ team
1818

1919
const { teamId } = await params;
2020

21-
if (!(await canUpdateTeam(auth, teamId))) {
21+
if (!(await canViewTeam(auth, teamId))) {
2222
return unauthorized('You must be the owner of this team.');
2323
}
2424

@@ -45,12 +45,9 @@ export async function GET(request: Request, { params }: { params: Promise<{ team
4545
return json(users);
4646
}
4747

48-
export async function POST(
49-
request: Request,
50-
{ params }: { params: Promise<{ teamId: string; userId: string }> },
51-
) {
48+
export async function POST(request: Request, { params }: { params: Promise<{ teamId: string }> }) {
5249
const schema = z.object({
53-
userId: z.string(),
50+
userId: z.string().uuid(),
5451
role: roleParam,
5552
});
5653

src/app/login/LoginForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Logo from '@/assets/logo.svg';
1616
import styles from './LoginForm.module.css';
1717

1818
export function LoginForm() {
19-
const { formatMessage, labels, getMessage } = useMessages();
19+
const { formatMessage, labels } = useMessages();
2020
const router = useRouter();
2121
const { post, useMutation } = useApi();
2222
const { mutate, error, isPending } = useMutation({
@@ -40,7 +40,7 @@ export function LoginForm() {
4040
<Logo />
4141
</Icon>
4242
<div className={styles.title}>umami</div>
43-
<Form className={styles.form} onSubmit={handleSubmit} error={getMessage(error)}>
43+
<Form className={styles.form} onSubmit={handleSubmit} error={error}>
4444
<FormRow label={formatMessage(labels.username)}>
4545
<FormInput
4646
data-test="input-username"

src/components/hooks/useApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const selector = (state: { shareToken: { token?: string } }) => state.shareToken
99

1010
async function handleResponse(res: FetchResponse): Promise<any> {
1111
if (!res.ok) {
12-
return Promise.reject(new Error(res.error));
12+
return Promise.reject(new Error(res.error?.error || res.error || 'Unexpectd error.'));
1313
}
1414
return Promise.resolve(res.data);
1515
}

0 commit comments

Comments
 (0)