[feat] negodata/front: 프론트 초기 구축 (Vite+React, orval API 클라이언트, 견적/상품/협력사 페이지)

- 라우팅 react-router v7, 서버상태 TanStack Query
- orval 자동 생성 API 클라이언트(src/api/generated)
- 견적/상품/협력사/견적설정 페이지, shadcn UI, 토큰(tokens.css)
- 실행: 루트 docker compose (front :3001), README 그에 맞게 정리
- AI Studio 스캐폴드 잔재 제거(metadata.json, 중복 DESIGN_TOKENS.md), 타이틀 NegoData, vite.config 죽은코드 제거

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
minaChoiandClaude Opus 4.8 committed 2026-06-16 17:18:08 +09:00
1 parent a6731dcb07
commit 87524bf6e8
288 files changed
+26363 -1

No files matched your search

@@ -0,0 +1,92 @@
// Orval mutator (기본 client 방식). axios 인터셉터를 대체하는 단일 길목 —
// 토큰 주입 / 에러 throw / 401 처리 / baseURL 을 여기서 처리한다.
//
// orval.config.ts 의 override.mutator 가 이 함수를 모든 생성 API 호출에 꽂는다.
// httpClient: 'fetch' 를 쓰지 않으므로 orval 은 config-object 시그니처로 호출한다:
// customFetch<T>({ url, method, params, data, signal, headers }, requestOptions)
// → 함수가 응답 본문(T)을 바로 반환하고, 상태코드별 ResponseXXX 유니온 타입은 생성되지 않는다.
// baseURL — compose 의 VITE_API_BASE_URL 로 주입, 없으면 9400 폴백.
const BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:9400';
// 토큰 보관소 — 인증 연동 시 로그인 후 setAccessToken()으로 주입한다(현재 목업 단계에선 미사용).
let accessToken: string | null = null;
export const setAccessToken = (token: string | null) => {
accessToken = token;
};
export class ApiError extends Error {
constructor(
public status: number,
public statusText: string,
public data: unknown,
) {
super(`API ${status} ${statusText}`);
this.name = 'ApiError';
}
}
export type RequestConfig = {
url: string;
method: string;
params?: Record<string, unknown>;
data?: unknown;
headers?: HeadersInit;
signal?: AbortSignal;
responseType?: string;
};
export const customFetch = async <T>(
config: RequestConfig,
options?: RequestInit,
): Promise<T> => {
const { url, method, params, data, signal } = config;
// [요청 인터셉터] 헤더 병합: config → options 순으로 덮어쓴다.
const headers = new Headers(config.headers);
if (options?.headers) {
new Headers(options.headers).forEach((v, k) => headers.set(k, v));
}
if (data != null && !headers.has('Content-Type')) {
headers.set('Content-Type', 'application/json');
}
// 토큰이 있으면 Authorization 자동 주입
if (accessToken) {
headers.set('Authorization', `Bearer ${accessToken}`);
}
// 쿼리스트링 직렬화 (null/undefined 값은 제외)
const queryString = params
? new URLSearchParams(
Object.entries(params)
.filter(([, v]) => v !== undefined && v !== null)
.map(([k, v]) => [k, String(v)]),
).toString()
: '';
const requestUrl =
(url.startsWith('http') ? url : `${BASE_URL}${url}`) +
(queryString ? `?${queryString}` : '');
const response = await fetch(requestUrl, {
...options,
method,
headers,
body: data != null ? JSON.stringify(data) : options?.body,
signal,
});
// [응답 인터셉터] 본문 파싱 (204/빈 응답 대응)
const isJson = response.headers.get('content-type')?.includes('application/json');
const body =
response.status === 204 ? null : isJson ? await response.json() : await response.text();
// fetch는 4xx/5xx도 resolve하므로 직접 throw → React Query가 error로 처리
if (!response.ok) {
// TODO: 401이면 refresh 토큰으로 재발급 후 재시도 로직 추가 위치
throw new ApiError(response.status, response.statusText, body);
}
return body as T;
};
export default customFetch;