solution-site 빌드가 TS2440(Import declaration conflicts with local declaration of 'useCallback')로 실패했다. FastAPI 라우트 핸들러 함수명이 `callback`이라 orval이 만든 React Query 훅 이름이 `useCallback`이 됐고, 같은 파일에서 import한 React의 useCallback과 이름이 겹쳤다. - router/v1/social/oauth.py: 함수명 callback → oauth_callback - 백엔드 재빌드 후 npm run orval 로 재생성 → useOauthCallback, callbackParams.ts → oauthCallbackParams.ts docker compose build solution-site 로 재검증, 정상 빌드 확인
3328 lines
91 KiB
TypeScript
3328 lines
91 KiB
TypeScript
/**
|
|
* Generated by orval v7.21.0 🍺
|
|
* Do not edit manually.
|
|
* Web4Ai API
|
|
* OpenAPI spec version: 0.1.0
|
|
*/
|
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
import type {
|
|
DataTag,
|
|
DefinedInitialDataOptions,
|
|
DefinedUseQueryResult,
|
|
MutationFunction,
|
|
QueryClient,
|
|
QueryFunction,
|
|
QueryKey,
|
|
UndefinedInitialDataOptions,
|
|
UseMutationOptions,
|
|
UseMutationResult,
|
|
UseQueryOptions,
|
|
UseQueryResult,
|
|
} from "@tanstack/react-query";
|
|
|
|
import type {
|
|
ApprovePageParams,
|
|
CheckSlugParams,
|
|
GenerateMyPostForDateParams,
|
|
GenerateMyPostsParams,
|
|
HTTPValidationError,
|
|
ListMyPostsParams,
|
|
ListMySitesParams,
|
|
ListReviewsParams,
|
|
ListUpcomingPostsParams,
|
|
ReqBookingRequest,
|
|
ReqEditPost,
|
|
ReqReview,
|
|
ReqRollback,
|
|
ReqSiteSlug,
|
|
ReqSiteStatus,
|
|
ReqSiteTemplate,
|
|
ReqSiteTheme,
|
|
ReqStartBuild,
|
|
ResBookingRequest,
|
|
ResGenerateNow,
|
|
ResGenerateOne,
|
|
ResGenerationHistory,
|
|
ResMyPosts,
|
|
ResMySites,
|
|
ResPublicReviews,
|
|
ResPublishLogs,
|
|
ResReview,
|
|
ResSeoAudit,
|
|
ResSite,
|
|
ResSiteSlug,
|
|
ResSiteVersions,
|
|
ResSlugCheck,
|
|
ResStartBuild,
|
|
ResWebPacketProtocol,
|
|
} from ".././model";
|
|
|
|
import { customFetch } from "../../mutator/custom-fetch";
|
|
|
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
|
|
/**
|
|
* 현재 발행 버전과 재빌드 필요 여부(needs_rebuild). 노출값이 바뀐 뒤 다시 빌드하지 않았으면 true — 이 사업장만 재빌드하면 된다.
|
|
* @summary 사이트 상태
|
|
*/
|
|
export const getSite = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSite>(
|
|
{ url: `/v1/place/${placeId}/site`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetSiteQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/site`] as const;
|
|
};
|
|
|
|
export const getGetSiteQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getSite>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetSiteQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getSite>>> = ({
|
|
signal,
|
|
}) => getSite(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type GetSiteQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getSite>>
|
|
>;
|
|
export type GetSiteQueryError = void | HTTPValidationError;
|
|
|
|
export function useGetSite<
|
|
TData = Awaited<ReturnType<typeof getSite>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getSite>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getSite>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetSite<
|
|
TData = Awaited<ReturnType<typeof getSite>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getSite>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getSite>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetSite<
|
|
TData = Awaited<ReturnType<typeof getSite>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 사이트 상태
|
|
*/
|
|
|
|
export function useGetSite<
|
|
TData = Awaited<ReturnType<typeof getSite>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSite>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetSiteQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 현재 확인된 콘텐츠와 최신 빌드를 SEO·AEO 각각 100점으로 채점하고 개선 항목을 반환한다. 준비도 점수이며 실제 검색 순위나 AI 인용을 보장하지 않는다.
|
|
* @summary SEO/AEO 준비도 진단
|
|
*/
|
|
export const getSeoAudit = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSeoAudit>(
|
|
{ url: `/v1/place/${placeId}/site/audit`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetSeoAuditQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/site/audit`] as const;
|
|
};
|
|
|
|
export const getGetSeoAuditQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSeoAudit>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getGetSeoAuditQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getSeoAudit>>> = ({
|
|
signal,
|
|
}) => getSeoAudit(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetSeoAuditQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getSeoAudit>>
|
|
>;
|
|
export type GetSeoAuditQueryError = void | HTTPValidationError;
|
|
|
|
export function useGetSeoAudit<
|
|
TData = Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSeoAudit>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getSeoAudit>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetSeoAudit<
|
|
TData = Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSeoAudit>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getSeoAudit>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetSeoAudit<
|
|
TData = Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSeoAudit>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary SEO/AEO 준비도 진단
|
|
*/
|
|
|
|
export function useGetSeoAudit<
|
|
TData = Awaited<ReturnType<typeof getSeoAudit>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getSeoAudit>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetSeoAuditQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 쓰고 싶은 주소를 미리 본다. 소문자 영문·숫자·하이픈 3~50자만 되고, 예약어와 남이 쓰는 주소는 막힌다. ★ 서버가 상호명으로 자동 확정하지 않는다 — 사람이 고른다. 못 쓰면 reason(INVALID_LENGTH·INVALID_FORMAT·RESERVED·TAKEN)과 대안 하나(suggestion)를 준다. 지금 자기가 쓰는 주소면 available=true 다.
|
|
* @summary 사이트 주소 사용 가능 확인
|
|
*/
|
|
export const checkSlug = (
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSlugCheck>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/slug/check`,
|
|
method: "GET",
|
|
params,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getCheckSlugQueryKey = (
|
|
placeId?: string,
|
|
params?: CheckSlugParams,
|
|
) => {
|
|
return [
|
|
`/v1/place/${placeId}/site/slug/check`,
|
|
...(params ? [params] : []),
|
|
] as const;
|
|
};
|
|
|
|
export const getCheckSlugQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof checkSlug>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getCheckSlugQueryKey(placeId, params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof checkSlug>>> = ({
|
|
signal,
|
|
}) => checkSlug(placeId, params, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type CheckSlugQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof checkSlug>>
|
|
>;
|
|
export type CheckSlugQueryError = void | HTTPValidationError;
|
|
|
|
export function useCheckSlug<
|
|
TData = Awaited<ReturnType<typeof checkSlug>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof checkSlug>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof checkSlug>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useCheckSlug<
|
|
TData = Awaited<ReturnType<typeof checkSlug>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof checkSlug>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof checkSlug>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useCheckSlug<
|
|
TData = Awaited<ReturnType<typeof checkSlug>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 사이트 주소 사용 가능 확인
|
|
*/
|
|
|
|
export function useCheckSlug<
|
|
TData = Awaited<ReturnType<typeof checkSlug>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: CheckSlugParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof checkSlug>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getCheckSlugQueryOptions(placeId, params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 주소를 sites.domain 에 저장한다(사이트 행이 없으면 만든다). 검증은 check 와 같은 규칙으로 서버가 다시 한다 — 클라이언트 검증을 믿지 않는다. ★ 이미 발행된 사이트의 주소는 바꿀 수 없다(SITE_SLUG_LOCKED) — 색인된 주소가 바뀌면 AI 검색이 잡아 둔 페이지가 404 가 된다.
|
|
* @summary 사이트 주소 확정
|
|
*/
|
|
export const setSlug = (
|
|
placeId: string,
|
|
reqSiteSlug: ReqSiteSlug,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSiteSlug>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/slug`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqSiteSlug,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSetSlugMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setSlug>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteSlug },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof setSlug>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteSlug },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["setSlug"];
|
|
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 setSlug>>,
|
|
{ placeId: string; data: ReqSiteSlug }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return setSlug(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SetSlugMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof setSlug>>
|
|
>;
|
|
export type SetSlugMutationBody = ReqSiteSlug;
|
|
export type SetSlugMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 사이트 주소 확정
|
|
*/
|
|
export const useSetSlug = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setSlug>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteSlug },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof setSlug>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteSlug },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSetSlugMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 위저드에서 고른 템플릿을 sites.template_id 에 저장한다(사이트 행이 없으면 만든다). ★ 서버는 값을 검증하지 않는다 — 템플릿 목록은 프론트가 소유한다. 길이(100자)만 막는다. ★ 주소와 달리 발행 뒤에도 바꿀 수 있다: 디자인이 바뀌어도 URL 은 그대로라 색인이 깨지지 않는다. 이미 발행된 사이트면 재빌드가 필요하다는 표시로 content_updated_at 을 찍는다(needs_rebuild=true).
|
|
* @summary 템플릿(디자인) 선택 저장
|
|
*/
|
|
export const setTemplate = (
|
|
placeId: string,
|
|
reqSiteTemplate: ReqSiteTemplate,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSite>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/template`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqSiteTemplate,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSetTemplateMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTemplate>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTemplate },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTemplate>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTemplate },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["setTemplate"];
|
|
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 setTemplate>>,
|
|
{ placeId: string; data: ReqSiteTemplate }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return setTemplate(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SetTemplateMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof setTemplate>>
|
|
>;
|
|
export type SetTemplateMutationBody = ReqSiteTemplate;
|
|
export type SetTemplateMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 템플릿(디자인) 선택 저장
|
|
*/
|
|
export const useSetTemplate = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTemplate>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTemplate },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof setTemplate>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTemplate },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSetTemplateMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 에디터가 정한 색·서체·섹션(순서·on/off·배리에이션)을 sites.theme 에 저장한다(사이트 행이 없으면 만든다). body 최상위 키는 theme 하나다: {"theme":{"colors":{...},"fontStyle":"...","look":{...},"colorPaletteId":"...","sections":[{"id","name","enabled","locked","variantId","body","data"}]}}. ★ sections 의 배열 순서가 곧 섹션 순서다(별도 order 필드 없음). ★ 서버는 값을 해석하지 않는다 — 섹션 목록·배리에이션 키·색 토큰은 프론트가 소유한다. 직렬화 크기(64KB)만 막는다. ★ templateId 는 여기 담지 않는다 — sites.template_id 와 POST /template 이 담당한다. ★ colorPaletteId 는 에디터 복원 전용이라 저장·반환만 하고 발행 payload 에는 싣지 않는다. ★ 빈 값({})을 보내면 NULL 로 되돌아가 업종 기본 색·서체·섹션으로 떨어진다. ★ 템플릿과 같이 발행 뒤에도 바꿀 수 있다(디자인이 바뀌어도 URL 은 그대로다). 이미 발행된 사이트면 재빌드가 필요하다는 표시로 content_updated_at 을 찍는다(needs_rebuild=true).
|
|
* @summary 디자인(색·서체·섹션) 저장
|
|
*/
|
|
export const setTheme = (
|
|
placeId: string,
|
|
reqSiteTheme: ReqSiteTheme,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSite>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/theme`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqSiteTheme,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSetThemeMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTheme>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTheme },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTheme>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTheme },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["setTheme"];
|
|
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 setTheme>>,
|
|
{ placeId: string; data: ReqSiteTheme }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return setTheme(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SetThemeMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof setTheme>>
|
|
>;
|
|
export type SetThemeMutationBody = ReqSiteTheme;
|
|
export type SetThemeMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 디자인(색·서체·섹션) 저장
|
|
*/
|
|
export const useSetTheme = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof setTheme>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTheme },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof setTheme>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteTheme },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSetThemeMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 스냅샷을 박제해 HTML + JSON-LD 를 만들고 발행 검수 게이트를 돌린다. publish=true 면 통과 시 바로 발행한다. ★ 게이트를 우회하는 옵션은 없다.
|
|
* @summary 정적 빌드(비동기)
|
|
*/
|
|
export const startBuild = (
|
|
placeId: string,
|
|
reqStartBuild: ReqStartBuild,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResStartBuild>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/build`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqStartBuild,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getStartBuildMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof startBuild>>,
|
|
TError,
|
|
{ placeId: string; data: ReqStartBuild },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof startBuild>>,
|
|
TError,
|
|
{ placeId: string; data: ReqStartBuild },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["startBuild"];
|
|
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 startBuild>>,
|
|
{ placeId: string; data: ReqStartBuild }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return startBuild(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type StartBuildMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof startBuild>>
|
|
>;
|
|
export type StartBuildMutationBody = ReqStartBuild;
|
|
export type StartBuildMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 정적 빌드(비동기)
|
|
*/
|
|
export const useStartBuild = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof startBuild>>,
|
|
TError,
|
|
{ placeId: string; data: ReqStartBuild },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof startBuild>>,
|
|
TError,
|
|
{ placeId: string; data: ReqStartBuild },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getStartBuildMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 발행이 굽는 것과 **같은 함수**로 만든 SitePayload 를 그대로 준다. 미리보기가 이 하나만 먹으면 캔버스와 발행본이 갈릴 자리가 없다. ★ DB 도 파일도 건드리지 않는다 — 버전을 만들지 않으므로 눌러도 발행 이력이 안 쌓인다.
|
|
* @summary 에디터 미리보기 payload — 발행본과 같은 것
|
|
*/
|
|
export const sitePreview = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<unknown>(
|
|
{ url: `/v1/place/${placeId}/site/preview`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSitePreviewQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/site/preview`] as const;
|
|
};
|
|
|
|
export const getSitePreviewQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof sitePreview>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof sitePreview>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getSitePreviewQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof sitePreview>>> = ({
|
|
signal,
|
|
}) => sitePreview(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof sitePreview>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type SitePreviewQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof sitePreview>>
|
|
>;
|
|
export type SitePreviewQueryError = void | HTTPValidationError;
|
|
|
|
export function useSitePreview<
|
|
TData = Awaited<ReturnType<typeof sitePreview>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof sitePreview>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof sitePreview>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof sitePreview>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useSitePreview<
|
|
TData = Awaited<ReturnType<typeof sitePreview>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof sitePreview>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof sitePreview>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof sitePreview>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useSitePreview<
|
|
TData = Awaited<ReturnType<typeof sitePreview>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof sitePreview>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 에디터 미리보기 payload — 발행본과 같은 것
|
|
*/
|
|
|
|
export function useSitePreview<
|
|
TData = Awaited<ReturnType<typeof sitePreview>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof sitePreview>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getSitePreviewQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* target_version 을 다시 공개 주소로 내보낸다. 재수집·재생성을 하지 않는다 — 그 버전이 발행될 때 박제된 snapshot 을 그대로 다시 굽는다. 렌더러가 그 사이 바뀌었을 수 있어 게이트는 다시 통과해야 한다. 실패하면 지금 공개된 버전은 그대로다.
|
|
* @summary 예전 버전으로 되돌리기(비동기)
|
|
*/
|
|
export const rollbackVersion = (
|
|
placeId: string,
|
|
reqRollback: ReqRollback,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResStartBuild>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/version/rollback`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqRollback,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getRollbackVersionMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof rollbackVersion>>,
|
|
TError,
|
|
{ placeId: string; data: ReqRollback },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof rollbackVersion>>,
|
|
TError,
|
|
{ placeId: string; data: ReqRollback },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["rollbackVersion"];
|
|
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 rollbackVersion>>,
|
|
{ placeId: string; data: ReqRollback }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return rollbackVersion(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type RollbackVersionMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof rollbackVersion>>
|
|
>;
|
|
export type RollbackVersionMutationBody = ReqRollback;
|
|
export type RollbackVersionMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 예전 버전으로 되돌리기(비동기)
|
|
*/
|
|
export const useRollbackVersion = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof rollbackVersion>>,
|
|
TError,
|
|
{ placeId: string; data: ReqRollback },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof rollbackVersion>>,
|
|
TError,
|
|
{ placeId: string; data: ReqRollback },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getRollbackVersionMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 빌드 버전 목록
|
|
*/
|
|
export const listVersions = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSiteVersions>(
|
|
{ url: `/v1/place/${placeId}/site/version/list`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListVersionsQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/site/version/list`] as const;
|
|
};
|
|
|
|
export const getListVersionsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listVersions>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listVersions>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListVersionsQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listVersions>>> = ({
|
|
signal,
|
|
}) => listVersions(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listVersions>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListVersionsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listVersions>>
|
|
>;
|
|
export type ListVersionsQueryError = void | HTTPValidationError;
|
|
|
|
export function useListVersions<
|
|
TData = Awaited<ReturnType<typeof listVersions>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listVersions>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listVersions>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listVersions>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListVersions<
|
|
TData = Awaited<ReturnType<typeof listVersions>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listVersions>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listVersions>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listVersions>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListVersions<
|
|
TData = Awaited<ReturnType<typeof listVersions>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listVersions>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 빌드 버전 목록
|
|
*/
|
|
|
|
export function useListVersions<
|
|
TData = Awaited<ReturnType<typeof listVersions>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listVersions>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListVersionsQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* 발행 시도와 거부 사유. 게이트가 막았으면 무엇이 문제였는지 detail 에 남는다.
|
|
* @summary 발행 기록
|
|
*/
|
|
export const listLogs = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResPublishLogs>(
|
|
{ url: `/v1/place/${placeId}/site/log/list`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListLogsQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/site/log/list`] as const;
|
|
};
|
|
|
|
export const getListLogsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listLogs>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListLogsQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listLogs>>> = ({
|
|
signal,
|
|
}) => listLogs(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type ListLogsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listLogs>>
|
|
>;
|
|
export type ListLogsQueryError = void | HTTPValidationError;
|
|
|
|
export function useListLogs<
|
|
TData = Awaited<ReturnType<typeof listLogs>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listLogs>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listLogs>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListLogs<
|
|
TData = Awaited<ReturnType<typeof listLogs>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listLogs>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listLogs>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListLogs<
|
|
TData = Awaited<ReturnType<typeof listLogs>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 발행 기록
|
|
*/
|
|
|
|
export function useListLogs<
|
|
TData = Awaited<ReturnType<typeof listLogs>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listLogs>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListLogsQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* ★ 해지는 삭제가 아니라 상태 전이다. 색인된 페이지를 갑자기 404 로 만들면 AI 검색이 그 자리를 다시 OTA 로 채운다.
|
|
* @summary 발행 상태 전이(중지·재개·내림)
|
|
*/
|
|
export const changeStatus = (
|
|
placeId: string,
|
|
reqSiteStatus: ReqSiteStatus,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResSite>(
|
|
{
|
|
url: `/v1/place/${placeId}/site/status`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqSiteStatus,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getChangeStatusMutationOptions = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof changeStatus>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteStatus },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof changeStatus>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteStatus },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["changeStatus"];
|
|
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 changeStatus>>,
|
|
{ placeId: string; data: ReqSiteStatus }
|
|
> = (props) => {
|
|
const { placeId, data } = props ?? {};
|
|
|
|
return changeStatus(placeId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type ChangeStatusMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof changeStatus>>
|
|
>;
|
|
export type ChangeStatusMutationBody = ReqSiteStatus;
|
|
export type ChangeStatusMutationError = void | HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 발행 상태 전이(중지·재개·내림)
|
|
*/
|
|
export const useChangeStatus = <
|
|
TError = void | HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof changeStatus>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteStatus },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof changeStatus>>,
|
|
TError,
|
|
{ placeId: string; data: ReqSiteStatus },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getChangeStatusMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 로그인한 계정(회사)이 가진 사이트 전부. 아직 사이트가 만들어지지 않은 사업장도 site_id=null 로 함께 내려간다 — 위저드를 걸어오다 만 것을 목록에서 잃지 않게 한다.
|
|
* @summary 내 사이트 목록
|
|
*/
|
|
export const listMySites = (
|
|
params?: ListMySitesParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResMySites>(
|
|
{ url: `/v1/site/list`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListMySitesQueryKey = (params?: ListMySitesParams) => {
|
|
return [`/v1/site/list`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getListMySitesQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listMySites>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListMySitesParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMySites>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListMySitesQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMySites>>> = ({
|
|
signal,
|
|
}) => listMySites(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listMySites>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListMySitesQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listMySites>>
|
|
>;
|
|
export type ListMySitesQueryError = void | HTTPValidationError;
|
|
|
|
export function useListMySites<
|
|
TData = Awaited<ReturnType<typeof listMySites>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params: undefined | ListMySitesParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMySites>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listMySites>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listMySites>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListMySites<
|
|
TData = Awaited<ReturnType<typeof listMySites>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListMySitesParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMySites>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listMySites>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listMySites>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListMySites<
|
|
TData = Awaited<ReturnType<typeof listMySites>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListMySitesParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMySites>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 내 사이트 목록
|
|
*/
|
|
|
|
export function useListMySites<
|
|
TData = Awaited<ReturnType<typeof listMySites>>,
|
|
TError = void | HTTPValidationError,
|
|
>(
|
|
params?: ListMySitesParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMySites>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListMySitesQueryOptions(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 sendBookingRequest = (
|
|
reqBookingRequest: ReqBookingRequest,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResBookingRequest>(
|
|
{
|
|
url: `/v1/site/booking-request`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqBookingRequest,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSendBookingRequestMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendBookingRequest>>,
|
|
TError,
|
|
{ data: ReqBookingRequest },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendBookingRequest>>,
|
|
TError,
|
|
{ data: ReqBookingRequest },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["sendBookingRequest"];
|
|
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 sendBookingRequest>>,
|
|
{ data: ReqBookingRequest }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return sendBookingRequest(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SendBookingRequestMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof sendBookingRequest>>
|
|
>;
|
|
export type SendBookingRequestMutationBody = ReqBookingRequest;
|
|
export type SendBookingRequestMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 예약 요청 — 발행본 폼에서 사장님 메일로 전달
|
|
*/
|
|
export const useSendBookingRequest = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendBookingRequest>>,
|
|
TError,
|
|
{ data: ReqBookingRequest },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof sendBookingRequest>>,
|
|
TError,
|
|
{ data: ReqBookingRequest },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSendBookingRequestMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 승인 확정 — 누르는 즉시 게재 큐에 넣는다
|
|
*/
|
|
export const approvePage = (
|
|
params: ApprovePageParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<string>(
|
|
{ url: `/v1/site/post/approve`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getApprovePageQueryKey = (params?: ApprovePageParams) => {
|
|
return [`/v1/site/post/approve`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getApprovePageQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof approvePage>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ApprovePageParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof approvePage>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getApprovePageQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof approvePage>>> = ({
|
|
signal,
|
|
}) => approvePage(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof approvePage>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ApprovePageQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof approvePage>>
|
|
>;
|
|
export type ApprovePageQueryError = HTTPValidationError;
|
|
|
|
export function useApprovePage<
|
|
TData = Awaited<ReturnType<typeof approvePage>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ApprovePageParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof approvePage>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof approvePage>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof approvePage>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useApprovePage<
|
|
TData = Awaited<ReturnType<typeof approvePage>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ApprovePageParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof approvePage>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof approvePage>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof approvePage>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useApprovePage<
|
|
TData = Awaited<ReturnType<typeof approvePage>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ApprovePageParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof approvePage>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 승인 확정 — 누르는 즉시 게재 큐에 넣는다
|
|
*/
|
|
|
|
export function useApprovePage<
|
|
TData = Awaited<ReturnType<typeof approvePage>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ApprovePageParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof approvePage>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getApprovePageQueryOptions(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 listMyPosts = (
|
|
placeId: string,
|
|
params?: ListMyPostsParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResMyPosts>(
|
|
{ url: `/v1/place/${placeId}/post`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListMyPostsQueryKey = (
|
|
placeId?: string,
|
|
params?: ListMyPostsParams,
|
|
) => {
|
|
return [`/v1/place/${placeId}/post`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getListMyPostsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListMyPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMyPosts>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getListMyPostsQueryKey(placeId, params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listMyPosts>>> = ({
|
|
signal,
|
|
}) => listMyPosts(placeId, params, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListMyPostsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listMyPosts>>
|
|
>;
|
|
export type ListMyPostsQueryError = HTTPValidationError;
|
|
|
|
export function useListMyPosts<
|
|
TData = Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: undefined | ListMyPostsParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMyPosts>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listMyPosts>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListMyPosts<
|
|
TData = Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListMyPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMyPosts>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listMyPosts>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListMyPosts<
|
|
TData = Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListMyPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMyPosts>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 이번 달(또는 고른 달) 생성된 글 목록
|
|
*/
|
|
|
|
export function useListMyPosts<
|
|
TData = Awaited<ReturnType<typeof listMyPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListMyPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listMyPosts>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListMyPostsQueryOptions(placeId, params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary 상단 카로셀 — 오늘부터 N일치, 날짜순
|
|
*/
|
|
export const listUpcomingPosts = (
|
|
placeId: string,
|
|
params?: ListUpcomingPostsParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResMyPosts>(
|
|
{
|
|
url: `/v1/place/${placeId}/post/upcoming`,
|
|
method: "GET",
|
|
params,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListUpcomingPostsQueryKey = (
|
|
placeId?: string,
|
|
params?: ListUpcomingPostsParams,
|
|
) => {
|
|
return [
|
|
`/v1/place/${placeId}/post/upcoming`,
|
|
...(params ? [params] : []),
|
|
] as const;
|
|
};
|
|
|
|
export const getListUpcomingPostsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListUpcomingPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getListUpcomingPostsQueryKey(placeId, params);
|
|
|
|
const queryFn: QueryFunction<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>
|
|
> = ({ signal }) =>
|
|
listUpcomingPosts(placeId, params, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListUpcomingPostsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>
|
|
>;
|
|
export type ListUpcomingPostsQueryError = HTTPValidationError;
|
|
|
|
export function useListUpcomingPosts<
|
|
TData = Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params: undefined | ListUpcomingPostsParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListUpcomingPosts<
|
|
TData = Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListUpcomingPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListUpcomingPosts<
|
|
TData = Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListUpcomingPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 상단 카로셀 — 오늘부터 N일치, 날짜순
|
|
*/
|
|
|
|
export function useListUpcomingPosts<
|
|
TData = Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
params?: ListUpcomingPostsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof listUpcomingPosts>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListUpcomingPostsQueryOptions(
|
|
placeId,
|
|
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 getGenerationHistory = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResGenerationHistory>(
|
|
{ url: `/v1/place/${placeId}/post/history`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetGenerationHistoryQueryKey = (placeId?: string) => {
|
|
return [`/v1/place/${placeId}/post/history`] as const;
|
|
};
|
|
|
|
export const getGetGenerationHistoryQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getGetGenerationHistoryQueryKey(placeId);
|
|
|
|
const queryFn: QueryFunction<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>
|
|
> = ({ signal }) => getGenerationHistory(placeId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!placeId,
|
|
...queryOptions,
|
|
} as UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type GetGenerationHistoryQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>
|
|
>;
|
|
export type GetGenerationHistoryQueryError = HTTPValidationError;
|
|
|
|
export function useGetGenerationHistory<
|
|
TData = Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGenerationHistory>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGenerationHistory<
|
|
TData = Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getGenerationHistory>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetGenerationHistory<
|
|
TData = Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 생성 이력 — 언제 몇 건 만들었는지
|
|
*/
|
|
|
|
export function useGetGenerationHistory<
|
|
TData = Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<
|
|
Awaited<ReturnType<typeof getGenerationHistory>>,
|
|
TError,
|
|
TData
|
|
>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetGenerationHistoryQueryOptions(placeId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary 글 하나 — 메일 수정 링크(자동 로그인)가 쓴다
|
|
*/
|
|
export const getMyPost = (
|
|
placeId: string,
|
|
postId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResMyPosts>(
|
|
{ url: `/v1/place/${placeId}/post/${postId}`, method: "GET", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGetMyPostQueryKey = (placeId?: string, postId?: string) => {
|
|
return [`/v1/place/${placeId}/post/${postId}`] as const;
|
|
};
|
|
|
|
export const getGetMyPostQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof getMyPost>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
postId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey =
|
|
queryOptions?.queryKey ?? getGetMyPostQueryKey(placeId, postId);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof getMyPost>>> = ({
|
|
signal,
|
|
}) => getMyPost(placeId, postId, requestOptions, signal);
|
|
|
|
return {
|
|
queryKey,
|
|
queryFn,
|
|
enabled: !!(placeId && postId),
|
|
...queryOptions,
|
|
} as UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
};
|
|
|
|
export type GetMyPostQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof getMyPost>>
|
|
>;
|
|
export type GetMyPostQueryError = HTTPValidationError;
|
|
|
|
export function useGetMyPost<
|
|
TData = Awaited<ReturnType<typeof getMyPost>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
postId: string,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMyPost>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMyPost>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMyPost<
|
|
TData = Awaited<ReturnType<typeof getMyPost>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
postId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof getMyPost>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof getMyPost>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useGetMyPost<
|
|
TData = Awaited<ReturnType<typeof getMyPost>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
postId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 글 하나 — 메일 수정 링크(자동 로그인)가 쓴다
|
|
*/
|
|
|
|
export function useGetMyPost<
|
|
TData = Awaited<ReturnType<typeof getMyPost>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
placeId: string,
|
|
postId: string,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof getMyPost>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getGetMyPostQueryOptions(placeId, postId, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|
|
|
|
/**
|
|
* @summary 로그인 세션으로 직접 수정 — 저장만, 승인은 이메일로
|
|
*/
|
|
export const editMyPost = (
|
|
placeId: string,
|
|
postId: string,
|
|
reqEditPost: ReqEditPost,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
) => {
|
|
return customFetch<ResWebPacketProtocol>(
|
|
{
|
|
url: `/v1/place/${placeId}/post/${postId}`,
|
|
method: "PUT",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqEditPost,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getEditMyPostMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof editMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string; data: ReqEditPost },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof editMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string; data: ReqEditPost },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["editMyPost"];
|
|
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 editMyPost>>,
|
|
{ placeId: string; postId: string; data: ReqEditPost }
|
|
> = (props) => {
|
|
const { placeId, postId, data } = props ?? {};
|
|
|
|
return editMyPost(placeId, postId, data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type EditMyPostMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof editMyPost>>
|
|
>;
|
|
export type EditMyPostMutationBody = ReqEditPost;
|
|
export type EditMyPostMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 로그인 세션으로 직접 수정 — 저장만, 승인은 이메일로
|
|
*/
|
|
export const useEditMyPost = <TError = HTTPValidationError, TContext = unknown>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof editMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string; data: ReqEditPost },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof editMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string; data: ReqEditPost },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getEditMyPostMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 글 삭제 — 게재된 글이면 재발행까지 큐에 넣는다
|
|
*/
|
|
export const deleteMyPost = (
|
|
placeId: string,
|
|
postId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
) => {
|
|
return customFetch<ResWebPacketProtocol>(
|
|
{ url: `/v1/place/${placeId}/post/${postId}`, method: "DELETE" },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getDeleteMyPostMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["deleteMyPost"];
|
|
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 deleteMyPost>>,
|
|
{ placeId: string; postId: string }
|
|
> = (props) => {
|
|
const { placeId, postId } = props ?? {};
|
|
|
|
return deleteMyPost(placeId, postId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type DeleteMyPostMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof deleteMyPost>>
|
|
>;
|
|
|
|
export type DeleteMyPostMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 글 삭제 — 게재된 글이면 재발행까지 큐에 넣는다
|
|
*/
|
|
export const useDeleteMyPost = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof deleteMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof deleteMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getDeleteMyPostMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 바로 발행 — 로그인 세션으로 고치지 않고 그대로(또는 방금 고친 그대로) 승인
|
|
*/
|
|
export const approveMyPost = (
|
|
placeId: string,
|
|
postId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResWebPacketProtocol>(
|
|
{
|
|
url: `/v1/place/${placeId}/post/${postId}/approve`,
|
|
method: "POST",
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getApproveMyPostMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof approveMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof approveMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["approveMyPost"];
|
|
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 approveMyPost>>,
|
|
{ placeId: string; postId: string }
|
|
> = (props) => {
|
|
const { placeId, postId } = props ?? {};
|
|
|
|
return approveMyPost(placeId, postId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type ApproveMyPostMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof approveMyPost>>
|
|
>;
|
|
|
|
export type ApproveMyPostMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 바로 발행 — 로그인 세션으로 고치지 않고 그대로(또는 방금 고친 그대로) 승인
|
|
*/
|
|
export const useApproveMyPost = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof approveMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof approveMyPost>>,
|
|
TError,
|
|
{ placeId: string; postId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getApproveMyPostMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 승인 알림보내기 — 아침 9시 스윕을 기다리지 않고 이 업장의 오늘 몫을 바로 보낸다
|
|
*/
|
|
export const sendMyPostsNow = (
|
|
placeId: string,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResWebPacketProtocol>(
|
|
{ url: `/v1/place/${placeId}/post/send-now`, method: "POST", signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSendMyPostsNowMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendMyPostsNow>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendMyPostsNow>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["sendMyPostsNow"];
|
|
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 sendMyPostsNow>>,
|
|
{ placeId: string }
|
|
> = (props) => {
|
|
const { placeId } = props ?? {};
|
|
|
|
return sendMyPostsNow(placeId, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SendMyPostsNowMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof sendMyPostsNow>>
|
|
>;
|
|
|
|
export type SendMyPostsNowMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 승인 알림보내기 — 아침 9시 스윕을 기다리지 않고 이 업장의 오늘 몫을 바로 보낸다
|
|
*/
|
|
export const useSendMyPostsNow = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof sendMyPostsNow>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof sendMyPostsNow>>,
|
|
TError,
|
|
{ placeId: string },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSendMyPostsNowMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 지금 생성하기 — 새벽 크론(04:10)을 기다리지 않고, 고른 구간을 채운다
|
|
*/
|
|
export const generateMyPosts = (
|
|
placeId: string,
|
|
params: GenerateMyPostsParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResGenerateNow>(
|
|
{
|
|
url: `/v1/place/${placeId}/post/generate`,
|
|
method: "POST",
|
|
params,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGenerateMyPostsMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPosts>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostsParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPosts>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostsParams },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["generateMyPosts"];
|
|
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 generateMyPosts>>,
|
|
{ placeId: string; params: GenerateMyPostsParams }
|
|
> = (props) => {
|
|
const { placeId, params } = props ?? {};
|
|
|
|
return generateMyPosts(placeId, params, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type GenerateMyPostsMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof generateMyPosts>>
|
|
>;
|
|
|
|
export type GenerateMyPostsMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 지금 생성하기 — 새벽 크론(04:10)을 기다리지 않고, 고른 구간을 채운다
|
|
*/
|
|
export const useGenerateMyPosts = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPosts>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostsParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof generateMyPosts>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostsParams },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getGenerateMyPostsMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 개별 생성 — 달력에서 빈 날짜 하나만 콕 집어 채운다
|
|
*/
|
|
export const generateMyPostForDate = (
|
|
placeId: string,
|
|
params: GenerateMyPostForDateParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResGenerateOne>(
|
|
{
|
|
url: `/v1/place/${placeId}/post/generate-one`,
|
|
method: "POST",
|
|
params,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getGenerateMyPostForDateMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPostForDate>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostForDateParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPostForDate>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostForDateParams },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["generateMyPostForDate"];
|
|
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 generateMyPostForDate>>,
|
|
{ placeId: string; params: GenerateMyPostForDateParams }
|
|
> = (props) => {
|
|
const { placeId, params } = props ?? {};
|
|
|
|
return generateMyPostForDate(placeId, params, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type GenerateMyPostForDateMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof generateMyPostForDate>>
|
|
>;
|
|
|
|
export type GenerateMyPostForDateMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 개별 생성 — 달력에서 빈 날짜 하나만 콕 집어 채운다
|
|
*/
|
|
export const useGenerateMyPostForDate = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof generateMyPostForDate>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostForDateParams },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof generateMyPostForDate>>,
|
|
TError,
|
|
{ placeId: string; params: GenerateMyPostForDateParams },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getGenerateMyPostForDateMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* @summary 이용 후기 남기기
|
|
*/
|
|
export const submitReview = (
|
|
reqReview: ReqReview,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResReview>(
|
|
{
|
|
url: `/v1/site/review`,
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
data: reqReview,
|
|
signal,
|
|
},
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getSubmitReviewMutationOptions = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof submitReview>>,
|
|
TError,
|
|
{ data: ReqReview },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
}): UseMutationOptions<
|
|
Awaited<ReturnType<typeof submitReview>>,
|
|
TError,
|
|
{ data: ReqReview },
|
|
TContext
|
|
> => {
|
|
const mutationKey = ["submitReview"];
|
|
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 submitReview>>,
|
|
{ data: ReqReview }
|
|
> = (props) => {
|
|
const { data } = props ?? {};
|
|
|
|
return submitReview(data, requestOptions);
|
|
};
|
|
|
|
return { mutationFn, ...mutationOptions };
|
|
};
|
|
|
|
export type SubmitReviewMutationResult = NonNullable<
|
|
Awaited<ReturnType<typeof submitReview>>
|
|
>;
|
|
export type SubmitReviewMutationBody = ReqReview;
|
|
export type SubmitReviewMutationError = HTTPValidationError;
|
|
|
|
/**
|
|
* @summary 이용 후기 남기기
|
|
*/
|
|
export const useSubmitReview = <
|
|
TError = HTTPValidationError,
|
|
TContext = unknown,
|
|
>(
|
|
options?: {
|
|
mutation?: UseMutationOptions<
|
|
Awaited<ReturnType<typeof submitReview>>,
|
|
TError,
|
|
{ data: ReqReview },
|
|
TContext
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseMutationResult<
|
|
Awaited<ReturnType<typeof submitReview>>,
|
|
TError,
|
|
{ data: ReqReview },
|
|
TContext
|
|
> => {
|
|
const mutationOptions = getSubmitReviewMutationOptions(options);
|
|
|
|
return useMutation(mutationOptions, queryClient);
|
|
};
|
|
/**
|
|
* 날씨(/v1/local/weather)와 같은 공개 조회다. 구운 HTML 에는 굽는 시점의 후기가 들어 있고,
|
|
화면은 붙은 뒤 이 주소로 최신을 받아 덮는다.
|
|
* @summary 게재된 후기 — 발행본이 붙은 뒤 받아 간다
|
|
*/
|
|
export const listReviews = (
|
|
params: ListReviewsParams,
|
|
options?: SecondParameter<typeof customFetch>,
|
|
signal?: AbortSignal,
|
|
) => {
|
|
return customFetch<ResPublicReviews>(
|
|
{ url: `/v1/site/reviews`, method: "GET", params, signal },
|
|
options,
|
|
);
|
|
};
|
|
|
|
export const getListReviewsQueryKey = (params?: ListReviewsParams) => {
|
|
return [`/v1/site/reviews`, ...(params ? [params] : [])] as const;
|
|
};
|
|
|
|
export const getListReviewsQueryOptions = <
|
|
TData = Awaited<ReturnType<typeof listReviews>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ListReviewsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listReviews>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
) => {
|
|
const { query: queryOptions, request: requestOptions } = options ?? {};
|
|
|
|
const queryKey = queryOptions?.queryKey ?? getListReviewsQueryKey(params);
|
|
|
|
const queryFn: QueryFunction<Awaited<ReturnType<typeof listReviews>>> = ({
|
|
signal,
|
|
}) => listReviews(params, requestOptions, signal);
|
|
|
|
return { queryKey, queryFn, ...queryOptions } as UseQueryOptions<
|
|
Awaited<ReturnType<typeof listReviews>>,
|
|
TError,
|
|
TData
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
};
|
|
|
|
export type ListReviewsQueryResult = NonNullable<
|
|
Awaited<ReturnType<typeof listReviews>>
|
|
>;
|
|
export type ListReviewsQueryError = HTTPValidationError;
|
|
|
|
export function useListReviews<
|
|
TData = Awaited<ReturnType<typeof listReviews>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ListReviewsParams,
|
|
options: {
|
|
query: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listReviews>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
DefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listReviews>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listReviews>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): DefinedUseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListReviews<
|
|
TData = Awaited<ReturnType<typeof listReviews>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ListReviewsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listReviews>>, TError, TData>
|
|
> &
|
|
Pick<
|
|
UndefinedInitialDataOptions<
|
|
Awaited<ReturnType<typeof listReviews>>,
|
|
TError,
|
|
Awaited<ReturnType<typeof listReviews>>
|
|
>,
|
|
"initialData"
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
export function useListReviews<
|
|
TData = Awaited<ReturnType<typeof listReviews>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ListReviewsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listReviews>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
};
|
|
/**
|
|
* @summary 게재된 후기 — 발행본이 붙은 뒤 받아 간다
|
|
*/
|
|
|
|
export function useListReviews<
|
|
TData = Awaited<ReturnType<typeof listReviews>>,
|
|
TError = HTTPValidationError,
|
|
>(
|
|
params: ListReviewsParams,
|
|
options?: {
|
|
query?: Partial<
|
|
UseQueryOptions<Awaited<ReturnType<typeof listReviews>>, TError, TData>
|
|
>;
|
|
request?: SecondParameter<typeof customFetch>;
|
|
},
|
|
queryClient?: QueryClient,
|
|
): UseQueryResult<TData, TError> & {
|
|
queryKey: DataTag<QueryKey, TData, TError>;
|
|
} {
|
|
const queryOptions = getListReviewsQueryOptions(params, options);
|
|
|
|
const query = useQuery(queryOptions, queryClient) as UseQueryResult<
|
|
TData,
|
|
TError
|
|
> & { queryKey: DataTag<QueryKey, TData, TError> };
|
|
|
|
query.queryKey = queryOptions.queryKey;
|
|
|
|
return query;
|
|
}
|