Merge branch 'feature/negodata'
# Conflicts: # landing/app/routes/home.tsx
This commit is contained in:
commit
d580e4d5ea
99 files changed
+3696
-360
No files matched your search
@@ -80,6 +80,7 @@ export * from './listCardsParams';
|
||||
export * from './listItemsParams';
|
||||
export * from './listNotificationsParams';
|
||||
export * from './listQuotationsParams';
|
||||
export * from './listRequestsParams';
|
||||
export * from './listSuppliersParams';
|
||||
export * from './listUsersParams';
|
||||
export * from './lowestPriceEntry';
|
||||
@@ -129,6 +130,16 @@ export * from './quotationSettingDataUpdatedAt';
|
||||
export * from './quotationSettingDataUserId';
|
||||
export * from './quotationStatus';
|
||||
export * from './quotationType';
|
||||
export * from './renegotiationData';
|
||||
export * from './renegotiationDataBidPrice';
|
||||
export * from './renegotiationDataCloseReason';
|
||||
export * from './renegotiationDataDecidedAt';
|
||||
export * from './renegotiationDataDecidedByName';
|
||||
export * from './renegotiationDataDesiredPrice';
|
||||
export * from './renegotiationDataMemo';
|
||||
export * from './renegotiationDataNextQuotationId';
|
||||
export * from './renegotiationDataTargetPrice';
|
||||
export * from './reqApproveRenegotiation';
|
||||
export * from './reqAwardQuotation';
|
||||
export * from './reqBulkMapByNames';
|
||||
export * from './reqCheckCodes';
|
||||
@@ -183,6 +194,7 @@ export * from './reqCreateSupplierManagerName';
|
||||
export * from './reqCreateSupplierTotalRevenue';
|
||||
export * from './reqLogin';
|
||||
export * from './reqRegenerateQuotation';
|
||||
export * from './reqRejectRenegotiation';
|
||||
export * from './reqResetSupplierAccountPassword';
|
||||
export * from './reqResetSupplierAccountPasswordPassword';
|
||||
export * from './reqUpdateCard';
|
||||
@@ -344,6 +356,11 @@ export * from './resQuotationStatusMsg';
|
||||
export * from './resQuotationStatusQtId';
|
||||
export * from './resRefreshToken';
|
||||
export * from './resRefreshTokenMsg';
|
||||
export * from './resRenegotiationDecision';
|
||||
export * from './resRenegotiationDecisionMsg';
|
||||
export * from './resRenegotiationDecisionNextQuotationId';
|
||||
export * from './resRenegotiationList';
|
||||
export * from './resRenegotiationListMsg';
|
||||
export * from './resResetSupplierAccountPassword';
|
||||
export * from './resResetSupplierAccountPasswordMsg';
|
||||
export * from './resResetSupplierAccountPasswordNewPassword';
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ListRequestsParams = {
|
||||
/**
|
||||
* 요청 상태(1=심사중 2=승인 3=반려 4=철회). 미지정 시 전체
|
||||
*/
|
||||
status?: number | null;
|
||||
/**
|
||||
* @minimum 1
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* @minimum 1
|
||||
* @maximum 100
|
||||
*/
|
||||
size?: number;
|
||||
};
|
||||
@@ -17,4 +17,5 @@ export const NotificationType = {
|
||||
REGENERATED: 2,
|
||||
FAILURE: 3,
|
||||
CREATED: 4,
|
||||
RENEGO_REQUESTED: 5,
|
||||
} as const;
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
import type { RenegotiationDataDesiredPrice } from './renegotiationDataDesiredPrice';
|
||||
import type { RenegotiationDataDecidedAt } from './renegotiationDataDecidedAt';
|
||||
import type { RenegotiationDataDecidedByName } from './renegotiationDataDecidedByName';
|
||||
import type { RenegotiationDataMemo } from './renegotiationDataMemo';
|
||||
import type { RenegotiationDataNextQuotationId } from './renegotiationDataNextQuotationId';
|
||||
import type { RenegotiationDataCloseReason } from './renegotiationDataCloseReason';
|
||||
import type { RenegotiationDataTargetPrice } from './renegotiationDataTargetPrice';
|
||||
import type { RenegotiationDataBidPrice } from './renegotiationDataBidPrice';
|
||||
|
||||
export interface RenegotiationData {
|
||||
session_id?: string;
|
||||
quotation_id?: string;
|
||||
qt_number?: string;
|
||||
qt_round?: number;
|
||||
qt_name?: string;
|
||||
item_id?: string;
|
||||
item_name?: string;
|
||||
supplier_id?: string;
|
||||
supplier_name?: string;
|
||||
owner_name?: string;
|
||||
status?: number;
|
||||
reason?: string;
|
||||
desired_price?: RenegotiationDataDesiredPrice;
|
||||
requested_at?: string;
|
||||
decided_at?: RenegotiationDataDecidedAt;
|
||||
decided_by_name?: RenegotiationDataDecidedByName;
|
||||
memo?: RenegotiationDataMemo;
|
||||
next_quotation_id?: RenegotiationDataNextQuotationId;
|
||||
close_reason?: RenegotiationDataCloseReason;
|
||||
target_price?: RenegotiationDataTargetPrice;
|
||||
bid_price?: RenegotiationDataBidPrice;
|
||||
can_act?: boolean;
|
||||
}
|
||||
@@ -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 RenegotiationDataBidPrice = number | 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 RenegotiationDataCloseReason = number | 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 RenegotiationDataDecidedAt = 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 RenegotiationDataDecidedByName = 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 RenegotiationDataDesiredPrice = number | 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 RenegotiationDataMemo = 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 RenegotiationDataNextQuotationId = 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 RenegotiationDataTargetPrice = number | null;
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ReqApproveRenegotiation {
|
||||
/** 다음 라운드에 함께 넣을 공급사. 비우면 요청자만 */
|
||||
supplier_ids?: string[];
|
||||
/**
|
||||
* 승인 메모
|
||||
* @maxLength 255
|
||||
*/
|
||||
memo?: string;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface ReqRejectRenegotiation {
|
||||
/**
|
||||
* 반려 사유 — 공급사에게 그대로 노출된다
|
||||
* @maxLength 255
|
||||
*/
|
||||
memo?: string;
|
||||
}
|
||||
@@ -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 { ResRenegotiationDecisionMsg } from './resRenegotiationDecisionMsg';
|
||||
import type { ResRenegotiationDecisionNextQuotationId } from './resRenegotiationDecisionNextQuotationId';
|
||||
|
||||
export interface ResRenegotiationDecision {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResRenegotiationDecisionMsg;
|
||||
session_id?: string;
|
||||
status?: number;
|
||||
next_quotation_id?: ResRenegotiationDecisionNextQuotationId;
|
||||
}
|
||||
@@ -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 ResRenegotiationDecisionMsg = 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 ResRenegotiationDecisionNextQuotationId = string | null;
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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 { ResRenegotiationListMsg } from './resRenegotiationListMsg';
|
||||
import type { RenegotiationData } from './renegotiationData';
|
||||
|
||||
export interface ResRenegotiationList {
|
||||
result?: ErrorInfo;
|
||||
msg?: ResRenegotiationListMsg;
|
||||
requests?: RenegotiationData[];
|
||||
total?: number;
|
||||
page?: number;
|
||||
size?: number;
|
||||
}
|
||||
@@ -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 ResRenegotiationListMsg = string | null;
|
||||
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Negodata Api Server
|
||||
* 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,
|
||||
ListRequestsParams,
|
||||
ReqApproveRenegotiation,
|
||||
ReqRejectRenegotiation,
|
||||
ResRenegotiationDecision,
|
||||
ResRenegotiationList
|
||||
} from '.././model';
|
||||
|
||||
import { customFetch } from '../../mutator/custom-fetch';
|
||||
|
||||
|
||||
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @summary 재협상 요청 현황
|
||||
*/
|
||||
export const listRequests = (
|
||||
params?: ListRequestsParams,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResRenegotiationList>(
|
||||
{url: `/v1/renegotiation/list`, method: 'GET',
|
||||
params, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export const getListRequestsQueryKey = (params?: ListRequestsParams,) => {
|
||||
return [
|
||||
`/v1/renegotiation/list`, ...(params ? [params]: [])
|
||||
] as const;
|
||||
}
|
||||
|
||||
|
||||
export const getListRequestsQueryOptions = <TData = Awaited<ReturnType<typeof listRequests>>, TError = void | HTTPValidationError>(params?: ListRequestsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
) => {
|
||||
|
||||
const {query: queryOptions, request: requestOptions} = options ?? {};
|
||||
|
||||
const queryKey = queryOptions?.queryKey ?? getListRequestsQueryKey(params);
|
||||
|
||||
|
||||
|
||||
const queryFn: QueryFunction<Awaited<ReturnType<typeof listRequests>>> = ({ signal }) => listRequests(params, requestOptions, signal);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return { queryKey, queryFn, ...queryOptions} as UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
}
|
||||
|
||||
export type ListRequestsQueryResult = NonNullable<Awaited<ReturnType<typeof listRequests>>>
|
||||
export type ListRequestsQueryError = void | HTTPValidationError
|
||||
|
||||
|
||||
export function useListRequests<TData = Awaited<ReturnType<typeof listRequests>>, TError = void | HTTPValidationError>(
|
||||
params: undefined | ListRequestsParams, options: { query:Partial<UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData>> & Pick<
|
||||
DefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof listRequests>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof listRequests>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useListRequests<TData = Awaited<ReturnType<typeof listRequests>>, TError = void | HTTPValidationError>(
|
||||
params?: ListRequestsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData>> & Pick<
|
||||
UndefinedInitialDataOptions<
|
||||
Awaited<ReturnType<typeof listRequests>>,
|
||||
TError,
|
||||
Awaited<ReturnType<typeof listRequests>>
|
||||
> , 'initialData'
|
||||
>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
export function useListRequests<TData = Awaited<ReturnType<typeof listRequests>>, TError = void | HTTPValidationError>(
|
||||
params?: ListRequestsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
|
||||
/**
|
||||
* @summary 재협상 요청 현황
|
||||
*/
|
||||
|
||||
export function useListRequests<TData = Awaited<ReturnType<typeof listRequests>>, TError = void | HTTPValidationError>(
|
||||
params?: ListRequestsParams, options?: { query?:Partial<UseQueryOptions<Awaited<ReturnType<typeof listRequests>>, TError, TData>>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient
|
||||
): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
|
||||
|
||||
const queryOptions = getListRequestsQueryOptions(params,options)
|
||||
|
||||
const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> };
|
||||
|
||||
query.queryKey = queryOptions.queryKey ;
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @summary 재협상 승인
|
||||
*/
|
||||
export const approve = (
|
||||
sessionId: string,
|
||||
reqApproveRenegotiation: ReqApproveRenegotiation,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResRenegotiationDecision>(
|
||||
{url: `/v1/renegotiation/${sessionId}/approve`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqApproveRenegotiation, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getApproveMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof approve>>, TError,{sessionId: string;data: ReqApproveRenegotiation}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof approve>>, TError,{sessionId: string;data: ReqApproveRenegotiation}, TContext> => {
|
||||
|
||||
const mutationKey = ['approve'];
|
||||
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 approve>>, {sessionId: string;data: ReqApproveRenegotiation}> = (props) => {
|
||||
const {sessionId,data} = props ?? {};
|
||||
|
||||
return approve(sessionId,data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type ApproveMutationResult = NonNullable<Awaited<ReturnType<typeof approve>>>
|
||||
export type ApproveMutationBody = ReqApproveRenegotiation
|
||||
export type ApproveMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 재협상 승인
|
||||
*/
|
||||
export const useApprove = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof approve>>, TError,{sessionId: string;data: ReqApproveRenegotiation}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof approve>>,
|
||||
TError,
|
||||
{sessionId: string;data: ReqApproveRenegotiation},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getApproveMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
/**
|
||||
* @summary 재협상 반려
|
||||
*/
|
||||
export const reject = (
|
||||
sessionId: string,
|
||||
reqRejectRenegotiation: ReqRejectRenegotiation,
|
||||
options?: SecondParameter<typeof customFetch>,signal?: AbortSignal
|
||||
) => {
|
||||
|
||||
|
||||
return customFetch<ResRenegotiationDecision>(
|
||||
{url: `/v1/renegotiation/${sessionId}/reject`, method: 'POST',
|
||||
headers: {'Content-Type': 'application/json', },
|
||||
data: reqRejectRenegotiation, signal
|
||||
},
|
||||
options);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const getRejectMutationOptions = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof reject>>, TError,{sessionId: string;data: ReqRejectRenegotiation}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
): UseMutationOptions<Awaited<ReturnType<typeof reject>>, TError,{sessionId: string;data: ReqRejectRenegotiation}, TContext> => {
|
||||
|
||||
const mutationKey = ['reject'];
|
||||
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 reject>>, {sessionId: string;data: ReqRejectRenegotiation}> = (props) => {
|
||||
const {sessionId,data} = props ?? {};
|
||||
|
||||
return reject(sessionId,data,requestOptions)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return { mutationFn, ...mutationOptions }}
|
||||
|
||||
export type RejectMutationResult = NonNullable<Awaited<ReturnType<typeof reject>>>
|
||||
export type RejectMutationBody = ReqRejectRenegotiation
|
||||
export type RejectMutationError = void | HTTPValidationError
|
||||
|
||||
/**
|
||||
* @summary 재협상 반려
|
||||
*/
|
||||
export const useReject = <TError = void | HTTPValidationError,
|
||||
TContext = unknown>(options?: { mutation?:UseMutationOptions<Awaited<ReturnType<typeof reject>>, TError,{sessionId: string;data: ReqRejectRenegotiation}, TContext>, request?: SecondParameter<typeof customFetch>}
|
||||
, queryClient?: QueryClient): UseMutationResult<
|
||||
Awaited<ReturnType<typeof reject>>,
|
||||
TError,
|
||||
{sessionId: string;data: ReqRejectRenegotiation},
|
||||
TContext
|
||||
> => {
|
||||
|
||||
const mutationOptions = getRejectMutationOptions(options);
|
||||
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export function Providers({children}: {children: ReactNode}) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{children}
|
||||
<Toaster richColors position="top-center" />
|
||||
<Toaster richColors position="top-center" expand visibleToasts={9} />
|
||||
<ConfirmHost />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
|
||||
@@ -8,6 +8,7 @@ import DashboardPage from '../pages/dashboard';
|
||||
import StatisticsPage from '../pages/statistics';
|
||||
import ForbiddenPage from '../pages/forbidden';
|
||||
import DevDesignPage from '../pages/dev-design';
|
||||
import RenegotiationPage from '../pages/renegotiation';
|
||||
import NotFoundPage from '../pages/not-found';
|
||||
import ProductsPage from '../pages/products';
|
||||
import PartnersPage from '../pages/partners';
|
||||
@@ -83,6 +84,7 @@ export const router = createBrowserRouter([
|
||||
{path: 'partners', Component: PartnersPage},
|
||||
{path: 'quotation', Component: QuotationPage},
|
||||
{path: 'cards', Component: CardsPage},
|
||||
{path: 'renegotiation', Component: RenegotiationPage},
|
||||
{path: 'notifications', Component: NotificationsPage},
|
||||
{
|
||||
// 최고관리자 전용. 자식 loader 는 부모와 병렬 실행되므로 여기서도 initAuth 를 기다린다(멱등).
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { toast } from 'sonner';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { useListNotifications, useReadOne } from '@/api/generated/notification/notification';
|
||||
import { useListRequests } from '@/api/generated/renegotiation/renegotiation';
|
||||
import { NotificationType } from '@/api/generated/model';
|
||||
import type { NotificationData } from '@/api/generated/model';
|
||||
|
||||
// 하단 우측 토스트로 알릴 알림 = 낙찰·결렬·자동재생성·재협상요청. 단순 생성(CREATED)은 제외.
|
||||
const TOASTED: number[] = [
|
||||
NotificationType.SUCCESS,
|
||||
NotificationType.FAILURE,
|
||||
NotificationType.REGENERATED,
|
||||
NotificationType.RENEGO_REQUESTED,
|
||||
];
|
||||
|
||||
function messageFor(n: NotificationData): string {
|
||||
const d = (n.data ?? {}) as Record<string, unknown>;
|
||||
const qt = String(d.qt_number ?? d.qt_name ?? '견적');
|
||||
const winner = d.winner_name ? ` · 낙찰 ${String(d.winner_name)}` : '';
|
||||
switch (n.type) {
|
||||
case NotificationType.SUCCESS:
|
||||
return `${qt} 낙찰되었습니다${winner}.`;
|
||||
case NotificationType.FAILURE:
|
||||
return `${qt} 결렬로 마감되었습니다.`;
|
||||
case NotificationType.REGENERATED:
|
||||
return `${qt} 다음 라운드가 자동 생성되었습니다.`;
|
||||
case NotificationType.RENEGO_REQUESTED:
|
||||
return `${d.supplier_name ? String(d.supplier_name) + ' · ' : ''}${qt} 재협상 요청이 접수됐습니다.`;
|
||||
default:
|
||||
return `${qt} 알림.`;
|
||||
}
|
||||
}
|
||||
|
||||
// sonner 색상 함수 — 재협상요청=경고(앰버), 낙찰=성공, 결렬=에러, 자동마감=정보.
|
||||
function fireOf(type?: number) {
|
||||
if (type === NotificationType.SUCCESS) return toast.success;
|
||||
if (type === NotificationType.FAILURE) return toast.error;
|
||||
if (type === NotificationType.RENEGO_REQUESTED) return toast.warning;
|
||||
return toast.info;
|
||||
}
|
||||
|
||||
// 알림 처리(레이아웃 상주, 화면 요소는 토스트로만).
|
||||
// 새로 도착한 알림만 하단 우측 토스트로 띄우고, [보기]/[X] 로 읽음 처리(readOne API — 알림함과 동일).
|
||||
// 읽으면 서버 read_at 이 박혀서 다시 뜨지 않고, 벨 배지·인박스 수도 함께 줄어든다.
|
||||
export function ActionBanner() {
|
||||
const navigate = useNavigate();
|
||||
const queryClient = useQueryClient();
|
||||
const readOne = useReadOne();
|
||||
|
||||
const { data: notif } = useListNotifications(
|
||||
{ size: 20 },
|
||||
{ query: { refetchInterval: 30_000, staleTime: 10_000 } },
|
||||
);
|
||||
// 재협상 요청 토스트는 '아직 완료 안 된(대기중)' 것만 — 내가 처리 가능한(can_act) 대기 세션 집합.
|
||||
const { data: renego } = useListRequests(
|
||||
{ status: 1, page: 1, size: 50 },
|
||||
{ query: { refetchInterval: 30_000, staleTime: 10_000 } },
|
||||
);
|
||||
const pendingSessions = new Set(
|
||||
(renego?.requests ?? []).filter((r) => r.can_act !== false).map((r) => r.session_id),
|
||||
);
|
||||
|
||||
// 읽음 처리(서버) 후 알림 목록 무효화 → 벨 배지·인박스 수가 함께 줄어든다.
|
||||
const markRead = (id: string) => {
|
||||
readOne.mutate(
|
||||
{ notificationId: id },
|
||||
{ onSuccess: () => queryClient.invalidateQueries({ queryKey: ['/v1/notification/list'], exact: false }) },
|
||||
);
|
||||
};
|
||||
|
||||
// 새로 도착한 건만 토스트(첫 로드 시점의 안읽음 백로그는 벨/인박스가 담당 — 토스트 폭탄 방지).
|
||||
const seen = useRef<Set<string> | null>(null);
|
||||
useEffect(() => {
|
||||
const rows = (notif?.notifications ?? []).filter((n) => !n.read_at && TOASTED.includes(n.type));
|
||||
if (seen.current === null) {
|
||||
seen.current = new Set(rows.map((n) => n.notification_id));
|
||||
return;
|
||||
}
|
||||
for (const n of rows) {
|
||||
if (seen.current.has(n.notification_id)) continue;
|
||||
const isRenego = n.type === NotificationType.RENEGO_REQUESTED;
|
||||
// 재협상 요청은 아직 대기중(미완료)인 세션만 토스트 — 이미 승인/반려된 건 건너뛴다.
|
||||
if (isRenego && !pendingSessions.has(n.ref_session_id ?? '')) continue;
|
||||
seen.current.add(n.notification_id);
|
||||
const target = isRenego ? '/renegotiation' : n.ref_qt_id ? `/quotation?detail=${n.ref_qt_id}` : '/notifications';
|
||||
fireOf(n.type)(messageFor(n), {
|
||||
id: n.notification_id,
|
||||
position: 'bottom-right',
|
||||
duration: Infinity, // 자동으로 안 사라지고, 읽음/닫기로만 사라진다.
|
||||
closeButton: true, // X = 닫기 = 읽음 처리(onDismiss).
|
||||
onDismiss: () => markRead(n.notification_id),
|
||||
action: {
|
||||
label: isRenego ? '확인하러 가기' : '보기',
|
||||
onClick: () => {
|
||||
markRead(n.notification_id); // 알림함과 동일하게 읽음 API 를 찌른다.
|
||||
toast.dismiss(n.notification_id);
|
||||
navigate(target);
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [notif]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -11,6 +11,7 @@ const PAGE_TO_PATH: Record<PageType, string> = {
|
||||
PARTNERS: '/partners',
|
||||
QUOTATION: '/quotation',
|
||||
CARDS: '/cards',
|
||||
RENEGOTIATION: '/renegotiation',
|
||||
MEMBERS: '/members',
|
||||
SETTINGS: '/settings',
|
||||
DESIGN: '/dev/design',
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Dialog, DialogContent, DialogTitle } from '@/components/ui/dialog';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { NotificationBell } from './NotificationBell';
|
||||
import { ActionBanner } from './ActionBanner';
|
||||
import { GUIDE_TABS, TAB_LABEL, type GuideTab } from '@/features/onboarding/OnboardingGuideModal';
|
||||
import { SETTINGS_TABS, SETTINGS_TAB_LABEL, type SettingsTab } from '@/features/settings/SettingsView';
|
||||
import {
|
||||
@@ -27,6 +28,7 @@ import {
|
||||
Moon,
|
||||
Building,
|
||||
Palette,
|
||||
RefreshCw,
|
||||
ChevronRight,
|
||||
Menu,
|
||||
X,
|
||||
@@ -60,6 +62,7 @@ const menuGroups: { label?: string; items: MenuItem[] }[] = [
|
||||
{ type: 'PARTNERS', label: '협력사관리', icon: Users, id: 'sidebar-partners' },
|
||||
{ type: 'QUOTATION', label: '견적관리', icon: FileSpreadsheet, id: 'sidebar-quotation' },
|
||||
{ type: 'CARDS', label: '협상카드관리', icon: Layers, id: 'sidebar-cards' },
|
||||
{ type: 'RENEGOTIATION', label: '재협상 요청', icon: RefreshCw, id: 'sidebar-renegotiation' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -93,6 +96,7 @@ const pageLabelMap: Record<PageType, string> = {
|
||||
PARTNERS: '협력사관리',
|
||||
QUOTATION: '견적관리',
|
||||
CARDS: '협상카드관리',
|
||||
RENEGOTIATION: '재협상 요청',
|
||||
MEMBERS: '회원관리',
|
||||
SETTINGS: '회사 설정',
|
||||
DESIGN: '디자인 시스템',
|
||||
@@ -333,12 +337,15 @@ export default function Layout({ children, currentPage, setPage, onLogout }: Lay
|
||||
<div className="max-w-7xl mx-auto space-y-6">{children}</div>
|
||||
</main>
|
||||
|
||||
{/* Compact Admin footer info */}
|
||||
{/* Compact Admin footer info — 액션 배너가 뜨면 가려지지 않게 여백을 준다 */}
|
||||
<footer className="h-10 border-t border-border/60 bg-card flex items-center justify-between px-4 md:px-8">
|
||||
<Typography variant="mono">Copyright © O2O Inc. All rights reserved</Typography>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
{/* 처리해야 사라지는 알림(재협상 심사 대기 등) — 하단 고정 */}
|
||||
<ActionBanner />
|
||||
|
||||
<CommandMenu
|
||||
open={isCmdOpen}
|
||||
onOpenChange={setIsCmdOpen}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import { z } from 'zod';
|
||||
import type { Descendant } from 'slate';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -120,7 +120,7 @@ export function CardFormSheet({
|
||||
|
||||
// 수정·삭제 게이팅 — 공용(기본 제공) 카드는 누구도 불가, 개인 카드는 본인 또는 최고관리자만(백엔드와 동일 규칙).
|
||||
const myUserId = useAuthStore((s) => s.user?.userId);
|
||||
const isSuperAdmin = useAuthStore((s) => s.user?.role === '최고관리자');
|
||||
const isSuperAdmin = useAuthStore((s) => canManage(s.user?.role));
|
||||
const canMutate =
|
||||
mode === 'create' || (!!card && !card.isShared && (card.userId === myUserId || isSuperAdmin));
|
||||
const mutateBlockReason = card?.isShared
|
||||
|
||||
@@ -211,8 +211,8 @@ const FAQS: { q: string; a: string }[] = [
|
||||
a: '견적 생성의 카드 선택에서 성공률(카드를 쓴 협상 중 타결된 비율) 높은 순으로 정렬되고, 상위 3개에는 순위 배지가 붙어요. 아직 쓰인 적 없는 카드는 표본이 없어 뒤로 밀려요.',
|
||||
},
|
||||
{
|
||||
q: '화면에 나오는 용어나 로고를 우리 회사 것으로 바꾸려면?',
|
||||
a: '최고관리자 계정으로 회사 설정에 들어가면 서비스명·로고·색상(브랜딩), 화면 용어(라벨), 추가로 입력받을 항목(커스텀 필드), 감출 항목을 바꿀 수 있어요. 설정을 JSON으로 내보내고 불러올 수도 있어요.',
|
||||
q: '협력사가 재협상을 요청하면 어디서 처리하나요?',
|
||||
a: '낙찰 없이 개찰(결렬)로 닫힌 건에 한해, 그 견적 마지막 라운드에 참여했던 협력사가 포털에서 재협상을 요청할 수 있어요. (낙찰된 건은 제외이고, 협상을 거부했거나 미참여였던 협력사도 조건이 바뀌면 요청할 수 있어요.) 요청은 「재협상」 화면에서 현황을 보고 승인 또는 반려해요. 승인하면 그 협력사를 포함해 재협상 견적이 바로 생성되고(초청메일은 견적 상세에서 수동 발송), 반려하면 사유가 협력사에게 그대로 보여요.',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { PhoneInput } from '@/components/ui/phone-input';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { useCompanySettings } from '@/features/settings/useCompanySettings';
|
||||
import { CustomFieldInputs, useCustomFieldValues } from '@/features/settings/CustomFieldInputs';
|
||||
import { SupplierItemsManager } from './SupplierItemsManager';
|
||||
@@ -85,7 +85,7 @@ export function PartnerFormSheet({
|
||||
});
|
||||
|
||||
// 협력사 명부는 회사 공유 자원 — 파괴적 삭제는 최고관리자만(백엔드 RequireOwner 와 동일 규칙).
|
||||
const isSuperAdmin = useAuthStore((s) => s.user?.role === '최고관리자');
|
||||
const isSuperAdmin = useAuthStore((s) => canManage(s.user?.role));
|
||||
|
||||
// 회사 협력사 커스텀필드(정의=companies.settings.supplier_fields, 값=suppliers.custom)
|
||||
const { settings } = useCompanySettings();
|
||||
|
||||
@@ -6,8 +6,9 @@ import type { Partner } from '../types';
|
||||
|
||||
type PartnerTableProps = {
|
||||
data: Partner[];
|
||||
selectedIds: string[];
|
||||
onSelectionChange: (ids: string[]) => void;
|
||||
/** 미전달 시 선택(체크박스) 컬럼 자체를 숨긴다 — 일괄삭제 권한 없는 계정용 */
|
||||
selectedIds?: string[];
|
||||
onSelectionChange?: (ids: string[]) => void;
|
||||
onRowClick: (part: Partner) => void;
|
||||
page: number;
|
||||
totalPages: number;
|
||||
@@ -37,7 +38,7 @@ export function PartnerTable({
|
||||
data={data}
|
||||
rowKey={(part) => part.supplier_id}
|
||||
onRowClick={onRowClick}
|
||||
selection={{ selectedKeys: selectedIds, onSelectionChange }}
|
||||
selection={selectedIds && onSelectionChange ? { selectedKeys: selectedIds, onSelectionChange } : undefined}
|
||||
empty="협약된 가용 B2B 파트너사가 존재하지 않습니다."
|
||||
footer={
|
||||
<TablePagination
|
||||
|
||||
@@ -12,7 +12,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { useCompanySettings, useLabels, useHiddenFields } from '@/features/settings/useCompanySettings';
|
||||
import { CustomFieldInputs, useCustomFieldValues } from '@/features/settings/CustomFieldInputs';
|
||||
import { ItemSuppliersManager } from './ItemSuppliersManager';
|
||||
@@ -145,7 +145,7 @@ export function ProductFormSheet({
|
||||
|
||||
// 소유자 게이팅 — 본인이 등록한 상품 또는 최고관리자만 수정·삭제(프론트 1차 차단, 백엔드도 강제).
|
||||
const myUserId = useAuthStore((s) => s.user?.userId);
|
||||
const isSuperAdmin = useAuthStore((s) => s.user?.role === '최고관리자');
|
||||
const isSuperAdmin = useAuthStore((s) => canManage(s.user?.role));
|
||||
const canManageOwn = !!product && (product.user_id === myUserId || isSuperAdmin);
|
||||
// 저장 가능 여부 — 신규는 항상, 수정은 소유자/관리자만.
|
||||
const canSave = mode === 'create' || canManageOwn;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { useListSuppliers } from '@/api/generated/supplier/supplier';
|
||||
import { useListSettings } from '@/api/generated/quotation-setting/quotation-setting';
|
||||
import { useQuotationChain } from '../../hooks/useQuotationChain';
|
||||
import { useScrollLock } from '@/lib/useScrollLock';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import type { QuotationData } from '@/api/generated/model/quotationData';
|
||||
import {
|
||||
mapItem,
|
||||
@@ -77,7 +77,7 @@ export function QuotationDetailSheet({
|
||||
// 소유자 게이팅 — 견적을 바꾸는 액션(초청메일·마감·재생성·낙찰)은 '본인 견적' 또는 최고관리자만.
|
||||
// 프론트 1차 차단이며, 실제 보안은 백엔드가 동일 스코프로 강제해야 함(버튼 숨김만으론 우회 가능).
|
||||
const myUserId = useAuthStore((s) => s.user?.userId);
|
||||
const isSuperAdmin = useAuthStore((s) => s.user?.role === '최고관리자');
|
||||
const isSuperAdmin = useAuthStore((s) => canManage(s.user?.role));
|
||||
const canManage = !!myUserId && (quotation.user_id === myUserId || isSuperAdmin);
|
||||
const canNotify = canManage; // 초청 메일 발송/재발송
|
||||
// 직접 낙찰 = 개찰(낙찰자 미정 마감) 견적에서만. 후보(투찰한 협상완료 협력사) 유무는 표에서 판정.
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { Sheet } from '@/components/ui/sheet';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Typography, typographyVariants } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { CLOSE_REASON_LABEL, RENEGO_STATUS_LABEL, RenegoStatus, type RenegoRequest } from '../types';
|
||||
|
||||
type Props = {
|
||||
open: boolean;
|
||||
request: RenegoRequest;
|
||||
onApprove: (memo: string) => Promise<void>;
|
||||
onReject: (memo: string) => Promise<void>;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
const won = (v?: number | null) => (v != null ? `₩${Number(v).toLocaleString()}` : '-');
|
||||
|
||||
// 재협상 심사 패널. 담당자가 승인/반려를 결정하는 데 필요한 근거(원 견적 결과 + 요청 내용)를 한 화면에 모은다.
|
||||
export function RenegotiationReviewSheet({ open, request, onApprove, onReject, onClose }: Props) {
|
||||
const [memo, setMemo] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
const pending = request.status === RenegoStatus.PENDING;
|
||||
|
||||
// 직전 투찰가 대비 희망가가 얼마나 내려오는지 — 승인 판단의 핵심 숫자.
|
||||
const drop =
|
||||
request.bid_price && request.desired_price
|
||||
? (1 - request.desired_price / request.bid_price) * 100
|
||||
: null;
|
||||
|
||||
const run = async (kind: 'approve' | 'reject') => {
|
||||
if (kind === 'reject' && !memo.trim()) {
|
||||
showToast('반려 사유를 입력해 주십시오. 공급사에게 그대로 전달됩니다.', 'error');
|
||||
return;
|
||||
}
|
||||
setBusy(true);
|
||||
try {
|
||||
await (kind === 'approve' ? onApprove(memo.trim()) : onReject(memo.trim()));
|
||||
onClose();
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet open={open} title="재협상 요청 심사" onClose={onClose}>
|
||||
<div className="mt-6 space-y-4 text-xs">
|
||||
<Row
|
||||
label="공급사"
|
||||
value={request.supplier_name || '-'}
|
||||
strong
|
||||
href={request.supplier_id ? `/partners?detail=${request.supplier_id}` : undefined}
|
||||
/>
|
||||
<Row
|
||||
label="담당자"
|
||||
value={request.owner_name || '-'}
|
||||
/>
|
||||
<Row
|
||||
label="상품"
|
||||
value={request.item_name || '-'}
|
||||
href={request.item_id ? `/products?detail=${request.item_id}` : undefined}
|
||||
/>
|
||||
<Row
|
||||
label="원 견적"
|
||||
value={`${request.qt_number} · ${request.qt_round}차 · 마감사유 ${CLOSE_REASON_LABEL[request.close_reason ?? 0] ?? '-'}`}
|
||||
/>
|
||||
|
||||
<div className="rounded-lg border border-border bg-muted/30 p-3 space-y-2">
|
||||
<Typography variant="label">요청 내용</Typography>
|
||||
<Row label="사유" value={request.reason || '-'} />
|
||||
<Row label="희망가" value={won(request.desired_price)} strong />
|
||||
<Row label="직전 투찰가" value={won(request.bid_price)} />
|
||||
<Row label="목표가" value={won(request.target_price)} />
|
||||
{drop != null && (
|
||||
<Typography variant="caption" className={cn('block', drop > 0 ? 'text-emerald-600' : 'text-rose-600')}>
|
||||
{drop > 0
|
||||
? `직전 투찰가보다 ${drop.toFixed(1)}% 낮은 금액을 제시했습니다.`
|
||||
: `직전 투찰가보다 높거나 같은 금액입니다 — 재협상 실익을 확인하십시오.`}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{pending ? (
|
||||
request.can_act === false ? (
|
||||
// 남의 견적 요청 — 현황은 보이되 처리(승인/반려)는 견적 작성자 본인·최고관리자만.
|
||||
<Typography variant="caption" className="block rounded-lg border border-border bg-muted/30 p-3">
|
||||
이 견적의 담당자(작성자) 또는 최고관리자만 승인·반려할 수 있습니다. 현황 확인만 가능합니다.
|
||||
</Typography>
|
||||
) : (
|
||||
<>
|
||||
<div className="space-y-1">
|
||||
<Typography as="label" variant="label">
|
||||
메모 <span className="text-muted-foreground">(반려 시 필수 — 공급사에게 노출)</span>
|
||||
</Typography>
|
||||
<Input value={memo} onChange={(e) => setMemo(e.target.value)} placeholder="예: 목표가와 격차가 커 이번 건은 종료합니다" />
|
||||
</div>
|
||||
<Typography variant="caption" className="block">
|
||||
승인하면 이 공급사를 포함해 <b>재협상 견적이 즉시 생성</b>됩니다. 초청메일은 자동 발송되지 않으니 견적 상세에서 보내십시오.
|
||||
</Typography>
|
||||
<div className="flex gap-2 pt-1">
|
||||
<Button className="flex-1" onClick={() => run('approve')} disabled={busy}>
|
||||
{busy ? '처리 중…' : '승인하고 재협상 견적 생성'}
|
||||
</Button>
|
||||
<Button variant="outline" className="flex-1 text-rose-600" onClick={() => run('reject')} disabled={busy}>
|
||||
반려
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
) : (
|
||||
<div className="rounded-lg border border-border bg-muted/30 p-3 space-y-2">
|
||||
<Row label="처리 결과" value={RENEGO_STATUS_LABEL[request.status ?? 0] ?? '-'} strong />
|
||||
{request.decided_by_name && <Row label="처리 담당자" value={request.decided_by_name} />}
|
||||
{request.memo && <Row label="메모" value={request.memo} />}
|
||||
{request.next_quotation_id && (
|
||||
<Link
|
||||
to={`/quotation?detail=${request.next_quotation_id}`}
|
||||
className={cn(typographyVariants({ variant: 'link' }), 'text-xs font-semibold')}
|
||||
>
|
||||
생성된 재협상 견적 보기 ↗
|
||||
</Link>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Sheet>
|
||||
);
|
||||
}
|
||||
|
||||
function Row({ label, value, strong, href }: { label: string; value: string; strong?: boolean; href?: string }) {
|
||||
return (
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<Typography as="span" variant="caption" className="shrink-0">{label}</Typography>
|
||||
{href ? (
|
||||
<Link to={href} className={cn(typographyVariants({ variant: 'link' }), 'min-w-0 text-right', strong && 'font-bold')}>
|
||||
{value} ↗
|
||||
</Link>
|
||||
) : (
|
||||
<Typography as="span" variant="small" className={cn('min-w-0 text-right', strong && 'font-bold')}>
|
||||
{value}
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
import { DataTable, type Column } from '@/components/ui/data-table';
|
||||
import { TablePagination } from '@/components/ui/table-pagination';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { StatusPill } from '@/features/quotations/components/QuotationDetailSheet/StatusPill';
|
||||
import { CLOSE_REASON_LABEL, RENEGO_STATUS_LABEL, RenegoStatus, type RenegoRequest } from '../types';
|
||||
|
||||
type Props = {
|
||||
data: RenegoRequest[];
|
||||
onRowClick: (req: RenegoRequest) => void;
|
||||
page: number;
|
||||
totalPages: number;
|
||||
totalCount: number;
|
||||
pageSize: number;
|
||||
onPageChange: (page: number) => void;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const won = (v?: number | null) => (v != null ? `₩${Number(v).toLocaleString()}` : '-');
|
||||
// ISO(UTC) → 'MM-DD HH:mm'. 목록에선 연도까지 필요 없다.
|
||||
const shortTime = (iso?: string | null) =>
|
||||
iso ? new Date(iso).toLocaleString('sv-SE').slice(5, 16) : '-';
|
||||
|
||||
const statusTone = (status: number) => {
|
||||
if (status === RenegoStatus.PENDING) return 'amber' as const;
|
||||
if (status === RenegoStatus.APPROVED) return 'emerald' as const;
|
||||
if (status === RenegoStatus.REJECTED) return 'rose' as const;
|
||||
return 'zinc' as const;
|
||||
};
|
||||
|
||||
export function RenegotiationTable({ data, onRowClick, page, totalPages, totalCount, pageSize, onPageChange, className }: Props) {
|
||||
return (
|
||||
<DataTable
|
||||
className={className}
|
||||
data={data}
|
||||
rowKey={(r) => r.session_id ?? ''}
|
||||
onRowClick={onRowClick}
|
||||
empty="접수된 재협상 요청이 없습니다."
|
||||
footer={
|
||||
<TablePagination
|
||||
page={page}
|
||||
totalPages={totalPages}
|
||||
totalCount={totalCount}
|
||||
pageSize={pageSize}
|
||||
onPageChange={onPageChange}
|
||||
label="전체 요청"
|
||||
unit="건"
|
||||
/>
|
||||
}
|
||||
columns={[
|
||||
{
|
||||
header: '요청일시',
|
||||
align: 'left',
|
||||
cellClassName: 'font-mono text-muted-foreground whitespace-nowrap',
|
||||
cell: (r) => shortTime(r.requested_at),
|
||||
},
|
||||
{
|
||||
header: '공급사',
|
||||
align: 'left',
|
||||
mobileHeader: true,
|
||||
cell: (r) => (
|
||||
<div className="min-w-0">
|
||||
<Typography as="span" variant="small" className="block truncate font-semibold">
|
||||
{r.supplier_name || '-'}
|
||||
</Typography>
|
||||
<Typography as="span" variant="caption" className="block truncate">
|
||||
{r.item_name || '-'}
|
||||
</Typography>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: '견적',
|
||||
align: 'left',
|
||||
cell: (r) => (
|
||||
<div className="min-w-0">
|
||||
<Typography as="span" variant="small" className="block font-mono">
|
||||
{r.qt_number} <span className="text-muted-foreground">/ {r.qt_round}차</span>
|
||||
</Typography>
|
||||
<Typography as="span" variant="caption" className="block">
|
||||
마감: {CLOSE_REASON_LABEL[r.close_reason ?? 0] ?? '-'}
|
||||
</Typography>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: '담당자',
|
||||
align: 'left',
|
||||
cellClassName: 'whitespace-nowrap',
|
||||
cell: (r) => r.owner_name || '-',
|
||||
},
|
||||
{ header: '요청 사유', align: 'left', cell: (r) => r.reason || '-' },
|
||||
{
|
||||
header: '희망가',
|
||||
align: 'right',
|
||||
cellClassName: 'font-mono',
|
||||
cell: (r) => won(r.desired_price),
|
||||
},
|
||||
{
|
||||
header: '직전 투찰가',
|
||||
align: 'right',
|
||||
cellClassName: 'font-mono text-muted-foreground',
|
||||
cell: (r) => won(r.bid_price),
|
||||
},
|
||||
{
|
||||
header: '상태',
|
||||
align: 'center',
|
||||
cell: (r) => (
|
||||
<StatusPill tone={statusTone(r.status ?? 0)}>
|
||||
{RENEGO_STATUS_LABEL[r.status ?? 0] ?? '-'}
|
||||
</StatusPill>
|
||||
),
|
||||
},
|
||||
{
|
||||
header: '처리 담당자',
|
||||
align: 'left',
|
||||
cellClassName: 'whitespace-nowrap text-muted-foreground',
|
||||
cell: (r) => r.decided_by_name || '-',
|
||||
},
|
||||
] as Column<RenegoRequest>[]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { RenegotiationData } from '@/api/generated/model';
|
||||
|
||||
// 재협상 요청 상태(sessions.custom.renegotiation.status). 백엔드 RenegotiationStatus 와 1:1.
|
||||
export const RenegoStatus = { PENDING: 1, APPROVED: 2, REJECTED: 3, CANCELED: 4 } as const;
|
||||
export type RenegoStatusCode = (typeof RenegoStatus)[keyof typeof RenegoStatus];
|
||||
|
||||
export const RENEGO_STATUS_LABEL: Record<number, string> = {
|
||||
[RenegoStatus.PENDING]: '심사 대기',
|
||||
[RenegoStatus.APPROVED]: '승인',
|
||||
[RenegoStatus.REJECTED]: '반려',
|
||||
[RenegoStatus.CANCELED]: '철회',
|
||||
};
|
||||
|
||||
// 마감 사유 — 요청이 걸린 원 견적이 왜 결렬됐는지(담당자 판단 근거).
|
||||
export const CLOSE_REASON_LABEL: Record<number, string> = {
|
||||
1: '낙찰',
|
||||
5: '기준 미달',
|
||||
6: '동가',
|
||||
7: '전원 미응찰',
|
||||
8: '협상거부',
|
||||
};
|
||||
|
||||
export type RenegoRequest = RenegotiationData;
|
||||
@@ -49,6 +49,20 @@ export function CustomFieldInputs({ fields, state, title = '회사 추가 항목
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
) : f.type === 'select' ? (
|
||||
<>
|
||||
<Typography as="label" variant="label">{f.label}</Typography>
|
||||
<select
|
||||
className="h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500"
|
||||
value={String(state.values[f.key] ?? '')}
|
||||
onChange={(e) => state.set(f.key, e.target.value)}
|
||||
>
|
||||
<option value="">선택</option>
|
||||
{(f.options ?? []).map((o) => (
|
||||
<option key={o} value={o}>{o}</option>
|
||||
))}
|
||||
</select>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Typography as="label" variant="label">{f.label}</Typography>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router';
|
||||
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw, Download, Upload } from 'lucide-react';
|
||||
import { Palette, Tags, ListPlus, Plus, Trash2, RotateCcw, Download, Upload, X } from 'lucide-react';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -180,30 +180,6 @@ export function SettingsView() {
|
||||
placeholder="NegoData (기본값)"
|
||||
/>
|
||||
</Field>
|
||||
<Field label="브랜드 색상" hint="브랜드 마크 색 (hex)">
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
type="color"
|
||||
aria-label="브랜드 색상 선택"
|
||||
className="size-8 rounded border border-border bg-transparent p-0.5 cursor-pointer"
|
||||
value={draft.branding?.primary_color || '#5E6AD2'}
|
||||
onChange={(e) => setBranding('primary_color', e.target.value)}
|
||||
/>
|
||||
<Input
|
||||
className="w-32"
|
||||
value={draft.branding?.primary_color ?? ''}
|
||||
onChange={(e) => setBranding('primary_color', e.target.value)}
|
||||
placeholder="#5E6AD2"
|
||||
/>
|
||||
</div>
|
||||
</Field>
|
||||
<Field label="이메일 헤더 문구" hint="협상 초청 메일 상단 브랜드 문구">
|
||||
<Input
|
||||
value={draft.branding?.email_header ?? ''}
|
||||
onChange={(e) => setBranding('email_header', e.target.value)}
|
||||
placeholder="NEGODATA (기본값)"
|
||||
/>
|
||||
</Field>
|
||||
</div>
|
||||
|
||||
{/* 로고 이미지 — 업로드(드롭/선택) 또는 URL 직접 입력. 비우면 색상 마크+서비스명 텍스트. */}
|
||||
@@ -430,13 +406,14 @@ function CustomFieldsEditor({
|
||||
<TableHead className="p-2 w-52">표시명</TableHead>
|
||||
<TableHead className="p-2 w-52">키 (영문)</TableHead>
|
||||
<TableHead className="p-2 w-36">유형</TableHead>
|
||||
<TableHead className="p-2">보기 목록 (선택형, 쉼표로 구분)</TableHead>
|
||||
<TableHead className="p-2 text-center w-12">삭제</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody className="divide-y divide-border bg-background">
|
||||
{fields.length === 0 && (
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} className="p-6 text-center text-muted-foreground">
|
||||
<TableCell colSpan={5} className="p-6 text-center text-muted-foreground">
|
||||
추가된 커스텀 필드가 없습니다.
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -476,6 +453,13 @@ function CustomFieldsEditor({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</TableCell>
|
||||
<TableCell className="p-2">
|
||||
<OptionsEditor
|
||||
options={f.options ?? []}
|
||||
disabled={f.type !== 'select'}
|
||||
onChange={(opts) => update(i, { options: opts })}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className="p-2 text-center">
|
||||
<button
|
||||
type="button"
|
||||
@@ -504,6 +488,60 @@ function CustomFieldsEditor({
|
||||
);
|
||||
}
|
||||
|
||||
// 선택형 필드의 보기 목록 — 칩(태그) 방식. 입력 후 Enter/쉼표로 하나씩 추가, X로 제거, 빈 칸에서 Backspace 로 마지막 제거.
|
||||
function OptionsEditor({
|
||||
options,
|
||||
disabled,
|
||||
onChange,
|
||||
}: {
|
||||
options: string[];
|
||||
disabled?: boolean;
|
||||
onChange: (opts: string[]) => void;
|
||||
}) {
|
||||
const [draft, setDraft] = useState('');
|
||||
|
||||
if (disabled) return <span className="text-[11px] text-muted-foreground">유형이 ‘선택’일 때 사용</span>;
|
||||
|
||||
const add = (raw: string) => {
|
||||
const v = raw.trim();
|
||||
setDraft('');
|
||||
if (v && !options.includes(v)) onChange([...options, v]);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-7 flex-wrap items-center gap-1 rounded-md border border-input bg-background px-1.5 py-1">
|
||||
{options.map((o, idx) => (
|
||||
<span key={idx} className="inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px] font-sans">
|
||||
{o}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onChange(options.filter((_, i) => i !== idx))}
|
||||
className="text-muted-foreground hover:text-red-500"
|
||||
title="옵션 삭제"
|
||||
>
|
||||
<X size={11} />
|
||||
</button>
|
||||
</span>
|
||||
))}
|
||||
<input
|
||||
className="h-5 min-w-[70px] flex-1 bg-transparent text-[11px] font-sans outline-none"
|
||||
value={draft}
|
||||
onChange={(e) => (e.target.value.includes(',') ? add(e.target.value.replace(/,/g, '')) : setDraft(e.target.value))}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' && !e.nativeEvent.isComposing) {
|
||||
e.preventDefault();
|
||||
add(draft);
|
||||
} else if (e.key === 'Backspace' && !draft && options.length) {
|
||||
onChange(options.slice(0, -1));
|
||||
}
|
||||
}}
|
||||
onBlur={() => add(draft)}
|
||||
placeholder={options.length ? '추가…' : '예: 협력사배송 (엔터로 추가)'}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// key 입력 정리 — 영문/숫자/언더스코어만 허용(소문자화).
|
||||
function sanitizeKey(raw: string): string {
|
||||
return raw.toLowerCase().replace(/[^a-z0-9_]/g, '');
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
// 회사 커스터마이징 설정(companies.settings JSONB) 문서 타입 + 용어 라벨 카탈로그.
|
||||
// 라벨 키는 여기 한 곳에만 추가한다 — 설정 화면(용어 탭)과 화면 배선(useLabel)이 같은 카탈로그를 읽는다.
|
||||
|
||||
export type CustomFieldType = 'text' | 'number' | 'boolean';
|
||||
export type CustomFieldType = 'text' | 'number' | 'boolean' | 'select';
|
||||
|
||||
export type CustomFieldDef = {
|
||||
key: string; // custom JSONB 의 키 (영문 snake_case)
|
||||
label: string; // 화면 표시명
|
||||
type: CustomFieldType;
|
||||
options?: string[]; // type='select' 일 때 고를 보기 목록
|
||||
};
|
||||
|
||||
export type CompanySettings = {
|
||||
@@ -130,4 +131,5 @@ export const CUSTOM_FIELD_TYPE_LABEL: Record<CustomFieldType, string> = {
|
||||
text: '텍스트',
|
||||
number: '숫자',
|
||||
boolean: '예/아니오',
|
||||
select: '선택',
|
||||
};
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react';
|
||||
import { useNavigate } from 'react-router';
|
||||
import { useInfiniteQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Trophy, RefreshCw, XCircle, Bell, CheckCheck, FilePlus2 } from 'lucide-react';
|
||||
import { CheckCircle2, RefreshCw, XCircle, Bell, CheckCheck, FilePlus2, Handshake } from 'lucide-react';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -295,7 +295,7 @@ function render(n: NotificationData): {
|
||||
case NotificationType.SUCCESS:
|
||||
// 자동 낙찰과 담당자 직접 낙찰(data.manual)은 같은 SUCCESS — 문구로만 '직접'을 구분한다.
|
||||
return {
|
||||
icon: <Trophy size={15} />,
|
||||
icon: <CheckCircle2 size={15} />,
|
||||
pill: d.manual ? '낙찰 · 직접' : '낙찰',
|
||||
pillCls: PILL_TONE.emerald,
|
||||
name,
|
||||
@@ -325,6 +325,18 @@ function render(n: NotificationData): {
|
||||
}`,
|
||||
number,
|
||||
};
|
||||
case NotificationType.RENEGO_REQUESTED: {
|
||||
const reason = d.reason ? `사유 ${String(d.reason)}` : '';
|
||||
const want = d.desired_price != null ? `희망가 ${Number(d.desired_price).toLocaleString()}원` : '';
|
||||
return {
|
||||
icon: <Handshake size={15} />,
|
||||
pill: '재협상 요청',
|
||||
pillCls: PILL_TONE.indigo,
|
||||
name: (d.supplier_name as string) || name,
|
||||
detail: [reason, want].filter(Boolean).join(' · ') || '공급사가 재협상을 요청했습니다',
|
||||
number,
|
||||
};
|
||||
}
|
||||
default:
|
||||
return { icon: <Bell size={15} />, pill: '알림', pillCls: PILL_TONE.muted, name, detail: '', number };
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { PageToolbar, SearchInput } from '@/components/layout/PageToolbar';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useAuthStore, canManage } from '@/stores/auth';
|
||||
import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||
import { useServerList } from '@/lib/useServerList';
|
||||
import { usePartners } from '@/features/partners/hooks/usePartners';
|
||||
@@ -40,7 +40,7 @@ export default function PartnersPage() {
|
||||
const isFormOpen = overlay.has('new') || !!editing;
|
||||
|
||||
// 협력사 삭제는 최고관리자 전용(단건 삭제와 동일 규칙) — 일괄삭제 버튼도 최고관리자에게만 노출.
|
||||
const isSuperAdmin = useAuthStore((st) => st.user?.role === '최고관리자');
|
||||
const isSuperAdmin = useAuthStore((st) => canManage(st.user?.role));
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([]);
|
||||
|
||||
const handleBulkDelete = async () => {
|
||||
@@ -133,8 +133,8 @@ export default function PartnersPage() {
|
||||
<PartnerTable
|
||||
className="rounded-none border-0"
|
||||
data={partners}
|
||||
selectedIds={selectedIds}
|
||||
onSelectionChange={setSelectedIds}
|
||||
selectedIds={isSuperAdmin ? selectedIds : undefined}
|
||||
onSelectionChange={isSuperAdmin ? setSelectedIds : undefined}
|
||||
onRowClick={openEdit}
|
||||
page={list.page}
|
||||
totalPages={totalPages}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import { showToast } from '@/lib/notify';
|
||||
import { useOverlayRouter } from '@/lib/useOverlayRouter';
|
||||
import { useServerList } from '@/lib/useServerList';
|
||||
import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { PageToolbar } from '@/components/layout/PageToolbar';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { useListRequests, approve, reject, getListRequestsQueryKey } from '@/api/generated/renegotiation/renegotiation';
|
||||
import { RenegotiationTable } from '@/features/renegotiation/components/RenegotiationTable';
|
||||
import { RenegotiationReviewSheet } from '@/features/renegotiation/components/RenegotiationReviewSheet';
|
||||
import { RenegoStatus, type RenegoRequest } from '@/features/renegotiation/types';
|
||||
|
||||
// 상태 탭 — 담당자가 가장 먼저 할 일(심사 대기)을 기본으로 연다.
|
||||
const TABS = [
|
||||
{ id: 'PENDING', label: '심사 대기', status: RenegoStatus.PENDING },
|
||||
{ id: 'APPROVED', label: '승인', status: RenegoStatus.APPROVED },
|
||||
{ id: 'REJECTED', label: '반려', status: RenegoStatus.REJECTED },
|
||||
{ id: 'ALL', label: '전체', status: undefined },
|
||||
] as const;
|
||||
|
||||
export default function RenegotiationPage() {
|
||||
const list = useServerList({ pageSize: 20 });
|
||||
const queryClient = useQueryClient();
|
||||
const activeTab = (list.filters.tab as string) || 'PENDING';
|
||||
const status = TABS.find((t) => t.id === activeTab)?.status;
|
||||
|
||||
const { data } = useListRequests({ status, page: list.page, size: list.pageSize });
|
||||
const requests = (data?.requests ?? []) as RenegoRequest[];
|
||||
const total = data?.total ?? 0;
|
||||
const totalPages = list.totalPages(total);
|
||||
|
||||
const overlay = useOverlayRouter(['detail']);
|
||||
const detailId = overlay.get('detail');
|
||||
const active = detailId ? requests.find((r) => r.session_id === detailId) ?? null : null;
|
||||
|
||||
const refresh = () => queryClient.invalidateQueries({ queryKey: getListRequestsQueryKey() });
|
||||
|
||||
const handleApprove = async (memo: string) => {
|
||||
if (!active?.session_id) return;
|
||||
const res = await approve(active.session_id, { memo, supplier_ids: [] });
|
||||
if (res.result?.success === false) {
|
||||
showToast(res.msg || '승인에 실패했습니다.', 'error');
|
||||
return;
|
||||
}
|
||||
showToast('승인했습니다. 다음 차수 견적이 생성되었습니다 — 초청메일을 발송해 주십시오.', 'success');
|
||||
await refresh();
|
||||
};
|
||||
|
||||
const handleReject = async (memo: string) => {
|
||||
if (!active?.session_id) return;
|
||||
const res = await reject(active.session_id, { memo });
|
||||
if (res.result?.success === false) {
|
||||
showToast(res.msg || '반려에 실패했습니다.', 'error');
|
||||
return;
|
||||
}
|
||||
showToast('반려했습니다. 사유가 공급사에게 전달됩니다.', 'success');
|
||||
await refresh();
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer>
|
||||
<div className="overflow-hidden rounded-lg border border-border bg-card">
|
||||
<PageToolbar className="rounded-none border-0 border-b border-border">
|
||||
<Typography variant="caption">
|
||||
협력사가 결렬(개찰) 건에 대해 다시 협상하자고 요청한 목록입니다. 승인하면 다음 차수 견적이 생성됩니다.
|
||||
</Typography>
|
||||
</PageToolbar>
|
||||
|
||||
<div className="flex border-b border-border px-3">
|
||||
{TABS.map((tab) => (
|
||||
<button
|
||||
key={tab.id}
|
||||
type="button"
|
||||
onClick={() => list.setFilter('tab', tab.id)}
|
||||
className={cn(
|
||||
'cursor-pointer border-b-2 px-5 py-2 text-xs font-bold tracking-tight transition-all',
|
||||
activeTab === tab.id
|
||||
? 'border-primary text-primary'
|
||||
: 'border-transparent text-muted-foreground hover:text-foreground',
|
||||
)}
|
||||
>
|
||||
{tab.label}
|
||||
{tab.id === 'PENDING' && status === RenegoStatus.PENDING && total > 0 && ` (${total})`}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<RenegotiationTable
|
||||
className="rounded-none border-0"
|
||||
data={requests}
|
||||
onRowClick={(r) => r.session_id && overlay.open('detail', r.session_id)}
|
||||
page={list.page}
|
||||
totalPages={totalPages}
|
||||
totalCount={total}
|
||||
pageSize={list.pageSize}
|
||||
onPageChange={list.setPage}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{active && (
|
||||
<RenegotiationReviewSheet
|
||||
key={active.session_id}
|
||||
open
|
||||
request={active}
|
||||
onApprove={handleApprove}
|
||||
onReject={handleReject}
|
||||
onClose={overlay.close}
|
||||
/>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -3,13 +3,14 @@ import { PageContainer } from '@/components/layout/PageContainer';
|
||||
import { Typography } from '@/components/ui/typography';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useAuth } from '@/features/auth/useAuth';
|
||||
import { canManage } from '@/stores/auth';
|
||||
import { StatisticsView, useStatistics, type Scope } from '@/features/statistics';
|
||||
|
||||
// 통계(성과 분석). 회사 전체 스코프는 최고관리자만, 일반 사용자는 '내 견적'만 본다.
|
||||
// 데이터는 백엔드 파생 집계(/v1/statistics/summary) — 최근 6개월 창.
|
||||
export default function StatisticsPage() {
|
||||
const { user } = useAuth();
|
||||
const isOwner = user?.role === '최고관리자';
|
||||
const isOwner = canManage(user?.role);
|
||||
const [scope, setScope] = useState<Scope>('company');
|
||||
const activeScope: Scope = isOwner ? scope : 'mine';
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ export const useAuthStore = create<AuthStore>((set) => ({
|
||||
}));
|
||||
|
||||
export const isLoggedIn = () => useAuthStore.getState().user !== null;
|
||||
// 레벨2 이상(최고관리자·개발자) — 변경 액션 게이트. 백엔드 authz(role >= OWNER)·메뉴 노출(Layout ownerOnly)과 같은 기준.
|
||||
export const canManage = (role?: UserRole | null) => role === '최고관리자' || role === '개발자';
|
||||
export const hasRole = (...roles: UserRole[]) => {
|
||||
const u = useAuthStore.getState().user;
|
||||
return u ? roles.includes(u.role) : false;
|
||||
|
||||
@@ -37,4 +37,4 @@ export interface NegotiationCard {
|
||||
usedCount: number; // 카드 사용 세션 수(표본)
|
||||
}
|
||||
|
||||
export type PageType = 'DASHBOARD' | 'STATISTICS' | 'PRODUCTS' | 'PARTNERS' | 'QUOTATION' | 'CARDS' | 'MEMBERS' | 'SETTINGS' | 'DESIGN' | 'NOTIFICATIONS';
|
||||
export type PageType = 'DASHBOARD' | 'STATISTICS' | 'PRODUCTS' | 'PARTNERS' | 'QUOTATION' | 'CARDS' | 'RENEGOTIATION' | 'MEMBERS' | 'SETTINGS' | 'DESIGN' | 'NOTIFICATIONS';
|
||||
Reference in new issue
Block a user