Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions packages/app/src/AuthPage.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// @ts-nocheck TODO: remove this line

import { useEffect } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/router';
import { NextSeo } from 'next-seo';
import cx from 'classnames';
import { HTTPError } from 'ky';
import { SubmitHandler, useForm, useWatch } from 'react-hook-form';
import {
Button,
Expand Down Expand Up @@ -92,17 +90,18 @@ export default function AuthPage({ action }: { action: 'register' | 'login' }) {
{
onSuccess: () => router.push('/search'),
onError: async error => {
const jsonData = await error.response.json();
if (error instanceof HTTPError) {
const jsonData = await error.response.json();

if (Array.isArray(jsonData) && jsonData[0]?.errors?.issues) {
return jsonData[0].errors.issues.forEach((issue: any) => {
setError(issue.path[0], {
type: issue.code,
message: issue.message,
if (Array.isArray(jsonData) && jsonData[0]?.errors?.issues) {
return jsonData[0].errors.issues.forEach((issue: any) => {
setError(issue.path[0], {
type: issue.code,
message: issue.message,
});
});
});
}
}

setError('root', {
type: 'manual',
message: 'An unexpected error occurred, please try again later.',
Expand Down
2 changes: 0 additions & 2 deletions packages/app/src/LandingHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-nocheck TODO: remove this line

import Link from 'next/link';
import { Anchor, Burger, Button, Container, Group } from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
Expand Down
12 changes: 4 additions & 8 deletions packages/app/src/Spotlights.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-nocheck TODO: remove this line

import * as React from 'react';
import { useRouter } from 'next/router';
import { Spotlight, SpotlightActionData } from '@mantine/spotlight';
Expand All @@ -11,7 +9,6 @@ import {
IconGridDots,
IconHelpCircle,
IconLayout,
IconLayoutSidebar,
IconLogs,
IconSearch,
IconSettings,
Expand All @@ -38,28 +35,27 @@ export const useSpotlightActions = () => {
// Saved searches
logViews.forEach(logView => {
logViewActions.push({
id: logView._id,
id: logView.id,
group: 'Saved searches',
leftSection: <IconLogs size={16} />,
description: logView.query,
label: logView.name,
keywords: ['search', 'log', 'saved'],
onClick: () => {
router.push(`/search/${logView._id}`);
router.push(`/search/${logView.id}`);
},
});
});

// Dashboards
dashboards.forEach(dashboard => {
logViewActions.push({
id: dashboard._id,
id: dashboard.id,
group: 'Dashboards',
leftSection: <IconLayout size={16} />,
label: dashboard.name,
keywords: ['dashboard'],
onClick: () => {
router.push(`/dashboards/${dashboard._id}`);
router.push(`/dashboards/${dashboard.id}`);
},
});
});
Expand Down
16 changes: 12 additions & 4 deletions packages/app/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { UseQueryOptions } from '@tanstack/react-query';
import { useMutation, useQuery } from '@tanstack/react-query';

import { IS_LOCAL_MODE } from './config';
import { Dashboard } from './dashboard';
import type { AlertsPageItem } from './types';

type ServicesResponse = {
Expand Down Expand Up @@ -112,14 +113,14 @@ const api = {
}),
});
},
useDashboards(options?: UseQueryOptions<any, Error>) {
useDashboards(options?: UseQueryOptions<Dashboard[] | null, Error>) {
return useQuery({
queryKey: [`dashboards`],
queryFn: () => {
if (IS_LOCAL_MODE) {
return null;
}
return hdxServer(`dashboards`, { method: 'GET' }).json();
return hdxServer(`dashboards`, { method: 'GET' }).json<Dashboard[]>();
},
...options,
});
Expand Down Expand Up @@ -501,8 +502,15 @@ const api = {
},
useRegisterPassword() {
return useMutation({
// @ts-ignore
mutationFn: async ({ email, password, confirmPassword }) =>
mutationFn: async ({
email,
password,
confirmPassword,
}: {
email: string;
password: string;
confirmPassword: string;
}) =>
hdxServer(`register/password`, {
method: 'POST',
json: {
Expand Down
Loading