Skip to content
Open
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
2 changes: 2 additions & 0 deletions src/lib/schemas/campaignPublicResponseDto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export interface CampaignPublicResponseDto {
hotline?: string;
/** Link điều lệ */
regulationsUrl?: string;
/** Nội dung thể lệ (Markdown) */
regulations?: string;
/** Link fanpage */
fanpageUrl?: string;
/** Danh sách size áo */
Expand Down
2 changes: 2 additions & 0 deletions src/lib/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ export * from './updateStageDtoConfig';
export * from './updateStageDtoStageType';
export * from './updateTicketTierDto';
export * from './uploadControllerUploadFileBody';
export * from './upsertMatchScoreDto';
export * from './upsertMatchScoreDtoDetails';
export * from './user';
export * from './userResponseDto';
export * from './userResponseDtoRole';
Expand Down
19 changes: 19 additions & 0 deletions src/lib/schemas/upsertMatchScoreDto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Generated by orval v8.5.1 🍺
* Do not edit manually.
* 5Sport API
* API documentation for 5Sport authentication and services
* OpenAPI spec version: 1.0
*/
import type { UpsertMatchScoreDtoDetails } from './upsertMatchScoreDtoDetails';

export interface UpsertMatchScoreDto {
/** Team 1 points in this set */
team1Points: number;
/** Team 2 points in this set */
team2Points: number;
/** Winner team for this set (1 or 2) */
winnerTeam?: number;
/** Point-by-point details */
details?: UpsertMatchScoreDtoDetails;
}
12 changes: 12 additions & 0 deletions src/lib/schemas/upsertMatchScoreDtoDetails.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Generated by orval v8.5.1 🍺
* Do not edit manually.
* 5Sport API
* API documentation for 5Sport authentication and services
* OpenAPI spec version: 1.0
*/

/**
* Point-by-point details
*/
export type UpsertMatchScoreDtoDetails = { [key: string]: unknown };
247 changes: 247 additions & 0 deletions src/lib/services/match-scores/match-scores.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
/**
* Generated by orval v8.5.1 🍺
* Do not edit manually.
* 5Sport API
* API documentation for 5Sport authentication and services
* OpenAPI spec version: 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 {
MatchScore,
UpsertMatchScoreDto
} from '../../schemas';

import { defaultMutator } from '../../api/axiosInstance';


type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];



/**
* @summary Get all scores of a match
*/
export type matchScoreControllerFindAllResponse200 = {
data: MatchScore[]
status: 200
}

export type matchScoreControllerFindAllResponseSuccess = (matchScoreControllerFindAllResponse200) & {
headers: Headers;
};
;

export type matchScoreControllerFindAllResponse = (matchScoreControllerFindAllResponseSuccess)

export const getMatchScoreControllerFindAllUrl = (matchId: string,) => {




return `/matches/${matchId}/scores`
}

export const matchScoreControllerFindAll = async (matchId: string, options?: RequestInit): Promise<matchScoreControllerFindAllResponse> => {

return defaultMutator<matchScoreControllerFindAllResponse>(getMatchScoreControllerFindAllUrl(matchId),
{
...options,
method: 'GET'


}
);}





export const getMatchScoreControllerFindAllQueryKey = (matchId: string,) => {
return [
`/matches/${matchId}/scores`
] as const;
}


export const getMatchScoreControllerFindAllQueryOptions = <TData = Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError = unknown>(matchId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData>>, request?: SecondParameter<typeof defaultMutator>}
) => {

const {query: queryOptions, request: requestOptions} = options ?? {};

const queryKey = queryOptions?.queryKey ?? getMatchScoreControllerFindAllQueryKey(matchId);



const queryFn: QueryFunction<Awaited<ReturnType<typeof matchScoreControllerFindAll>>> = ({ signal }) => matchScoreControllerFindAll(matchId, { signal, ...requestOptions });





return { queryKey, queryFn, enabled: !!(matchId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
}

export type MatchScoreControllerFindAllQueryResult = NonNullable<Awaited<ReturnType<typeof matchScoreControllerFindAll>>>
export type MatchScoreControllerFindAllQueryError = unknown


export function useMatchScoreControllerFindAll<TData = Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError = unknown>(
matchId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData>> & Pick<
DefinedInitialDataOptions<
Awaited<ReturnType<typeof matchScoreControllerFindAll>>,
TError,
Awaited<ReturnType<typeof matchScoreControllerFindAll>>
> , 'initialData'
>, request?: SecondParameter<typeof defaultMutator>}
, queryClient?: QueryClient
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useMatchScoreControllerFindAll<TData = Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError = unknown>(
matchId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData>> & Pick<
UndefinedInitialDataOptions<
Awaited<ReturnType<typeof matchScoreControllerFindAll>>,
TError,
Awaited<ReturnType<typeof matchScoreControllerFindAll>>
> , 'initialData'
>, request?: SecondParameter<typeof defaultMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
export function useMatchScoreControllerFindAll<TData = Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError = unknown>(
matchId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData>>, request?: SecondParameter<typeof defaultMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
/**
* @summary Get all scores of a match
*/

export function useMatchScoreControllerFindAll<TData = Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError = unknown>(
matchId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof matchScoreControllerFindAll>>, TError, TData>>, request?: SecondParameter<typeof defaultMutator>}
, queryClient?: QueryClient
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {

const queryOptions = getMatchScoreControllerFindAllQueryOptions(matchId,options)

const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };

return { ...query, queryKey: queryOptions.queryKey };
}




/**
* Creates or updates the score for a specific set. Match must be IN_PROGRESS. Set N can only be created after set N-1 exists.
* @summary Create or update a match score
*/
export type matchScoreControllerUpsertResponse200 = {
data: MatchScore
status: 200
}

export type matchScoreControllerUpsertResponse400 = {
data: void
status: 400
}

export type matchScoreControllerUpsertResponse404 = {
data: void
status: 404
}

export type matchScoreControllerUpsertResponseSuccess = (matchScoreControllerUpsertResponse200) & {
headers: Headers;
};
export type matchScoreControllerUpsertResponseError = (matchScoreControllerUpsertResponse400 | matchScoreControllerUpsertResponse404) & {
headers: Headers;
};

export type matchScoreControllerUpsertResponse = (matchScoreControllerUpsertResponseSuccess | matchScoreControllerUpsertResponseError)

export const getMatchScoreControllerUpsertUrl = (matchId: string,
setNumber: number,) => {




return `/matches/${matchId}/scores/${setNumber}`
}

export const matchScoreControllerUpsert = async (matchId: string,
setNumber: number,
upsertMatchScoreDto: UpsertMatchScoreDto, options?: RequestInit): Promise<matchScoreControllerUpsertResponse> => {

return defaultMutator<matchScoreControllerUpsertResponse>(getMatchScoreControllerUpsertUrl(matchId,setNumber),
{
...options,
method: 'PUT',
headers: { 'Content-Type': 'application/json', ...options?.headers },
body: JSON.stringify(
upsertMatchScoreDto,)
}
);}




export const getMatchScoreControllerUpsertMutationOptions = <TError = void,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof matchScoreControllerUpsert>>, TError,{matchId: string;setNumber: number;data: UpsertMatchScoreDto}, TContext>, request?: SecondParameter<typeof defaultMutator>}
): UseMutationOptions<Awaited<ReturnType<typeof matchScoreControllerUpsert>>, TError,{matchId: string;setNumber: number;data: UpsertMatchScoreDto}, TContext> => {

const mutationKey = ['matchScoreControllerUpsert'];
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 matchScoreControllerUpsert>>, {matchId: string;setNumber: number;data: UpsertMatchScoreDto}> = (props) => {
const {matchId,setNumber,data} = props ?? {};

return matchScoreControllerUpsert(matchId,setNumber,data,requestOptions)
}






return { mutationFn, ...mutationOptions }}

export type MatchScoreControllerUpsertMutationResult = NonNullable<Awaited<ReturnType<typeof matchScoreControllerUpsert>>>
export type MatchScoreControllerUpsertMutationBody = UpsertMatchScoreDto
export type MatchScoreControllerUpsertMutationError = void

/**
* @summary Create or update a match score
*/
export const useMatchScoreControllerUpsert = <TError = void,
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof matchScoreControllerUpsert>>, TError,{matchId: string;setNumber: number;data: UpsertMatchScoreDto}, TContext>, request?: SecondParameter<typeof defaultMutator>}
, queryClient?: QueryClient): UseMutationResult<
Awaited<ReturnType<typeof matchScoreControllerUpsert>>,
TError,
{matchId: string;setNumber: number;data: UpsertMatchScoreDto},
TContext
> => {
return useMutation(getMatchScoreControllerUpsertMutationOptions(options), queryClient);
}