사용자 계정 관리 기능 구현 및 API 오류 수정
- 사용자 로그인 인증정보 관리 기능 구현 (이메일/휴대폰 추가/삭제) - 사용자 추가 기능 구현 (실시간 ID 중복 검증 포함) - 사용자 목록 조회 기능 구현 - API 엔드포인트 오류 수정 (userExistsUserid: GET → POST, URL 경로 수정) - TypeScript 타입 오류 수정 (UseQueryOptions, UserCreateParams/Response) - 이메일/휴대폰 형식 검증 및 중복 방지 로직 추가 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,24 +1,50 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '@/shared/api/urls';
|
||||
import { resultify } from '@/shared/lib/resultify';
|
||||
import { API_URL_USER } from '@/shared/api/api-url-user';
|
||||
import { CBDCAxiosError } from '@/shared/@types/error';
|
||||
import {
|
||||
import {
|
||||
UserCreateParams,
|
||||
UserCreateResponse
|
||||
} from '../model/types';
|
||||
import {
|
||||
|
||||
interface UserCreateMutationResponse {
|
||||
status: boolean;
|
||||
data?: UserCreateResponse;
|
||||
error?: {
|
||||
root: string;
|
||||
errKey: string;
|
||||
code: string;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
details: Record<string, string>;
|
||||
};
|
||||
}
|
||||
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions
|
||||
} from '@tanstack/react-query';
|
||||
|
||||
export const userCreate = (params: UserCreateParams) => {
|
||||
return resultify(
|
||||
axios.post<UserCreateResponse>(API_URL.userCreate(), params),
|
||||
);
|
||||
export const userCreate = async (params: UserCreateParams): Promise<UserCreateMutationResponse> => {
|
||||
try {
|
||||
const response = await axios.post<UserCreateResponse>(API_URL_USER.userCreate(), params);
|
||||
return { status: true, data: response.data };
|
||||
} catch (error: any) {
|
||||
return {
|
||||
status: false,
|
||||
error: {
|
||||
root: 'USER_CREATE',
|
||||
errKey: error.response?.data?.errKey || 'UNKNOWN_ERROR',
|
||||
code: error.response?.status?.toString() || '500',
|
||||
message: error.response?.data?.message || error.message || 'Unknown error',
|
||||
timestamp: new Date().toISOString(),
|
||||
details: error.response?.data?.details || {}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export const useUserCreateMutation = (options?: UseMutationOptions<UserCreateResponse, CBDCAxiosError, UserCreateParams>) => {
|
||||
const mutation = useMutation<UserCreateResponse, CBDCAxiosError, UserCreateParams>({
|
||||
export const useUserCreateMutation = (options?: UseMutationOptions<UserCreateMutationResponse, CBDCAxiosError, UserCreateParams>) => {
|
||||
const mutation = useMutation<UserCreateMutationResponse, CBDCAxiosError, UserCreateParams>({
|
||||
...options,
|
||||
mutationFn: (params: UserCreateParams) => userCreate(params),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user