-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cms): Add model to store the chart data
SS-56
- Loading branch information
1 parent
d5b580b
commit c559040
Showing
15 changed files
with
5,677 additions
and
2,078 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,353 @@ | ||
/** | ||
* Generated by orval v7.2.0 🍺 | ||
* Do not edit manually. | ||
* DOCUMENTATION | ||
* OpenAPI spec version: 1.0.0 | ||
*/ | ||
import { | ||
useMutation, | ||
useQuery | ||
} from '@tanstack/react-query' | ||
import type { | ||
DefinedInitialDataOptions, | ||
DefinedUseQueryResult, | ||
MutationFunction, | ||
QueryFunction, | ||
QueryKey, | ||
UndefinedInitialDataOptions, | ||
UseMutationOptions, | ||
UseMutationResult, | ||
UseQueryOptions, | ||
UseQueryResult | ||
} from '@tanstack/react-query' | ||
import type { | ||
ChartDataListResponse, | ||
ChartDataRequest, | ||
ChartDataResponse, | ||
Error, | ||
GetChartDatasParams | ||
} from './strapi.schemas' | ||
import { API } from '../../services/api'; | ||
import type { ErrorType, BodyType } from '../../services/api'; | ||
|
||
|
||
|
||
type SecondParameter<T extends (...args: any) => any> = Parameters<T>[1]; | ||
|
||
|
||
export const getChartDatas = ( | ||
params?: GetChartDatasParams, | ||
options?: SecondParameter<typeof API>,signal?: AbortSignal | ||
) => { | ||
|
||
|
||
return API<ChartDataListResponse>( | ||
{url: `/chart-datas`, method: 'GET', | ||
params, signal | ||
}, | ||
options); | ||
} | ||
|
||
|
||
export const getGetChartDatasQueryKey = (params?: GetChartDatasParams,) => { | ||
return [`/chart-datas`, ...(params ? [params]: [])] as const; | ||
} | ||
|
||
|
||
export const getGetChartDatasQueryOptions = <TData = Awaited<ReturnType<typeof getChartDatas>>, TError = ErrorType<Error>>(params?: GetChartDatasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
) => { | ||
|
||
const {query: queryOptions, request: requestOptions} = options ?? {}; | ||
|
||
const queryKey = queryOptions?.queryKey ?? getGetChartDatasQueryKey(params); | ||
|
||
|
||
|
||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getChartDatas>>> = ({ signal }) => getChartDatas(params, requestOptions, signal); | ||
|
||
|
||
|
||
|
||
|
||
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData> & { queryKey: QueryKey } | ||
} | ||
|
||
export type GetChartDatasQueryResult = NonNullable<Awaited<ReturnType<typeof getChartDatas>>> | ||
export type GetChartDatasQueryError = ErrorType<Error> | ||
|
||
|
||
export function useGetChartDatas<TData = Awaited<ReturnType<typeof getChartDatas>>, TError = ErrorType<Error>>( | ||
params: undefined | GetChartDatasParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData>> & Pick< | ||
DefinedInitialDataOptions< | ||
Awaited<ReturnType<typeof getChartDatas>>, | ||
TError, | ||
TData | ||
> , 'initialData' | ||
>, request?: SecondParameter<typeof API>} | ||
|
||
): DefinedUseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
export function useGetChartDatas<TData = Awaited<ReturnType<typeof getChartDatas>>, TError = ErrorType<Error>>( | ||
params?: GetChartDatasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData>> & Pick< | ||
UndefinedInitialDataOptions< | ||
Awaited<ReturnType<typeof getChartDatas>>, | ||
TError, | ||
TData | ||
> , 'initialData' | ||
>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
export function useGetChartDatas<TData = Awaited<ReturnType<typeof getChartDatas>>, TError = ErrorType<Error>>( | ||
params?: GetChartDatasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
|
||
export function useGetChartDatas<TData = Awaited<ReturnType<typeof getChartDatas>>, TError = ErrorType<Error>>( | ||
params?: GetChartDatasParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatas>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } { | ||
|
||
const queryOptions = getGetChartDatasQueryOptions(params,options) | ||
|
||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey }; | ||
|
||
query.queryKey = queryOptions.queryKey ; | ||
|
||
return query; | ||
} | ||
|
||
|
||
|
||
export const postChartDatas = ( | ||
chartDataRequest: BodyType<ChartDataRequest>, | ||
options?: SecondParameter<typeof API>,) => { | ||
|
||
|
||
return API<ChartDataResponse>( | ||
{url: `/chart-datas`, method: 'POST', | ||
headers: {'Content-Type': 'application/json', }, | ||
data: chartDataRequest | ||
}, | ||
options); | ||
} | ||
|
||
|
||
|
||
export const getPostChartDatasMutationOptions = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postChartDatas>>, TError,{data: BodyType<ChartDataRequest>}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationOptions<Awaited<ReturnType<typeof postChartDatas>>, TError,{data: BodyType<ChartDataRequest>}, TContext> => { | ||
const {mutation: mutationOptions, request: requestOptions} = options ?? {}; | ||
|
||
|
||
|
||
|
||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof postChartDatas>>, {data: BodyType<ChartDataRequest>}> = (props) => { | ||
const {data} = props ?? {}; | ||
|
||
return postChartDatas(data,requestOptions) | ||
} | ||
|
||
|
||
|
||
|
||
return { mutationFn, ...mutationOptions }} | ||
|
||
export type PostChartDatasMutationResult = NonNullable<Awaited<ReturnType<typeof postChartDatas>>> | ||
export type PostChartDatasMutationBody = BodyType<ChartDataRequest> | ||
export type PostChartDatasMutationError = ErrorType<Error> | ||
|
||
export const usePostChartDatas = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof postChartDatas>>, TError,{data: BodyType<ChartDataRequest>}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationResult< | ||
Awaited<ReturnType<typeof postChartDatas>>, | ||
TError, | ||
{data: BodyType<ChartDataRequest>}, | ||
TContext | ||
> => { | ||
|
||
const mutationOptions = getPostChartDatasMutationOptions(options); | ||
|
||
return useMutation(mutationOptions); | ||
} | ||
export const getChartDatasId = ( | ||
id: number, | ||
options?: SecondParameter<typeof API>,signal?: AbortSignal | ||
) => { | ||
|
||
|
||
return API<ChartDataResponse>( | ||
{url: `/chart-datas/${id}`, method: 'GET', signal | ||
}, | ||
options); | ||
} | ||
|
||
|
||
export const getGetChartDatasIdQueryKey = (id: number,) => { | ||
return [`/chart-datas/${id}`] as const; | ||
} | ||
|
||
|
||
export const getGetChartDatasIdQueryOptions = <TData = Awaited<ReturnType<typeof getChartDatasId>>, TError = ErrorType<Error>>(id: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
) => { | ||
|
||
const {query: queryOptions, request: requestOptions} = options ?? {}; | ||
|
||
const queryKey = queryOptions?.queryKey ?? getGetChartDatasIdQueryKey(id); | ||
|
||
|
||
|
||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getChartDatasId>>> = ({ signal }) => getChartDatasId(id, requestOptions, signal); | ||
|
||
|
||
|
||
|
||
|
||
return { queryKey, queryFn, enabled: !!(id), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData> & { queryKey: QueryKey } | ||
} | ||
|
||
export type GetChartDatasIdQueryResult = NonNullable<Awaited<ReturnType<typeof getChartDatasId>>> | ||
export type GetChartDatasIdQueryError = ErrorType<Error> | ||
|
||
|
||
export function useGetChartDatasId<TData = Awaited<ReturnType<typeof getChartDatasId>>, TError = ErrorType<Error>>( | ||
id: number, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData>> & Pick< | ||
DefinedInitialDataOptions< | ||
Awaited<ReturnType<typeof getChartDatasId>>, | ||
TError, | ||
TData | ||
> , 'initialData' | ||
>, request?: SecondParameter<typeof API>} | ||
|
||
): DefinedUseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
export function useGetChartDatasId<TData = Awaited<ReturnType<typeof getChartDatasId>>, TError = ErrorType<Error>>( | ||
id: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData>> & Pick< | ||
UndefinedInitialDataOptions< | ||
Awaited<ReturnType<typeof getChartDatasId>>, | ||
TError, | ||
TData | ||
> , 'initialData' | ||
>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
export function useGetChartDatasId<TData = Awaited<ReturnType<typeof getChartDatasId>>, TError = ErrorType<Error>>( | ||
id: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } | ||
|
||
export function useGetChartDatasId<TData = Awaited<ReturnType<typeof getChartDatasId>>, TError = ErrorType<Error>>( | ||
id: number, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getChartDatasId>>, TError, TData>>, request?: SecondParameter<typeof API>} | ||
|
||
): UseQueryResult<TData, TError> & { queryKey: QueryKey } { | ||
|
||
const queryOptions = getGetChartDatasIdQueryOptions(id,options) | ||
|
||
const query = useQuery(queryOptions) as UseQueryResult<TData, TError> & { queryKey: QueryKey }; | ||
|
||
query.queryKey = queryOptions.queryKey ; | ||
|
||
return query; | ||
} | ||
|
||
|
||
|
||
export const putChartDatasId = ( | ||
id: number, | ||
chartDataRequest: BodyType<ChartDataRequest>, | ||
options?: SecondParameter<typeof API>,) => { | ||
|
||
|
||
return API<ChartDataResponse>( | ||
{url: `/chart-datas/${id}`, method: 'PUT', | ||
headers: {'Content-Type': 'application/json', }, | ||
data: chartDataRequest | ||
}, | ||
options); | ||
} | ||
|
||
|
||
|
||
export const getPutChartDatasIdMutationOptions = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putChartDatasId>>, TError,{id: number;data: BodyType<ChartDataRequest>}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationOptions<Awaited<ReturnType<typeof putChartDatasId>>, TError,{id: number;data: BodyType<ChartDataRequest>}, TContext> => { | ||
const {mutation: mutationOptions, request: requestOptions} = options ?? {}; | ||
|
||
|
||
|
||
|
||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof putChartDatasId>>, {id: number;data: BodyType<ChartDataRequest>}> = (props) => { | ||
const {id,data} = props ?? {}; | ||
|
||
return putChartDatasId(id,data,requestOptions) | ||
} | ||
|
||
|
||
|
||
|
||
return { mutationFn, ...mutationOptions }} | ||
|
||
export type PutChartDatasIdMutationResult = NonNullable<Awaited<ReturnType<typeof putChartDatasId>>> | ||
export type PutChartDatasIdMutationBody = BodyType<ChartDataRequest> | ||
export type PutChartDatasIdMutationError = ErrorType<Error> | ||
|
||
export const usePutChartDatasId = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof putChartDatasId>>, TError,{id: number;data: BodyType<ChartDataRequest>}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationResult< | ||
Awaited<ReturnType<typeof putChartDatasId>>, | ||
TError, | ||
{id: number;data: BodyType<ChartDataRequest>}, | ||
TContext | ||
> => { | ||
|
||
const mutationOptions = getPutChartDatasIdMutationOptions(options); | ||
|
||
return useMutation(mutationOptions); | ||
} | ||
export const deleteChartDatasId = ( | ||
id: number, | ||
options?: SecondParameter<typeof API>,) => { | ||
|
||
|
||
return API<number>( | ||
{url: `/chart-datas/${id}`, method: 'DELETE' | ||
}, | ||
options); | ||
} | ||
|
||
|
||
|
||
export const getDeleteChartDatasIdMutationOptions = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteChartDatasId>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationOptions<Awaited<ReturnType<typeof deleteChartDatasId>>, TError,{id: number}, TContext> => { | ||
const {mutation: mutationOptions, request: requestOptions} = options ?? {}; | ||
|
||
|
||
|
||
|
||
const mutationFn: MutationFunction<Awaited<ReturnType<typeof deleteChartDatasId>>, {id: number}> = (props) => { | ||
const {id} = props ?? {}; | ||
|
||
return deleteChartDatasId(id,requestOptions) | ||
} | ||
|
||
|
||
|
||
|
||
return { mutationFn, ...mutationOptions }} | ||
|
||
export type DeleteChartDatasIdMutationResult = NonNullable<Awaited<ReturnType<typeof deleteChartDatasId>>> | ||
|
||
export type DeleteChartDatasIdMutationError = ErrorType<Error> | ||
|
||
export const useDeleteChartDatasId = <TError = ErrorType<Error>, | ||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteChartDatasId>>, TError,{id: number}, TContext>, request?: SecondParameter<typeof API>} | ||
): UseMutationResult< | ||
Awaited<ReturnType<typeof deleteChartDatasId>>, | ||
TError, | ||
{id: number}, | ||
TContext | ||
> => { | ||
|
||
const mutationOptions = getDeleteChartDatasIdMutationOptions(options); | ||
|
||
return useMutation(mutationOptions); | ||
} | ||
|
Oops, something went wrong.