콘솔에 발급된 설정이 설계와 어긋나 있었다. 클라이언트 시크릿이 켜져 있고 Redirect URI 가
프론트 경로(/auth/kakao/callback)인데, 코드는 "프론트가 액세스 토큰을 들고 온다" 는
전제였다 — 시크릿을 번들에 구울 수 없으므로 그 흐름으로는 토큰을 받을 수 없다.
- services/external/kakao_identity: access_token 검증 → **인가 코드 교환**으로 교체.
★ 우리 REST 키·시크릿으로 교환한 토큰이라 정의상 우리 앱 것이다 — 구글의 aud 대조에
해당하는 검사(KAKAO_LOGIN_APP_ID)가 구조적으로 필요 없어져 설정 칸째로 지웠다.
★ 로그인 앱과 챗봇 앱이 다르면 로그인은 되는데 채널 매칭만 조용히 안 된다 —
REST 키가 어긋나면 경고 로그를 남긴다.
★ 미인증 이메일은 신원으로 쓰지 않는다(is_email_valid·is_email_verified 둘 다). 이 값으로
auth_service 가 다른 수단 가입과의 충돌을 판정한다.
- config/config_models: KAKAO_LOGIN_APP_ID → REST_API_KEY · CLIENT_SECRET · REDIRECT_URI
- router/v1/auth: Req_KakaoLogin {access_token} → {code, redirect_uri}
- frontend: lib/kakaoIdentity(인가 URL · sessionStorage state) · KakaoSignInButton ·
pages/KakaoCallbackPage(코드는 1회용이라 ref 로 한 번만 보낸다) · routes
★ 로그인 폼에서 카카오를 구글 위에 둔다 — 이 수단으로 들어와야 6자리 코드 없이 채널이 이어진다
- compose · nginx/Dockerfile: REST 키·Redirect URI 만 프론트로 흘려보낸다. 시크릿은 안 나간다
- 어드민 키는 저장하지 않는다 — 탈퇴까지 되는 키인데 로그인에는 쓰이지 않는다
- api/generated: orval 재생성. 카카오 외에도 오래 밀려 있던 문구·agent 경로가 함께 따라왔다
테스트 8건 추가(tests/test_kakao_identity.py), 관련 85 passed
(test_auth::test_google_login_is_off_when_client_id_is_empty 는 기존 실패)
lint(react-router typegen + tsc + eslint) 통과
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
697 lines
18 KiB
TypeScript
697 lines
18 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Web4Ai API
|
|
* 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,
|
|
ReqGoogleLogin,
|
|
ReqKakaoLogin,
|
|
ReqLogin,
|
|
ReqSignup,
|
|
ReqUpdateMe,
|
|
ResLogin,
|
|
ResMe,
|
|
ResRefreshToken,
|
|
} from ".././model";
|
|
|
|
import { customFetch } from "../../mutator/custom-fetch";
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
/**
|
|
* id/pw 로 로그인하고 JWT 토큰을 발급한다.
|
|
* @summary 로그인
|
|
*/
|
|
export const login = (
|
|
reqLogin: ReqLogin,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLogin>(
|
|
{
|
|
url: `/v1/auth/login`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqLogin,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getLoginMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof login>>,
|
|
TError,
|
|
{ data: ReqLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof login>>,
|
|
TError,
|
|
{ data: ReqLogin },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["login"];
|
|
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 login>>,
|
|
{ data: ReqLogin }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return login(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type LoginMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof login>>
|
|
>;
|
|
export type LoginMutationBody = ReqLogin;
|
|
export type LoginMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 로그인
|
|
*/
|
|
export const useLogin = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof login>>,
|
|
TError,
|
|
{ data: ReqLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof login>>,
|
|
TError,
|
|
{ data: ReqLogin },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getLoginMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* id/pw 로 가입한다. 회사(테넌트) 1개가 함께 생기고, 성공하면 곧바로 로그인 토큰을 발급한다.
|
|
* @summary 회원가입
|
|
*/
|
|
export const signup = (
|
|
reqSignup: ReqSignup,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLogin>(
|
|
{
|
|
url: `/v1/auth/signup`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqSignup,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSignupMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof signup>>,
|
|
TError,
|
|
{ data: ReqSignup },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof signup>>,
|
|
TError,
|
|
{ data: ReqSignup },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["signup"];
|
|
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 signup>>,
|
|
{ data: ReqSignup }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return signup(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SignupMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof signup>>
|
|
>;
|
|
export type SignupMutationBody = ReqSignup;
|
|
export type SignupMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 회원가입
|
|
*/
|
|
export const useSignup = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof signup>>,
|
|
TError,
|
|
{ data: ReqSignup },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof signup>>,
|
|
TError,
|
|
{ data: ReqSignup },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSignupMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 구글 ID 토큰(GIS credential)을 검증하고 JWT 토큰을 발급한다. 처음 온 계정은 그 자리에서 만든다.
|
|
* @summary 구글 로그인
|
|
*/
|
|
export const googleLogin = (
|
|
reqGoogleLogin: ReqGoogleLogin,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLogin>(
|
|
{
|
|
url: `/v1/auth/google`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqGoogleLogin,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGoogleLoginMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof googleLogin>>,
|
|
TError,
|
|
{ data: ReqGoogleLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof googleLogin>>,
|
|
TError,
|
|
{ data: ReqGoogleLogin },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["googleLogin"];
|
|
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 googleLogin>>,
|
|
{ data: ReqGoogleLogin }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return googleLogin(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type GoogleLoginMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof googleLogin>>
|
|
>;
|
|
export type GoogleLoginMutationBody = ReqGoogleLogin;
|
|
export type GoogleLoginMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 구글 로그인
|
|
*/
|
|
export const useGoogleLogin = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof googleLogin>>,
|
|
TError,
|
|
{ data: ReqGoogleLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof googleLogin>>,
|
|
TError,
|
|
{ data: ReqGoogleLogin },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getGoogleLoginMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 카카오 **인가 코드**를 서버가 토큰으로 교환해 신원을 확인하고 JWT 를 발급한다. 처음 온 계정은 그 자리에서 만든다. ★ 코드는 1회용이라 같은 값으로 두 번 부르면 실패한다. ★ 챗봇에 물린 앱과 같은 앱이어야 한다 — 회원번호가 챗봇 웹훅의 appUserId 와 같은 값이라, 그래야 카톡 채널 발화자와 이 계정이 자동으로 이어진다(docs/AGENT.md).
|
|
* @summary 카카오 로그인
|
|
*/
|
|
export const kakaoLogin = (
|
|
reqKakaoLogin: ReqKakaoLogin,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResLogin>(
|
|
{
|
|
url: `/v1/auth/kakao`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqKakaoLogin,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getKakaoLoginMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof kakaoLogin>>,
|
|
TError,
|
|
{ data: ReqKakaoLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof kakaoLogin>>,
|
|
TError,
|
|
{ data: ReqKakaoLogin },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["kakaoLogin"];
|
|
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 kakaoLogin>>,
|
|
{ data: ReqKakaoLogin }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return kakaoLogin(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type KakaoLoginMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof kakaoLogin>>
|
|
>;
|
|
export type KakaoLoginMutationBody = ReqKakaoLogin;
|
|
export type KakaoLoginMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 카카오 로그인
|
|
*/
|
|
export const useKakaoLogin = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof kakaoLogin>>,
|
|
TError,
|
|
{ data: ReqKakaoLogin },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof kakaoLogin>>,
|
|
TError,
|
|
{ data: ReqKakaoLogin },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getKakaoLoginMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* refresh 토큰으로 access 토큰을 재발급한다.
|
|
* @summary 액세스 토큰 갱신
|
|
*/
|
|
export const refreshToken = (
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResRefreshToken>(
|
|
{ url: `/v1/auth/refresh_token`, method: "POST", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getRefreshTokenMutationOptions = <
|
|
TError = void,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof refreshToken>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof refreshToken>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["refreshToken"];
|
|
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 refreshToken>>,
|
|
void
|
|
> = () => {
|
|
return refreshToken(requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type RefreshTokenMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof refreshToken>>
|
|
>;
|
|
|
|
export type RefreshTokenMutationError = void;
|
|
|
|
/**
|
|
* @summary 액세스 토큰 갱신
|
|
*/
|
|
export const useRefreshToken = <TError = void, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof refreshToken>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof refreshToken>>,
|
|
TError,
|
|
void,
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getRefreshTokenMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 유효한 access 토큰이 있어야 호출 가능. 토큰의 유저+회사 정보를 반환한다.
|
|
* @summary 내 정보
|
|
*/
|
|
export const me = (
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResMe>(
|
|
{ url: `/v1/auth/me`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getMeQueryKey = () => {
|
|
return [`/v1/auth/me`] as const;
|
|
};
|
|
|
|
export const getMeQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof me>>,
|
|
TError = void,
|
|
>(options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getMeQueryKey();
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof me>>> = ({ signal }) =>
|
|
me(requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof me>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type MeQueryResult = NonNullable<Awaited<ReturnType<typeof me>>>;
|
|
export type MeQueryError = void;
|
|
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof me>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof me>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof me>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof me>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 내 정보
|
|
*/
|
|
|
|
export function useMe<TData = Awaited<ReturnType<typeof me>>, TError = void>(
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof me>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getMeQueryOptions(options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 본인 이름/이메일/연락처/비밀번호를 수정한다(권한·소속·ID 변경 불가).
|
|
* @summary 내 정보 수정
|
|
*/
|
|
export const updateMe = (
|
|
reqUpdateMe: ReqUpdateMe,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
) => {
|
|
return customFetch<ResMe>(
|
|
{
|
|
url: `/v1/auth/me`,
|
|
method: "PATCH",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqUpdateMe,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getUpdateMeMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMe>>,
|
|
TError,
|
|
{ data: ReqUpdateMe },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMe>>,
|
|
TError,
|
|
{ data: ReqUpdateMe },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["updateMe"];
|
|
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 updateMe>>,
|
|
{ data: ReqUpdateMe }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return updateMe(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type UpdateMeMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof updateMe>>
|
|
>;
|
|
export type UpdateMeMutationBody = ReqUpdateMe;
|
|
export type UpdateMeMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 내 정보 수정
|
|
*/
|
|
export const useUpdateMe = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof updateMe>>,
|
|
TError,
|
|
{ data: ReqUpdateMe },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof updateMe>>,
|
|
TError,
|
|
{ data: ReqUpdateMe },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getUpdateMeMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|