mirror of https://github.com/buster-so/buster.git
Add TODO
This commit is contained in:
parent
154182d20e
commit
05194b004c
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
description: Creating tan stack query options to be consuming in providers and api calls
|
||||
globs: src/api/query_keys/**/*
|
||||
alwaysApply: false
|
||||
---
|
||||
# Query Keys Folder Rules
|
||||
|
||||
|
@ -17,6 +18,7 @@ Below is an example of how query options should be structured within a file:
|
|||
import { queryOptions } from '@tanstack/react-query';
|
||||
import type { BusterChat, BusterChatListItem } from '@/api/asset_interfaces';
|
||||
import type { GetChatListParams } from '@/api/request_interfaces/chats';
|
||||
import { type getListLogs } from '@/api/buster_rest/chats';
|
||||
|
||||
const chatsGetChat = (chatId: string) =>
|
||||
queryOptions<BusterChat>({
|
||||
|
@ -24,7 +26,7 @@ const chatsGetChat = (chatId: string) =>
|
|||
staleTime: 10 * 1000
|
||||
});
|
||||
|
||||
const chatsGetList = (filters?: GetChatListParams) =>
|
||||
const chatsGetList = (filters?: Parameters<typeof getListLogs>[0]>) =>
|
||||
queryOptions<BusterChatListItem[]>({
|
||||
queryKey: ['chats', 'list', filters] as const,
|
||||
staleTime: 10 * 1000
|
||||
|
|
|
@ -3,7 +3,6 @@ import { serverFetch } from '../../createServerInstance';
|
|||
import type { BusterChatListItem, BusterChat } from '@/api/asset_interfaces/chat';
|
||||
import type {
|
||||
DuplicateChatParams,
|
||||
GetChatListParams,
|
||||
GetChatParams,
|
||||
UpdateChatParams
|
||||
} from '../../request_interfaces/chats';
|
||||
|
@ -11,7 +10,10 @@ import type {
|
|||
const CHATS_BASE = '/chats';
|
||||
|
||||
// Client-side fetch version
|
||||
export const getListChats = async (params?: GetChatListParams): Promise<BusterChatListItem[]> => {
|
||||
export const getListChats = async (params?: {
|
||||
page_token: number;
|
||||
page_size: number;
|
||||
}): Promise<BusterChatListItem[]> => {
|
||||
const { page_token = 0, page_size = 3000 } = params || {};
|
||||
return mainApi
|
||||
.get<BusterChatListItem[]>(`${CHATS_BASE}`, {
|
||||
|
@ -20,7 +22,9 @@ export const getListChats = async (params?: GetChatListParams): Promise<BusterCh
|
|||
.then((res) => res.data);
|
||||
};
|
||||
|
||||
export const getListLogs = async (params?: GetChatListParams): Promise<BusterChatListItem[]> => {
|
||||
export const getListLogs = async (
|
||||
params?: Parameters<typeof getListChats>[0]
|
||||
): Promise<BusterChatListItem[]> => {
|
||||
const { page_token = 0, page_size = 3000 } = params || {};
|
||||
return mainApi
|
||||
.get<BusterChatListItem[]>(`/logs`, {
|
||||
|
@ -31,7 +35,7 @@ export const getListLogs = async (params?: GetChatListParams): Promise<BusterCha
|
|||
|
||||
// Server-side fetch version
|
||||
export const getListChats_server = async (
|
||||
params?: GetChatListParams
|
||||
params?: Parameters<typeof getListChats>[0]
|
||||
): Promise<BusterChatListItem[]> => {
|
||||
const { page_token = 0, page_size = 1000 } = params || {};
|
||||
return await serverFetch<BusterChatListItem[]>(`${CHATS_BASE}`, {
|
||||
|
|
|
@ -220,9 +220,9 @@ export const useRemoveItemFromDashboard = () => {
|
|||
if (prevDashboard) {
|
||||
const prevMetricsIds = Object.keys(prevDashboard?.metrics);
|
||||
const newMetricsIds = prevMetricsIds?.filter((t) => !metricId.includes(t));
|
||||
console.log('TODO: remove metrics from dashboard', dashboardId, metricId);
|
||||
return updateDashboardMutation({
|
||||
id: dashboardId,
|
||||
metrics: newMetricsIds
|
||||
id: dashboardId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
import type {
|
||||
GetChatParams,
|
||||
GetChatListParams,
|
||||
CreateNewChatParams,
|
||||
StopChatParams,
|
||||
UnsubscribeFromChatParams,
|
||||
DeleteChatParams,
|
||||
UpdateChatParams,
|
||||
ChatsSearchParams,
|
||||
DuplicateChatParams
|
||||
} from '../../request_interfaces/chats';
|
||||
import type { BusterSocketRequestBase } from '../base_interfaces';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { queryOptions } from '@tanstack/react-query';
|
||||
import type { BusterMetricData } from '@/api/asset_interfaces/metric';
|
||||
import { IBusterChat, BusterChatListItem, IBusterChatMessage } from '@/api/asset_interfaces/chat';
|
||||
import type { GetChatListParams } from '@/api/request_interfaces/chats';
|
||||
import { type getListLogs, type getListChats } from '@/api/buster_rest/chats';
|
||||
|
||||
const chatsGetChat = (chatId: string) =>
|
||||
queryOptions<IBusterChat>({
|
||||
|
@ -24,7 +24,7 @@ const chatsMessagesFetchingData = (messageId: string) =>
|
|||
enabled: !!messageId
|
||||
});
|
||||
|
||||
const chatsGetList = (filters?: GetChatListParams) =>
|
||||
const chatsGetList = (filters?: Parameters<typeof getListChats>[0]) =>
|
||||
queryOptions<BusterChatListItem[]>({
|
||||
queryKey: ['chats', 'list', filters] as const,
|
||||
staleTime: 60 * 1000, // 1 minute
|
||||
|
@ -40,7 +40,7 @@ const chatsBlackBoxMessages = (messageId: string) =>
|
|||
queryFn: () => Promise.resolve(null)
|
||||
});
|
||||
|
||||
const logsGetList = (filters?: GetChatListParams) =>
|
||||
const logsGetList = (filters?: Parameters<typeof getListLogs>[0]) =>
|
||||
queryOptions<BusterChatListItem[]>({
|
||||
queryKey: ['logs', 'list', filters] as const,
|
||||
staleTime: 60 * 1000, // 1 minute
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
export interface GetChatListParams {
|
||||
/** Pagination token indicating the page number */
|
||||
page_token: number;
|
||||
/** Number of chat items to return per page */
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface GetChatParams {
|
||||
/** The unique identifier of the chat to retrieve */
|
||||
id: string;
|
||||
|
|
|
@ -212,9 +212,10 @@ export const AddTypeModal: React.FC<{
|
|||
assets
|
||||
});
|
||||
} else if (type === 'dashboard') {
|
||||
console.log('TODO: add metrics to dashboard', dashboard!.id, selectedIds);
|
||||
await updateDashboard({
|
||||
id: dashboard!.id,
|
||||
metrics: selectedIds
|
||||
id: dashboard!.id
|
||||
// metrics: selectedIds
|
||||
});
|
||||
}
|
||||
setSubmitting(false);
|
||||
|
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
import React, { useState } from 'react';
|
||||
import { ChatItemsContainer } from './ChatItemsContainer';
|
||||
import { useGetListChats, useGetListLogs } from '@/api/buster_rest/chats';
|
||||
import type { GetChatListParams } from '@/api/request_interfaces/chats';
|
||||
import {
|
||||
type getListChats,
|
||||
type getListLogs,
|
||||
useGetListChats,
|
||||
useGetListLogs
|
||||
} from '@/api/buster_rest/chats';
|
||||
import { useUserConfigContextSelector } from '@/context/Users';
|
||||
|
||||
export const ChatListContainer: React.FC<{
|
||||
|
@ -19,7 +23,7 @@ export const ChatListContainer: React.FC<{
|
|||
};
|
||||
|
||||
const ChatsContainer: React.FC<{}> = ({}) => {
|
||||
const [filters, setFilters] = useState<Partial<GetChatListParams>>({});
|
||||
const [filters, setFilters] = useState<Partial<Parameters<typeof getListChats>[0]>>({});
|
||||
|
||||
const { data: list, isFetched } = useGetListChats(filters);
|
||||
|
||||
|
@ -27,7 +31,7 @@ const ChatsContainer: React.FC<{}> = ({}) => {
|
|||
};
|
||||
|
||||
const LogsContainer: React.FC<{}> = ({}) => {
|
||||
const [filters, setFilters] = useState<Partial<GetChatListParams>>({});
|
||||
const [filters, setFilters] = useState<Partial<Parameters<typeof getListLogs>[0]>>({});
|
||||
|
||||
const { data: list, isFetched } = useGetListLogs(filters);
|
||||
|
||||
|
|
Loading…
Reference in New Issue