diff --git a/src/lib/schemas/campaignPublicResponseDto.ts b/src/lib/schemas/campaignPublicResponseDto.ts index d367e21..009bcbb 100644 --- a/src/lib/schemas/campaignPublicResponseDto.ts +++ b/src/lib/schemas/campaignPublicResponseDto.ts @@ -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 */ diff --git a/src/lib/schemas/index.ts b/src/lib/schemas/index.ts index 31cb8dd..5b6d43b 100644 --- a/src/lib/schemas/index.ts +++ b/src/lib/schemas/index.ts @@ -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'; diff --git a/src/lib/schemas/upsertMatchScoreDto.ts b/src/lib/schemas/upsertMatchScoreDto.ts new file mode 100644 index 0000000..10ef74b --- /dev/null +++ b/src/lib/schemas/upsertMatchScoreDto.ts @@ -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; +} diff --git a/src/lib/schemas/upsertMatchScoreDtoDetails.ts b/src/lib/schemas/upsertMatchScoreDtoDetails.ts new file mode 100644 index 0000000..86e719c --- /dev/null +++ b/src/lib/schemas/upsertMatchScoreDtoDetails.ts @@ -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 }; diff --git a/src/lib/services/match-scores/match-scores.ts b/src/lib/services/match-scores/match-scores.ts new file mode 100644 index 0000000..41f03da --- /dev/null +++ b/src/lib/services/match-scores/match-scores.ts @@ -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 unknown> = Parameters[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 => { + + return defaultMutator(getMatchScoreControllerFindAllUrl(matchId), + { + ...options, + method: 'GET' + + + } +);} + + + + + +export const getMatchScoreControllerFindAllQueryKey = (matchId: string,) => { + return [ + `/matches/${matchId}/scores` + ] as const; + } + + +export const getMatchScoreControllerFindAllQueryOptions = >, TError = unknown>(matchId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} +) => { + +const {query: queryOptions, request: requestOptions} = options ?? {}; + + const queryKey = queryOptions?.queryKey ?? getMatchScoreControllerFindAllQueryKey(matchId); + + + + const queryFn: QueryFunction>> = ({ signal }) => matchScoreControllerFindAll(matchId, { signal, ...requestOptions }); + + + + + + return { queryKey, queryFn, enabled: !!(matchId), ...queryOptions} as UseQueryOptions>, TError, TData> & { queryKey: DataTag } +} + +export type MatchScoreControllerFindAllQueryResult = NonNullable>> +export type MatchScoreControllerFindAllQueryError = unknown + + +export function useMatchScoreControllerFindAll>, TError = unknown>( + matchId: string, options: { query:Partial>, TError, TData>> & Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): DefinedUseQueryResult & { queryKey: DataTag } +export function useMatchScoreControllerFindAll>, TError = unknown>( + matchId: string, options?: { query?:Partial>, TError, TData>> & Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + > , 'initialData' + >, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +export function useMatchScoreControllerFindAll>, TError = unknown>( + matchId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } +/** + * @summary Get all scores of a match + */ + +export function useMatchScoreControllerFindAll>, TError = unknown>( + matchId: string, options?: { query?:Partial>, TError, TData>>, request?: SecondParameter} + , queryClient?: QueryClient + ): UseQueryResult & { queryKey: DataTag } { + + const queryOptions = getMatchScoreControllerFindAllQueryOptions(matchId,options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { queryKey: DataTag }; + + 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 => { + + return defaultMutator(getMatchScoreControllerUpsertUrl(matchId,setNumber), + { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify( + upsertMatchScoreDto,) + } +);} + + + + +export const getMatchScoreControllerUpsertMutationOptions = (options?: { mutation?:UseMutationOptions>, TError,{matchId: string;setNumber: number;data: UpsertMatchScoreDto}, TContext>, request?: SecondParameter} +): UseMutationOptions>, 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>, {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>> + export type MatchScoreControllerUpsertMutationBody = UpsertMatchScoreDto + export type MatchScoreControllerUpsertMutationError = void + + /** + * @summary Create or update a match score + */ +export const useMatchScoreControllerUpsert = (options?: { mutation?:UseMutationOptions>, TError,{matchId: string;setNumber: number;data: UpsertMatchScoreDto}, TContext>, request?: SecondParameter} + , queryClient?: QueryClient): UseMutationResult< + Awaited>, + TError, + {matchId: string;setNumber: number;data: UpsertMatchScoreDto}, + TContext + > => { + return useMutation(getMatchScoreControllerUpsertMutationOptions(options), queryClient); + } + \ No newline at end of file