[feat] negodata: 협력사 채팅 계정(supplier_users) 관리 — 발급·비번 재설정·활성상태
- 백엔드: supplier_users/supplier_user_tokens ORM 매핑, /v1/supplier/{id}/account 4종(조회·발급·재설정·상태), 회사 스코프 게이팅, 재설정·비활성 시 토큰 삭제로 기존 로그인 즉시 무효화
- 비밀번호: 발급=서버 자동생성(1회 반환), 재설정=커스텀 지정 가능(미지정 시 자동생성)
- 프론트: 협력사 상세 SupplierAccountManager 섹션 + 목록 '채팅 계정' 컬럼, orval 재생성(SupplierType 은 enumLabels 로컬 상수로 이동)
- 테스트: test_supplier_account.py 9건, 전체 스위트 green
This commit is contained in:
1 parent
a80dac20ed
commit
7f1c0be2b3
37 files changed
+1385
-36
No files matched your search
@@ -162,6 +162,7 @@ export * from './reqCreateQuotationSetting';
|
||||
export * from './reqCreateQuotationStartTime';
|
||||
export * from './reqCreateQuotationVersionId';
|
||||
export * from './reqCreateSupplier';
|
||||
export * from './reqCreateSupplierAccount';
|
||||
export * from './reqCreateSupplierCode';
|
||||
export * from './reqCreateSupplierItem';
|
||||
export * from './reqCreateSupplierManagerContactNumber';
|
||||
@@ -170,6 +171,8 @@ export * from './reqCreateSupplierManagerName';
|
||||
export * from './reqCreateSupplierTotalRevenue';
|
||||
export * from './reqLogin';
|
||||
export * from './reqRegenerateQuotation';
|
||||
export * from './reqResetSupplierAccountPassword';
|
||||
export * from './reqResetSupplierAccountPasswordPassword';
|
||||
export * from './reqUpdateCard';
|
||||
export * from './reqUpdateCardCondition';
|
||||
export * from './reqUpdateCardEditScript';
|
||||
@@ -215,6 +218,7 @@ export * from './reqUpdateQuotationSetting';
|
||||
export * from './reqUpdateQuotationSettingCardCount';
|
||||
export * from './reqUpdateQuotationSettingTargetMarginRate';
|
||||
export * from './reqUpdateSupplier';
|
||||
export * from './reqUpdateSupplierAccountStatus';
|
||||
export * from './reqUpdateSupplierCode';
|
||||
export * from './reqUpdateSupplierManagerContactNumber';
|
||||
export * from './reqUpdateSupplierManagerEmail';
|
||||
@@ -239,6 +243,10 @@ export * from './resCompanyUserUser';
|
||||
export * from './resCreateQuotation';
|
||||
export * from './resCreateQuotationMsg';
|
||||
export * from './resCreateQuotationQtId';
|
||||
export * from './resCreateSupplierAccount';
|
||||
export * from './resCreateSupplierAccountAccount';
|
||||
export * from './resCreateSupplierAccountInitialPassword';
|
||||
export * from './resCreateSupplierAccountMsg';
|
||||
export * from './resDashboardSummary';
|
||||
export * from './resDashboardSummaryMsg';
|
||||
export * from './resDeleteCard';
|
||||
@@ -313,12 +321,18 @@ export * from './resQuotationStatusMsg';
|
||||
export * from './resQuotationStatusQtId';
|
||||
export * from './resRefreshToken';
|
||||
export * from './resRefreshTokenMsg';
|
||||
export * from './resResetSupplierAccountPassword';
|
||||
export * from './resResetSupplierAccountPasswordMsg';
|
||||
export * from './resResetSupplierAccountPasswordNewPassword';
|
||||
export * from './resSessionChat';
|
||||
export * from './resSessionChatMsg';
|
||||
export * from './resSessionChatSessionId';
|
||||
export * from './resStatisticsSummary';
|
||||
export * from './resStatisticsSummaryMsg';
|
||||
export * from './resSupplier';
|
||||
export * from './resSupplierAccount';
|
||||
export * from './resSupplierAccountAccount';
|
||||
export * from './resSupplierAccountMsg';
|
||||
export * from './resSupplierItem';
|
||||
export * from './resSupplierItemList';
|
||||
export * from './resSupplierItemListMsg';
|
||||
@@ -355,7 +369,11 @@ export * from './statOutcome';
|
||||
export * from './statParticipation';
|
||||
export * from './statScope';
|
||||
export * from './statTypeRow';
|
||||
export * from './supplierAccountData';
|
||||
export * from './supplierAccountDataCreatedAt';
|
||||
export * from './supplierData';
|
||||
export * from './supplierDataAccountLoginId';
|
||||
export * from './supplierDataAccountStatus';
|
||||
export * from './supplierDataCode';
|
||||
export * from './supplierDataCreatedAt';
|
||||
export * from './supplierDataCreatorName';
|
||||
@@ -368,10 +386,9 @@ export * from './supplierItemData';
|
||||
export * from './supplierItemDataCreatedAt';
|
||||
export * from './supplierItemDataItemCode';
|
||||
export * from './supplierItemDataUpdatedAt';
|
||||
export * from './supplierType';
|
||||
export * from './targetCandidate';
|
||||
export * from './userRole';
|
||||
export * from './userStatus';
|
||||
export * from './validationError';
|
||||
export * from './validationErrorCtx';
|
||||
export * from './validationErrorLocItem';
|
||||
export * from './validationErrorLocItem';
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ReqCreateSupplierAccount {
|
||||
login_id?: string;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ReqResetSupplierAccountPasswordPassword } from './reqResetSupplierAccountPasswordPassword';
|
||||
|
||||
export interface ReqResetSupplierAccountPassword {
|
||||
password?: ReqResetSupplierAccountPasswordPassword;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ReqResetSupplierAccountPasswordPassword = string | null;
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ReqUpdateSupplierAccountStatus {
|
||||
status?: number;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ErrorInfo } from './errorInfo';
|
||||
import type { ResCreateSupplierAccountMsg } from './resCreateSupplierAccountMsg';
|
||||
import type { ResCreateSupplierAccountAccount } from './resCreateSupplierAccountAccount';
|
||||
import type { ResCreateSupplierAccountInitialPassword } from './resCreateSupplierAccountInitialPassword';
|
||||
|
||||
export interface ResCreateSupplierAccount {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResCreateSupplierAccountMsg;
|
||||
account?: ResCreateSupplierAccountAccount;
|
||||
initial_password?: ResCreateSupplierAccountInitialPassword;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { SupplierAccountData } from './supplierAccountData';
|
||||
|
||||
export type ResCreateSupplierAccountAccount = SupplierAccountData | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResCreateSupplierAccountInitialPassword = string | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResCreateSupplierAccountMsg = string | null;
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ErrorInfo } from './errorInfo';
|
||||
import type { ResResetSupplierAccountPasswordMsg } from './resResetSupplierAccountPasswordMsg';
|
||||
import type { ResResetSupplierAccountPasswordNewPassword } from './resResetSupplierAccountPasswordNewPassword';
|
||||
|
||||
export interface ResResetSupplierAccountPassword {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResResetSupplierAccountPasswordMsg;
|
||||
new_password?: ResResetSupplierAccountPasswordNewPassword;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResResetSupplierAccountPasswordMsg = string | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResResetSupplierAccountPasswordNewPassword = string | null;
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { ErrorInfo } from './errorInfo';
|
||||
import type { ResSupplierAccountMsg } from './resSupplierAccountMsg';
|
||||
import type { ResSupplierAccountAccount } from './resSupplierAccountAccount';
|
||||
|
||||
export interface ResSupplierAccount {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResSupplierAccountMsg;
|
||||
account?: ResSupplierAccountAccount;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { SupplierAccountData } from './supplierAccountData';
|
||||
|
||||
export type ResSupplierAccountAccount = SupplierAccountData | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ResSupplierAccountMsg = string | null;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { SupplierAccountDataCreatedAt } from './supplierAccountDataCreatedAt';
|
||||
|
||||
export interface SupplierAccountData {
|
||||
su_id: string;
|
||||
login_id: string;
|
||||
status: number;
|
||||
created_at?: SupplierAccountDataCreatedAt;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type SupplierAccountDataCreatedAt = string | null;
|
||||
@@ -10,6 +10,8 @@ import type { SupplierDataManagerName } from './supplierDataManagerName';
|
||||
import type { SupplierDataManagerEmail } from './supplierDataManagerEmail';
|
||||
import type { SupplierDataManagerContactNumber } from './supplierDataManagerContactNumber';
|
||||
import type { SupplierDataTotalRevenue } from './supplierDataTotalRevenue';
|
||||
import type { SupplierDataAccountLoginId } from './supplierDataAccountLoginId';
|
||||
import type { SupplierDataAccountStatus } from './supplierDataAccountStatus';
|
||||
import type { SupplierDataCreatedAt } from './supplierDataCreatedAt';
|
||||
import type { SupplierDataUpdatedAt } from './supplierDataUpdatedAt';
|
||||
|
||||
@@ -24,6 +26,8 @@ export interface SupplierData {
|
||||
manager_email?: SupplierDataManagerEmail;
|
||||
manager_contact_number?: SupplierDataManagerContactNumber;
|
||||
total_revenue?: SupplierDataTotalRevenue;
|
||||
account_login_id?: SupplierDataAccountLoginId;
|
||||
account_status?: SupplierDataAccountStatus;
|
||||
created_at?: SupplierDataCreatedAt;
|
||||
updated_at?: SupplierDataUpdatedAt;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type SupplierDataAccountLoginId = string | null;
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type SupplierDataAccountStatus = number | null;
|
||||
@@ -1,21 +0,0 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* partner.supplier_items.supply_type 코드값. 없음(0,미지정)/유통(1)/제조(2)/총판(3).
|
||||
없음은 상품-협력사 매핑에서 유형 미지정 상태를 뜻한다.
|
||||
*/
|
||||
export type SupplierType = typeof SupplierType[keyof typeof SupplierType];
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
export const SupplierType = {
|
||||
NONE: 0,
|
||||
DISTRIBUTION: 1,
|
||||
MANUFACTURE: 2,
|
||||
SOLE_AGENCY: 3,
|
||||
} as const;
|
||||
@@ -1135,9 +1135,7 @@ export const useDeleteQuotation = <TError = void | HTTPValidationError,
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* @summary 견적 조회
|
||||
*/
|
||||
export const getQuotation = (
|
||||
@@ -1228,3 +1226,4 @@ export function useGetQuotation<TData = Awaited<ReturnType<typeof getQuotation>>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,10 +28,16 @@ import type {
|
||||
ListSuppliersParams,
|
||||
ReqCheckCodes,
|
||||
ReqCreateSupplier,
|
||||
ReqCreateSupplierAccount,
|
||||
ReqResetSupplierAccountPassword,
|
||||
ReqUpdateSupplier,
|
||||
ReqUpdateSupplierAccountStatus,
|
||||
ResCheckCodes,
|
||||
ResCreateSupplierAccount,
|
||||
ResDeleteSupplier,
|
||||
ResResetSupplierAccountPassword,
|
||||
ResSupplier,
|
||||
ResSupplierAccount,
|
||||
ResSupplierList
|
||||
} from '.././model';
|
||||
|
||||
@@ -420,7 +426,7 @@ export const useUpdateSupplier = <TError = void | HTTPValidationError,
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 협력사 삭제
|
||||
* @summary 협력사 삭제 (최고관리자 전용)
|
||||
*/
|
||||
export const deleteSupplier = (
|
||||
supplierId: string,
|
||||
@@ -465,7 +471,7 @@ const {mutation: mutationOptions, request: requestOptions} = options ?
|
||||
export type DeleteSupplierMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 협력사 삭제
|
||||
* @summary 협력사 삭제 (최고관리자 전용)
|
||||
*/
|
||||
export const useDeleteSupplier = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof deleteSupplier>>, TError,{supplierId: string}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
@@ -480,4 +486,290 @@ export const useDeleteSupplier = <TError = void | HTTPValidationError,
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 채팅 계정 조회 (미발급이면 account=null)
|
||||
*/
|
||||
export const getSupplierAccount = (
|
||||
supplierId: string,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResSupplierAccount>(
|
||||
{url: `/v1/supplier/${supplierId}/account`, method: 'GET', signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const getGetSupplierAccountQueryKey = (supplierId?: string,) => {
|
||||
return [
|
||||
`/v1/supplier/${supplierId}/account`
|
||||
] as const;
|
||||
}
|
||||
|
||||
|
||||
export const getGetSupplierAccountQueryOptions = <TData = Awaited<ReturnType<typeof getSupplierAccount>>, TError = void | HTTPValidationError>(supplierId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
) => {
|
||||
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryKey = queryOptions?.queryKey ?? getGetSupplierAccountQueryKey(supplierId);
|
||||
|
||||
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof getSupplierAccount>>> = ({ signal }) => getSupplierAccount(supplierId, requestOptions, signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return { queryKey, queryFn, enabled: !!(supplierId), ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
}
|
||||
|
||||
export type GetSupplierAccountQueryResult = NonNullable<Awaited<ReturnType<typeof getSupplierAccount>>>
|
||||
export type GetSupplierAccountQueryError = void | HTTPValidationError
|
||||
|
||||
|
||||
export function useGetSupplierAccount<TData = Awaited<ReturnType<typeof getSupplierAccount>>, TError = void | HTTPValidationError>(
|
||||
supplierId: string, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData>> & Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getSupplierAccount>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getSupplierAccount>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useGetSupplierAccount<TData = Awaited<ReturnType<typeof getSupplierAccount>>, TError = void | HTTPValidationError>(
|
||||
supplierId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData>> & Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof getSupplierAccount>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof getSupplierAccount>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useGetSupplierAccount<TData = Awaited<ReturnType<typeof getSupplierAccount>>, TError = void | HTTPValidationError>(
|
||||
supplierId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
/**
|
||||
* @summary 채팅 계정 조회 (미발급이면 account=null)
|
||||
*/
|
||||
|
||||
export function useGetSupplierAccount<TData = Awaited<ReturnType<typeof getSupplierAccount>>, TError = void | HTTPValidationError>(
|
||||
supplierId: string, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof getSupplierAccount>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
||||
|
||||
const queryOptions = getGetSupplierAccountQueryOptions(supplierId,options)
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @summary 채팅 계정 발급 (비밀번호 자동생성·1회 반환)
|
||||
*/
|
||||
export const createSupplierAccount = (
|
||||
supplierId: string,
|
||||
reqCreateSupplierAccount: ReqCreateSupplierAccount,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResCreateSupplierAccount>(
|
||||
{url: `/v1/supplier/${supplierId}/account/create`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqCreateSupplierAccount, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getCreateSupplierAccountMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSupplierAccount>>, TError,{supplierId: string;data: ReqCreateSupplierAccount}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof createSupplierAccount>>, TError,{supplierId: string;data: ReqCreateSupplierAccount}, TContext> => {
|
||||
|
||||
const mutationKey = ['createSupplierAccount'];
|
||||
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 createSupplierAccount>>, {supplierId: string;data: ReqCreateSupplierAccount}> = (props) => {
|
||||
const {supplierId,data} = props ?? {};
|
||||
|
||||
return createSupplierAccount(supplierId,data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type CreateSupplierAccountMutationResult = NonNullable<Awaited<ReturnType<typeof createSupplierAccount>>>
|
||||
export type CreateSupplierAccountMutationBody = ReqCreateSupplierAccount
|
||||
export type CreateSupplierAccountMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 채팅 계정 발급 (비밀번호 자동생성·1회 반환)
|
||||
*/
|
||||
export const useCreateSupplierAccount = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof createSupplierAccount>>, TError,{supplierId: string;data: ReqCreateSupplierAccount}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof createSupplierAccount>>,
|
||||
TError,
|
||||
{supplierId: string;data: ReqCreateSupplierAccount},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getCreateSupplierAccountMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 채팅 계정 비밀번호 재설정 (커스텀 지정 가능, 기존 로그인 즉시 무효화)
|
||||
*/
|
||||
export const resetSupplierAccountPassword = (
|
||||
supplierId: string,
|
||||
reqResetSupplierAccountPassword: ReqResetSupplierAccountPassword,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResResetSupplierAccountPassword>(
|
||||
{url: `/v1/supplier/${supplierId}/account/reset-password`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqResetSupplierAccountPassword, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getResetSupplierAccountPasswordMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof resetSupplierAccountPassword>>, TError,{supplierId: string;data: ReqResetSupplierAccountPassword}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof resetSupplierAccountPassword>>, TError,{supplierId: string;data: ReqResetSupplierAccountPassword}, TContext> => {
|
||||
|
||||
const mutationKey = ['resetSupplierAccountPassword'];
|
||||
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 resetSupplierAccountPassword>>, {supplierId: string;data: ReqResetSupplierAccountPassword}> = (props) => {
|
||||
const {supplierId,data} = props ?? {};
|
||||
|
||||
return resetSupplierAccountPassword(supplierId,data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type ResetSupplierAccountPasswordMutationResult = NonNullable<Awaited<ReturnType<typeof resetSupplierAccountPassword>>>
|
||||
export type ResetSupplierAccountPasswordMutationBody = ReqResetSupplierAccountPassword
|
||||
export type ResetSupplierAccountPasswordMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 채팅 계정 비밀번호 재설정 (커스텀 지정 가능, 기존 로그인 즉시 무효화)
|
||||
*/
|
||||
export const useResetSupplierAccountPassword = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof resetSupplierAccountPassword>>, TError,{supplierId: string;data: ReqResetSupplierAccountPassword}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof resetSupplierAccountPassword>>,
|
||||
TError,
|
||||
{supplierId: string;data: ReqResetSupplierAccountPassword},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getResetSupplierAccountPasswordMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 채팅 계정 활성/비활성 (비활성 시 기존 로그인 즉시 무효화)
|
||||
*/
|
||||
export const updateSupplierAccountStatus = (
|
||||
supplierId: string,
|
||||
reqUpdateSupplierAccountStatus: ReqUpdateSupplierAccountStatus,
|
||||
options?: SecondParameter<typeof customFetch>,) => {
|
||||
|
||||
|
||||
return customFetch<ResSupplierAccount>(
|
||||
{url: `/v1/supplier/${supplierId}/account/status`, method: 'PATCH',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqUpdateSupplierAccountStatus
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getUpdateSupplierAccountStatusMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateSupplierAccountStatus>>, TError,{supplierId: string;data: ReqUpdateSupplierAccountStatus}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof updateSupplierAccountStatus>>, TError,{supplierId: string;data: ReqUpdateSupplierAccountStatus}, TContext> => {
|
||||
|
||||
const mutationKey = ['updateSupplierAccountStatus'];
|
||||
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 updateSupplierAccountStatus>>, {supplierId: string;data: ReqUpdateSupplierAccountStatus}> = (props) => {
|
||||
const {supplierId,data} = props ?? {};
|
||||
|
||||
return updateSupplierAccountStatus(supplierId,data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type UpdateSupplierAccountStatusMutationResult = NonNullable<Awaited<ReturnType<typeof updateSupplierAccountStatus>>>
|
||||
export type UpdateSupplierAccountStatusMutationBody = ReqUpdateSupplierAccountStatus
|
||||
export type UpdateSupplierAccountStatusMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 채팅 계정 활성/비활성 (비활성 시 기존 로그인 즉시 무효화)
|
||||
*/
|
||||
export const useUpdateSupplierAccountStatus = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof updateSupplierAccountStatus>>, TError,{supplierId: string;data: ReqUpdateSupplierAccountStatus}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof updateSupplierAccountStatus>>,
|
||||
TError,
|
||||
{supplierId: string;data: ReqUpdateSupplierAccountStatus},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getUpdateSupplierAccountStatusMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import { PhoneInput } from '@/components/ui/phone-input';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { SupplierItemsManager } from './SupplierItemsManager';
|
||||
import { SupplierAccountManager } from './SupplierAccountManager';
|
||||
import { type Partner } from '../types';
|
||||
|
||||
const schema = z.object({
|
||||
@@ -215,6 +216,9 @@ export function PartnerFormSheet({
|
||||
{/* 취급상품 관리 — 수정 모드(협력사 확정)에서만. 추가/삭제/유형변경은 즉시 서버 반영. */}
|
||||
{mode === 'edit' && partner && <SupplierItemsManager supplierId={partner.supplier_id} />}
|
||||
|
||||
{/* 채팅 계정 관리 — 수정 모드에서만. 발급/재설정/활성상태는 즉시 서버 반영. */}
|
||||
{mode === 'edit' && partner && <SupplierAccountManager supplierId={partner.supplier_id} />}
|
||||
|
||||
{/* Buttons wrapper */}
|
||||
<div className="pt-4 flex items-center gap-2 border-t border-border mt-8 justify-between">
|
||||
{mode === 'edit' && partner && (
|
||||
|
||||
@@ -71,6 +71,20 @@ export function PartnerTable({
|
||||
cellClassName: 'font-mono text-muted-foreground',
|
||||
cell: (part) => (part.total_revenue != null ? `₩${Number(part.total_revenue).toLocaleString()}` : '-'),
|
||||
},
|
||||
{
|
||||
header: '채팅 계정',
|
||||
align: 'center',
|
||||
cellClassName: 'font-mono whitespace-nowrap',
|
||||
cell: (part) =>
|
||||
part.account_login_id ? (
|
||||
<span className="text-xs text-foreground">
|
||||
{part.account_login_id}
|
||||
{part.account_status === 2 && <span className="ml-1 text-[10px] text-rose-500">비활성</span>}
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-[10px] text-muted-foreground">미발급</span>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: '작성자',
|
||||
align: 'center',
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
import { useState } from 'react';
|
||||
import { Copy, KeyRound } from 'lucide-react';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { confirm } from '@/lib/confirm';
|
||||
import { useSupplierAccount } from '../hooks/useSupplierAccount';
|
||||
|
||||
// 협력사 상세의 채팅 계정 관리 섹션 — 발급/비번 재설정/활성상태, 각 조작 즉시 서버 반영.
|
||||
// 비밀번호는 발급·재설정 직후 이 화면에서만 1회 표시된다(해시 저장이라 재조회 불가).
|
||||
export function SupplierAccountManager({ supplierId }: { supplierId: string }) {
|
||||
const { account, isLoading, create, resetPassword, setStatus } = useSupplierAccount(supplierId);
|
||||
const [loginId, setLoginId] = useState('');
|
||||
const [issuedPassword, setIssuedPassword] = useState<string | null>(null); // 방금 발급/재설정된 평문(1회 표시)
|
||||
const [resetPw, setResetPw] = useState<string | null>(null); // 재설정 입력행 값(null=닫힘), 자동생성 프리필
|
||||
const [busy, setBusy] = useState(false);
|
||||
|
||||
const run = async (fn: () => Promise<void>) => {
|
||||
setBusy(true);
|
||||
try {
|
||||
await fn();
|
||||
} catch (err) {
|
||||
showToast(err instanceof Error ? err.message : '채팅 계정 처리 실패', 'error');
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCreate = () =>
|
||||
run(async () => {
|
||||
const pw = await create(loginId.trim());
|
||||
setIssuedPassword(pw);
|
||||
showToast('채팅 계정이 발급되었습니다.', 'success');
|
||||
});
|
||||
|
||||
const handleApplyReset = async () => {
|
||||
const pw = (resetPw ?? '').trim();
|
||||
if (pw.length < 4) {
|
||||
showToast('비밀번호는 4자 이상으로 입력하세요.', 'error');
|
||||
return;
|
||||
}
|
||||
await run(async () => {
|
||||
const applied = await resetPassword(pw);
|
||||
setIssuedPassword(applied);
|
||||
setResetPw(null);
|
||||
showToast('비밀번호가 재설정되었습니다. 새 비밀번호를 협력사에 전달해 주세요.', 'success');
|
||||
});
|
||||
};
|
||||
|
||||
const handleToggleStatus = async () => {
|
||||
const deactivating = account?.status === 1;
|
||||
if (
|
||||
deactivating &&
|
||||
!(await confirm({
|
||||
title: '채팅 계정 비활성화',
|
||||
description: '협력사가 협상 채팅에 로그인할 수 없게 되고, 이미 로그인된 세션도 즉시 끊깁니다. 계속하시겠습니까?',
|
||||
confirmText: '비활성화',
|
||||
destructive: true,
|
||||
}))
|
||||
)
|
||||
return;
|
||||
await run(async () => {
|
||||
await setStatus(deactivating ? 2 : 1);
|
||||
setIssuedPassword(null);
|
||||
showToast(deactivating ? '채팅 계정이 비활성화되었습니다.' : '채팅 계정이 활성화되었습니다.', 'info');
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="pt-4 border-t border-border space-y-2">
|
||||
<Typography as="label" variant="label">채팅 계정 (협상 참여 로그인)</Typography>
|
||||
|
||||
{isLoading ? (
|
||||
<Typography as="p" variant="small" className="p-3 text-muted-foreground text-[11px]">불러오는 중…</Typography>
|
||||
) : account == null ? (
|
||||
// 미발급 — 로그인 ID 직접 입력 후 발급(비밀번호는 서버 자동생성).
|
||||
<div className="space-y-1">
|
||||
<Typography as="p" variant="small" className="text-muted-foreground text-[11px]">
|
||||
발급된 채팅 계정이 없습니다. 로그인 ID를 정해 발급하세요.
|
||||
</Typography>
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
id="chat-account-login-id"
|
||||
type="text"
|
||||
value={loginId}
|
||||
onChange={(e) => setLoginId(e.target.value)}
|
||||
maxLength={20}
|
||||
className="text-foreground text-xs flex-1"
|
||||
placeholder="로그인 ID (영문·숫자, 20자 이내)"
|
||||
/>
|
||||
<Button type="button" size="sm" onClick={handleCreate} disabled={busy || !loginId.trim()}>
|
||||
<KeyRound />
|
||||
계정 발급
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
// 발급됨 — ID·상태 표시 + 비번 재설정/활성상태 토글.
|
||||
<div className="border border-border rounded p-2 space-y-2">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 min-w-0">
|
||||
<Typography as="span" variant="small" className="font-mono font-semibold truncate">{account.login_id}</Typography>
|
||||
<Typography
|
||||
as="span"
|
||||
variant="small"
|
||||
className={`text-[10px] whitespace-nowrap ${account.status === 1 ? 'text-emerald-600' : 'text-rose-500'}`}
|
||||
>
|
||||
● {account.status === 1 ? '활성' : '비활성'}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="flex items-center gap-1.5 shrink-0">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setIssuedPassword(null);
|
||||
setResetPw(generatePassword());
|
||||
}}
|
||||
disabled={busy || resetPw != null}
|
||||
>
|
||||
비밀번호 재설정
|
||||
</Button>
|
||||
<Button type="button" variant="outline" size="sm" onClick={handleToggleStatus} disabled={busy}>
|
||||
{account.status === 1 ? '비활성화' : '활성화'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{resetPw != null && (
|
||||
<div className="space-y-1">
|
||||
<div className="flex items-center gap-2">
|
||||
<Input
|
||||
id="chat-account-reset-pw"
|
||||
type="text"
|
||||
value={resetPw}
|
||||
onChange={(e) => setResetPw(e.target.value)}
|
||||
maxLength={72}
|
||||
className="text-foreground text-xs font-mono flex-1"
|
||||
placeholder="새 비밀번호 (4자 이상)"
|
||||
/>
|
||||
<Button type="button" size="sm" onClick={handleApplyReset} disabled={busy}>
|
||||
적용
|
||||
</Button>
|
||||
<Button type="button" variant="outline" size="sm" onClick={() => setResetPw(null)} disabled={busy}>
|
||||
취소
|
||||
</Button>
|
||||
</div>
|
||||
<Typography as="p" variant="small" className="text-[10px] text-muted-foreground">
|
||||
⚠ 적용 시 협력사의 기존 채팅 로그인이 즉시 끊깁니다.
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{issuedPassword && (
|
||||
<div className="rounded bg-amber-500/10 border border-amber-500/30 p-2 space-y-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<Typography as="span" variant="small" className="font-mono font-semibold">{issuedPassword}</Typography>
|
||||
<button
|
||||
type="button"
|
||||
title="비밀번호 복사"
|
||||
className="p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
|
||||
onClick={() => {
|
||||
void navigator.clipboard?.writeText(issuedPassword);
|
||||
showToast('비밀번호가 복사되었습니다.', 'info');
|
||||
}}
|
||||
>
|
||||
<Copy size={14} />
|
||||
</button>
|
||||
</div>
|
||||
<Typography as="p" variant="small" className="text-[10px] text-amber-700 dark:text-amber-500">
|
||||
⚠ 비밀번호는 지금만 표시됩니다. 협력사에 전달해 주세요. (분실 시 재설정)
|
||||
</Typography>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// 재설정 프리필용 임시 비밀번호(XXXX-XXXX) — 서버 자동생성과 같은 형식, 혼동 문자(0O1lI) 제외.
|
||||
const PW_ALPHABET = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789';
|
||||
function generatePassword(): string {
|
||||
const block = () =>
|
||||
Array.from(crypto.getRandomValues(new Uint32Array(4)), (n) => PW_ALPHABET[n % PW_ALPHABET.length]).join('');
|
||||
return `${block()}-${block()}`;
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
import { useState } from 'react';
|
||||
import { Plus, Trash2 } from 'lucide-react';
|
||||
import { useListItems } from '@/api/generated/item/item';
|
||||
import { SupplierType } from '@/api/generated/model';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Combobox, type ComboOption } from '@/components/ui/combobox';
|
||||
import { SUPPLIER_TYPE_OPTIONS, supplierTypeLabel } from '@/lib/enumLabels';
|
||||
import { SUPPLIER_TYPE_OPTIONS, SupplierType, supplierTypeLabel } from '@/lib/enumLabels';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { useSupplierItems } from '../hooks/useSupplierItems';
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import {
|
||||
useGetSupplierAccount,
|
||||
createSupplierAccount,
|
||||
resetSupplierAccountPassword,
|
||||
updateSupplierAccountStatus,
|
||||
getGetSupplierAccountQueryKey,
|
||||
} from '@/api/generated/supplier/supplier';
|
||||
import type { SupplierAccountData } from '@/api/generated/model/supplierAccountData';
|
||||
import type { ErrorInfo } from '@/api/generated/model/errorInfo';
|
||||
|
||||
// 서버 공통응답(result.success=false)을 한글 사유로 변환. 정상이면 null.
|
||||
function supplierAccountError(result: ErrorInfo | undefined): string | null {
|
||||
if (!result || result.success !== false) return null;
|
||||
if (result.desc === 'SUPPLIER_ACCOUNT_LOGIN_ID_DUPLICATE') return '이미 사용 중인 로그인 ID입니다(다른 협력사 포함 전역 중복).';
|
||||
if (result.desc === 'SUPPLIER_ACCOUNT_ALREADY_EXISTS') return '이미 발급된 채팅 계정이 있습니다.';
|
||||
if (result.desc === 'SUPPLIER_ACCOUNT_NOT_FOUND') return '발급된 채팅 계정이 없습니다.';
|
||||
return result.desc || '채팅 계정 처리에 실패했습니다.';
|
||||
}
|
||||
|
||||
// 협력사 채팅(협상) 계정 서버 데이터 + 발급/비번재설정/활성상태. 협력사 상세(PartnerFormSheet)에서 쓴다.
|
||||
// 발급/재설정 응답의 평문 비밀번호는 그 자리에서 1회만 반환된다(재조회 불가).
|
||||
export function useSupplierAccount(supplierId: string | undefined) {
|
||||
const queryClient = useQueryClient();
|
||||
const query = useGetSupplierAccount(supplierId ?? '', { query: { enabled: !!supplierId } });
|
||||
|
||||
// 계정 상태는 목록의 '채팅 계정' 컬럼에도 실리므로 목록 쿼리까지 함께 재조회.
|
||||
const refresh = () =>
|
||||
Promise.all([
|
||||
supplierId
|
||||
? queryClient.invalidateQueries({ queryKey: getGetSupplierAccountQueryKey(supplierId) })
|
||||
: Promise.resolve(),
|
||||
queryClient.invalidateQueries({ queryKey: ['/v1/supplier/list'] }),
|
||||
]);
|
||||
|
||||
const account: SupplierAccountData | null = (query.data?.account as SupplierAccountData | undefined) ?? null;
|
||||
|
||||
const create = async (loginId: string): Promise<string> => {
|
||||
if (!supplierId) throw new Error('협력사가 지정되지 않았습니다.');
|
||||
const res = await createSupplierAccount(supplierId, { login_id: loginId });
|
||||
const msg = supplierAccountError(res.result);
|
||||
if (msg) throw new Error(msg);
|
||||
await refresh();
|
||||
return res.initial_password ?? '';
|
||||
};
|
||||
|
||||
// password 지정 시 그 값으로, 미지정 시 서버 자동생성.
|
||||
const resetPassword = async (password?: string): Promise<string> => {
|
||||
if (!supplierId) throw new Error('협력사가 지정되지 않았습니다.');
|
||||
const res = await resetSupplierAccountPassword(supplierId, { password });
|
||||
const msg = supplierAccountError(res.result);
|
||||
if (msg) throw new Error(msg);
|
||||
await refresh();
|
||||
return res.new_password ?? '';
|
||||
};
|
||||
|
||||
const setStatus = async (status: number) => {
|
||||
if (!supplierId) throw new Error('협력사가 지정되지 않았습니다.');
|
||||
const res = await updateSupplierAccountStatus(supplierId, { status });
|
||||
const msg = supplierAccountError(res.result);
|
||||
if (msg) throw new Error(msg);
|
||||
await refresh();
|
||||
};
|
||||
|
||||
return { account, isLoading: query.isLoading, create, resetPassword, setStatus };
|
||||
}
|
||||
@@ -1,4 +1,14 @@
|
||||
import { DeliveryType, UserRole, SupplierType, CardUsageType, UserStatus } from '@/api/generated/model';
|
||||
import { DeliveryType, UserRole, CardUsageType, UserStatus } from '@/api/generated/model';
|
||||
|
||||
// partner.supplier_items.supply_type 코드값(백엔드 common.enums.SupplierType 미러링).
|
||||
// 백엔드 protocol 이 enum 대신 int 를 쓰게 되면서 openapi(→orval 생성물)에서 빠져 로컬로 정의한다.
|
||||
export const SupplierType = {
|
||||
NONE: 0,
|
||||
DISTRIBUTION: 1,
|
||||
MANUFACTURE: 2,
|
||||
SOLE_AGENCY: 3,
|
||||
} as const;
|
||||
export type SupplierType = (typeof SupplierType)[keyof typeof SupplierType];
|
||||
|
||||
export const DELIVERY_TYPE_LABEL: Record<DeliveryType, string> = {
|
||||
[DeliveryType.SUPPLIER]: '협력사배송',
|
||||
|
||||
Reference in new issue
Block a user