- company.notifications 테이블 + NotificationType(SUCCESS/REGENERATED/FAILURE) - 백엔드 알림 조회/읽음 API + close_and_decide 결과 분기마다 알림 생성 - 헤더 알림 벨(안읽음 배지) + 알림 페이지(읽음·딥링크) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
257 lines
8.6 KiB
TypeScript
257 lines
8.6 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Negodata Api Server
|
|
* OpenAPI spec version: 0.1.0
|
|
*/
|
|
import {
|
|
useMutation,
|
|
useQuery
|
|
} from '@tanstack/react-query';
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult
|
|
} from '@tanstack/react-query';
|
|
|
|
import type {
|
|
HTTPValidationError,
|
|
ListNotificationsParams,
|
|
ResNotificationList,
|
|
ResNotificationRead
|
|
} from '.././model';
|
|
|
|
import { customFetch } from '../../mutator/custom-fetch';
|
|
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
|
|
|
|
/**
|
|
* @summary 알림 목록(+안읽음 수)
|
|
*/
|
|
export const listNotifications = (
|
|
params?: ListNotificationsParams,
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResNotificationList>(
|
|
{url: `/v1/notification/list`, method: 'GET',
|
|
params, signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getListNotificationsQueryKey = (params?: ListNotificationsParams,) => {
|
|
return [
|
|
`/v1/notification/list`, ...(params ? [params]: [])
|
|
] as const;
|
|
}
|
|
|
|
|
|
export const getListNotificationsQueryOptions = <TData = Awaited<ReturnType<typeof listNotifications>>, TError = void | HTTPValidationError>(params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
) => {
|
|
|
|
const {query: queryOptions, request: requestOptions} = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListNotificationsQueryKey(params);
|
|
|
|
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listNotifications>>> = ({ signal }) => listNotifications(params, requestOptions, signal);
|
|
|
|
|
|
|
|
|
|
|
|
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
}
|
|
|
|
export type ListNotificationsQueryResult = NonNullable<Awaited<ReturnType<typeof listNotifications>>>
|
|
export type ListNotificationsQueryError = void | HTTPValidationError
|
|
|
|
|
|
export function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = void | HTTPValidationError>(
|
|
params: undefined | ListNotificationsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listNotifications>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listNotifications>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = void | HTTPValidationError>(
|
|
params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>> & Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listNotifications>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listNotifications>>
|
|
> , 'initialData'
|
|
>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
export function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = void | HTTPValidationError>(
|
|
params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
|
/**
|
|
* @summary 알림 목록(+안읽음 수)
|
|
*/
|
|
|
|
export function useListNotifications<TData = Awaited<ReturnType<typeof listNotifications>>, TError = void | HTTPValidationError>(
|
|
params?: ListNotificationsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listNotifications>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient
|
|
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
|
|
|
const queryOptions = getListNotificationsQueryOptions(params,options)
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey ;
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
* @summary 전체 읽음 처리
|
|
*/
|
|
export const readAll = (
|
|
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResNotificationRead>(
|
|
{url: `/v1/notification/read-all`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getReadAllMutationOptions = <TError = void,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof readAll>>, TError,void, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof readAll>>, TError,void, TContext> => {
|
|
|
|
const mutationKey = ['readAll'];
|
|
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
options
|
|
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
: {mutation: { mutationKey, }, request: undefined};
|
|
|
|
|
|
|
|
|
|
const mutationFn: MutationFunction<Awaited<ReturnType<typeof readAll>>, void> = () => {
|
|
|
|
|
|
return readAll(requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type ReadAllMutationResult = NonNullable<Awaited<ReturnType<typeof readAll>>>
|
|
|
|
export type ReadAllMutationError = void
|
|
|
|
/**
|
|
* @summary 전체 읽음 처리
|
|
*/
|
|
export const useReadAll = <TError = void,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof readAll>>, TError,void, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof readAll>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getReadAllMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
/**
|
|
* @summary 알림 읽음 처리
|
|
*/
|
|
export const readOne = (
|
|
notificationId: string,
|
|
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
|
) => {
|
|
|
|
|
|
return customFetch<ResNotificationRead>(
|
|
{url: `/v1/notification/${notificationId}/read`, method: 'POST', signal
|
|
},
|
|
options);
|
|
}
|
|
|
|
|
|
|
|
export const getReadOneMutationOptions = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof readOne>>, TError,{notificationId: string}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
): UseMutationOptions<Awaited<ReturnType<typeof readOne>>, TError,{notificationId: string}, TContext> => {
|
|
|
|
const mutationKey = ['readOne'];
|
|
const {mutation: mutationOptions, request: requestOptions} = options ?
|
|
options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey ?
|
|
options
|
|
: {...options, mutation: {...options.mutation, mutationKey}}
|
|
: {mutation: { mutationKey, }, request: undefined};
|
|
|
|
|
|
|
|
|
|
const mutationFn: MutationFunction<Awaited<ReturnType<typeof readOne>>, {notificationId: string}> = (props) => {
|
|
const {notificationId} = props ?? {};
|
|
|
|
return readOne(notificationId,requestOptions)
|
|
}
|
|
|
|
|
|
|
|
|
|
return { mutationFn, ...mutationOptions }}
|
|
|
|
export type ReadOneMutationResult = NonNullable<Awaited<ReturnType<typeof readOne>>>
|
|
|
|
export type ReadOneMutationError = void | HTTPValidationError
|
|
|
|
/**
|
|
* @summary 알림 읽음 처리
|
|
*/
|
|
export const useReadOne = <TError = void | HTTPValidationError,
|
|
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof readOne>>, TError,{notificationId: string}, TContext>, request?: SecondParameter<typeof customFetch>}
|
|
, queryClient?: QueryClient): UseMutationResult<
|
|
Awaited<ReturnType<typeof readOne>>,
|
|
TError,
|
|
{notificationId: string},
|
|
TContext
|
|
> => {
|
|
|
|
const mutationOptions = getReadOneMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
}
|
|
|