diff --git a/apps/web/src/api/endpoints.schemas.ts b/apps/web/src/api/endpoints.schemas.ts index bf560ad4..eca6e77a 100644 --- a/apps/web/src/api/endpoints.schemas.ts +++ b/apps/web/src/api/endpoints.schemas.ts @@ -26,7 +26,6 @@ export type PostUsersCreate201User = { username: string; email: string; createdAt?: string; - subscriptionType?: PostUsersCreate201UserSubscriptionType; /** @nullable */ bannerUrl?: string | null; /** @nullable */ @@ -35,6 +34,7 @@ export type PostUsersCreate201User = { isLegacy?: boolean | null; /** @nullable */ biography?: string | null; + subscriptionType: PostUsersCreate201UserSubscriptionType; }; /** @@ -102,7 +102,6 @@ export type GetUsersUsername200User = { username: string; email: string; createdAt: string; - subscriptionType: GetUsersUsername200UserSubscriptionType; /** @nullable */ bannerUrl: string | null; /** @nullable */ @@ -111,56 +110,40 @@ export type GetUsersUsername200User = { isLegacy: boolean | null; /** @nullable */ biography: string | null; + subscriptionType: GetUsersUsername200UserSubscriptionType; }; export type GetUsersUsername200 = { user: GetUsersUsername200User; }; -export type GetUserById201UserSubscriptionType = typeof GetUserById201UserSubscriptionType[keyof typeof GetUserById201UserSubscriptionType]; +export type GetUserById200UserSubscriptionType = typeof GetUserById200UserSubscriptionType[keyof typeof GetUserById200UserSubscriptionType]; // eslint-disable-next-line @typescript-eslint/no-redeclare -export const GetUserById201UserSubscriptionType = { +export const GetUserById200UserSubscriptionType = { MEMBER: 'MEMBER', PRO: 'PRO', } as const; -export type GetUserById201User = { - id?: string; +export type GetUserById200User = { + id: string; username: string; email: string; - createdAt?: string; - subscriptionType?: GetUserById201UserSubscriptionType; + createdAt: string; /** @nullable */ - bannerUrl?: string | null; + bannerUrl: string | null; /** @nullable */ - avatarUrl?: string | null; + avatarUrl: string | null; /** @nullable */ - isLegacy?: boolean | null; + isLegacy: boolean | null; /** @nullable */ - biography?: string | null; -}; - -/** - * User created. - */ -export type GetUserById201 = { - user: GetUserById201User; -}; - -/** - * Email or username is already registered. - */ -export type GetUserById409 = { - message: string; + biography: string | null; + subscriptionType: GetUserById200UserSubscriptionType; }; -/** - * Fail to hash password. - */ -export type GetUserById500 = { - message: string; +export type GetUserById200 = { + user: GetUserById200User; }; export type GetMe200UserSubscriptionType = typeof GetMe200UserSubscriptionType[keyof typeof GetMe200UserSubscriptionType]; @@ -177,7 +160,6 @@ export type GetMe200User = { username: string; email: string; createdAt: string; - subscriptionType: GetMe200UserSubscriptionType; /** @nullable */ bannerUrl: string | null; /** @nullable */ @@ -186,6 +168,7 @@ export type GetMe200User = { isLegacy: boolean | null; /** @nullable */ biography: string | null; + subscriptionType: GetMe200UserSubscriptionType; }; export type GetMe200 = { @@ -199,21 +182,11 @@ export type PatchUserBody = { biography?: string; }; -export type PatchUser200UserSubscriptionType = typeof PatchUser200UserSubscriptionType[keyof typeof PatchUser200UserSubscriptionType]; - - -// eslint-disable-next-line @typescript-eslint/no-redeclare -export const PatchUser200UserSubscriptionType = { - MEMBER: 'MEMBER', - PRO: 'PRO', -} as const; - export type PatchUser200User = { id: string; username: string; email: string; createdAt: string; - subscriptionType: PatchUser200UserSubscriptionType; /** @nullable */ bannerUrl: string | null; /** @nullable */ @@ -1931,8 +1904,8 @@ export type GetFollowers200FollowersItemSubscriptionType = typeof GetFollowers20 // eslint-disable-next-line @typescript-eslint/no-redeclare export const GetFollowers200FollowersItemSubscriptionType = { - MEMBER: 'MEMBER', PRO: 'PRO', + MEMBER: 'MEMBER', } as const; export type GetFollowers200FollowersItem = { diff --git a/apps/web/src/api/users.ts b/apps/web/src/api/users.ts index 45d9f925..dbeae50c 100644 --- a/apps/web/src/api/users.ts +++ b/apps/web/src/api/users.ts @@ -26,9 +26,7 @@ import type { } from '@tanstack/react-query' import type { GetMe200, - GetUserById201, - GetUserById409, - GetUserById500, + GetUserById200, GetUserPreferences200, GetUsersAvailableEmail200, GetUsersAvailableEmail409, @@ -532,7 +530,7 @@ export const getUserById = ( ) => { - return axiosInstance( + return axiosInstance( {url: `/user/by/${id}`, method: 'GET', signal }, ); @@ -544,7 +542,7 @@ export const getGetUserByIdQueryKey = (id: string,) => { } -export const getGetUserByIdQueryOptions = >, TError = GetUserById409 | GetUserById500>(id: string, options?: { query?:Partial>, TError, TData>>, } +export const getGetUserByIdQueryOptions = >, TError = unknown>(id: string, options?: { query?:Partial>, TError, TData>>, } ) => { const {query: queryOptions} = options ?? {}; @@ -563,10 +561,10 @@ const {query: queryOptions} = options ?? {}; } export type GetUserByIdQueryResult = NonNullable>> -export type GetUserByIdQueryError = GetUserById409 | GetUserById500 +export type GetUserByIdQueryError = unknown -export function useGetUserById>, TError = GetUserById409 | GetUserById500>( +export function useGetUserById>, TError = unknown>( id: string, options: { query:Partial>, TError, TData>> & Pick< DefinedInitialDataOptions< Awaited>, @@ -576,7 +574,7 @@ export function useGetUserById>, >, } ): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetUserById>, TError = GetUserById409 | GetUserById500>( +export function useGetUserById>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>> & Pick< UndefinedInitialDataOptions< Awaited>, @@ -586,12 +584,12 @@ export function useGetUserById>, >, } ): UseQueryResult & { queryKey: DataTag } -export function useGetUserById>, TError = GetUserById409 | GetUserById500>( +export function useGetUserById>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>>, } ): UseQueryResult & { queryKey: DataTag } -export function useGetUserById>, TError = GetUserById409 | GetUserById500>( +export function useGetUserById>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>>, } ): UseQueryResult & { queryKey: DataTag } { @@ -607,7 +605,7 @@ export function useGetUserById>, -export const getGetUserByIdSuspenseQueryOptions = >, TError = GetUserById409 | GetUserById500>(id: string, options?: { query?:Partial>, TError, TData>>, } +export const getGetUserByIdSuspenseQueryOptions = >, TError = unknown>(id: string, options?: { query?:Partial>, TError, TData>>, } ) => { const {query: queryOptions} = options ?? {}; @@ -626,23 +624,23 @@ const {query: queryOptions} = options ?? {}; } export type GetUserByIdSuspenseQueryResult = NonNullable>> -export type GetUserByIdSuspenseQueryError = GetUserById409 | GetUserById500 +export type GetUserByIdSuspenseQueryError = unknown -export function useGetUserByIdSuspense>, TError = GetUserById409 | GetUserById500>( +export function useGetUserByIdSuspense>, TError = unknown>( id: string, options: { query:Partial>, TError, TData>>, } ): UseSuspenseQueryResult & { queryKey: DataTag } -export function useGetUserByIdSuspense>, TError = GetUserById409 | GetUserById500>( +export function useGetUserByIdSuspense>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>>, } ): UseSuspenseQueryResult & { queryKey: DataTag } -export function useGetUserByIdSuspense>, TError = GetUserById409 | GetUserById500>( +export function useGetUserByIdSuspense>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>>, } ): UseSuspenseQueryResult & { queryKey: DataTag } -export function useGetUserByIdSuspense>, TError = GetUserById409 | GetUserById500>( +export function useGetUserByIdSuspense>, TError = unknown>( id: string, options?: { query?:Partial>, TError, TData>>, } ): UseSuspenseQueryResult & { queryKey: DataTag } {