[feat] solution: 미니블로그 빌더 기능 확장 — 알림 이메일 분리·삭제·즉시발송·공급자 무관 생성
빌더 앱에서 미니블로그를 운영하는 데 필요했던 몇 가지를 묶었다. - notify_email: 업장별 승인 메일 수신자를 계정 로그인 이메일과 분리(places.notify_email, migrations/0021, PlaceCRUD·protocol.py·place_service.py 검증, BlogPostsPage.tsx 설정 UI) - 글 삭제(soft delete): 상태 제한 없이 지우고, 이미 게재된 글이면 재발행 잡까지 큐에 넣는다 (post_crud.py, router/v1/site/post.py DELETE, BlogPostsPage.tsx 삭제 버튼) - 지금 발송하기: 아침 9시 스윕을 안 기다리고 바로 발송(post_crud.next_due_for_mail, BlogPostsPage.tsx 버튼) - blog_service.generate_one: 하드코딩된 Gemini 대신 services/llm/provider.py(LLM_PROVIDER, 기본 openai)를 타도록 전환, 업종별 분기 구조(현재 숙소만 구현) 추가 - site_payload.publish_url(place, site): 발행 주소 조합을 한 곳에 모은 헬퍼 - 프론트: orval 로 재생성한 API 클라이언트(notify_email·삭제·즉시발송·social 엔드포인트 반영) 관련 스위트는 별도 커밋(쓰레드 연동 작업)에서 이미 PASS 확인함
This commit is contained in:
1 parent
adb3460c37
commit
81ea676546
24 files changed
+1813
-44
No files matched your search
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ApprovalParams = {
|
||||
/**
|
||||
* @minLength 40
|
||||
* @maxLength 100
|
||||
*/
|
||||
t: string;
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type CallbackParams = {
|
||||
/**
|
||||
* @maxLength 2048
|
||||
*/
|
||||
state?: string;
|
||||
/**
|
||||
* @maxLength 4096
|
||||
*/
|
||||
code?: string;
|
||||
/**
|
||||
* @maxLength 200
|
||||
*/
|
||||
error?: string;
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface Decision {
|
||||
approve: boolean;
|
||||
}
|
||||
@@ -5,12 +5,15 @@
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export * from "./approvalParams";
|
||||
export * from "./approvePageParams";
|
||||
export * from "./auditCheckData";
|
||||
export * from "./auditCheckDataRecommendation";
|
||||
export * from "./authProvider";
|
||||
export * from "./buildStatus";
|
||||
export * from "./callbackParams";
|
||||
export * from "./checkSlugParams";
|
||||
export * from "./decision";
|
||||
export * from "./errorInfo";
|
||||
export * from "./errorInfoCode";
|
||||
export * from "./errorInfoDesc";
|
||||
@@ -61,6 +64,7 @@ export * from "./linkData";
|
||||
export * from "./linkDataConfirmedAt";
|
||||
export * from "./linkDataDiscoveredAt";
|
||||
export * from "./linkDataTitle";
|
||||
export * from "./linkDecision";
|
||||
export * from "./listContentsParams";
|
||||
export * from "./listFactsParams";
|
||||
export * from "./listFaqsParams";
|
||||
@@ -126,6 +130,7 @@ export * from "./placeDataExternalPlaceId";
|
||||
export * from "./placeDataExternalSource";
|
||||
export * from "./placeDataLatitude";
|
||||
export * from "./placeDataLongitude";
|
||||
export * from "./placeDataNotifyEmail";
|
||||
export * from "./placeDataOwnerUserId";
|
||||
export * from "./placeDataPhone";
|
||||
export * from "./placeDataRegionCode";
|
||||
@@ -208,6 +213,7 @@ export * from "./reqUpdateMeName";
|
||||
export * from "./reqUpdateMePassword";
|
||||
export * from "./reqUpdatePlace";
|
||||
export * from "./reqUpdatePlaceName";
|
||||
export * from "./reqUpdatePlaceNotifyEmail";
|
||||
export * from "./reqUpdatePlaceStatus";
|
||||
export * from "./reqUpsertFact";
|
||||
export * from "./reqUpsertFactExpiresAt";
|
||||
@@ -372,6 +378,7 @@ export * from "./siteVersionDataBuildError";
|
||||
export * from "./siteVersionDataBuiltAt";
|
||||
export * from "./siteVersionDataCreatedAt";
|
||||
export * from "./sourceType";
|
||||
export * from "./testPost";
|
||||
export * from "./unitData";
|
||||
export * from "./userRole";
|
||||
export * from "./validationError";
|
||||
|
||||
@@ -23,4 +23,6 @@ export const JobType = {
|
||||
AI_CHECK: 6,
|
||||
SONG: 7,
|
||||
ROLLBACK: 8,
|
||||
SOCIAL_DRAFT: 9,
|
||||
SOCIAL_POST: 10,
|
||||
} as const;
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface LinkDecision {
|
||||
approve: boolean;
|
||||
/**
|
||||
* @minLength 40
|
||||
* @maxLength 100
|
||||
*/
|
||||
t: string;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import type { PlaceDataLongitude } from "./placeDataLongitude";
|
||||
import type { PlaceDataRegionCode } from "./placeDataRegionCode";
|
||||
import type { PlaceDataVerifiedAt } from "./placeDataVerifiedAt";
|
||||
import type { PlaceDataContentUpdatedAt } from "./placeDataContentUpdatedAt";
|
||||
import type { PlaceDataNotifyEmail } from "./placeDataNotifyEmail";
|
||||
import type { PlaceDataCreatedAt } from "./placeDataCreatedAt";
|
||||
|
||||
export interface PlaceData {
|
||||
@@ -35,5 +36,6 @@ export interface PlaceData {
|
||||
region_code?: PlaceDataRegionCode;
|
||||
verified_at?: PlaceDataVerifiedAt;
|
||||
content_updated_at?: PlaceDataContentUpdatedAt;
|
||||
notify_email?: PlaceDataNotifyEmail;
|
||||
created_at?: PlaceDataCreatedAt;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type PlaceDataNotifyEmail = string | null;
|
||||
@@ -6,8 +6,10 @@
|
||||
*/
|
||||
import type { ReqUpdatePlaceName } from "./reqUpdatePlaceName";
|
||||
import type { ReqUpdatePlaceStatus } from "./reqUpdatePlaceStatus";
|
||||
import type { ReqUpdatePlaceNotifyEmail } from "./reqUpdatePlaceNotifyEmail";
|
||||
|
||||
export interface ReqUpdatePlace {
|
||||
name?: ReqUpdatePlaceName;
|
||||
status?: ReqUpdatePlaceStatus;
|
||||
notify_email?: ReqUpdatePlaceNotifyEmail;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export type ReqUpdatePlaceNotifyEmail = string | null;
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Generated by orval v7.21.0 🍺
|
||||
* Do not edit manually.
|
||||
* Web4Ai API
|
||||
* OpenAPI spec version: 0.1.0
|
||||
*/
|
||||
|
||||
export interface TestPost {
|
||||
/**
|
||||
* @minLength 1
|
||||
* @maxLength 500
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
@@ -2562,7 +2562,7 @@ export function useGetMyPost<
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary 로그인 세션으로 직접 수정·승인
|
||||
* @summary 로그인 세션으로 직접 수정 — 저장만, 승인은 이메일로
|
||||
*/
|
||||
export const editMyPost = (
|
||||
placeId: string,
|
||||
@@ -2626,7 +2626,7 @@ export type EditMyPostMutationBody = ReqEditPost;
|
||||
export type EditMyPostMutationError = HTTPValidationError;
|
||||
|
||||
/**
|
||||
* @summary 로그인 세션으로 직접 수정·승인
|
||||
* @summary 로그인 세션으로 직접 수정 — 저장만, 승인은 이메일로
|
||||
*/
|
||||
export const useEditMyPost = <TError = HTTPValidationError, TContext = unknown>(
|
||||
options?: {
|
||||
@@ -2650,7 +2650,92 @@ export const useEditMyPost = <TError = HTTPValidationError, TContext = unknown>(
|
||||
return useMutation(mutationOptions, queryClient);
|
||||
};
|
||||
/**
|
||||
* @summary 바로 발행 — 고치지 않고 그대로
|
||||
* @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,
|
||||
@@ -2713,7 +2798,7 @@ export type ApproveMyPostMutationResult = NonNullable<
|
||||
export type ApproveMyPostMutationError = HTTPValidationError;
|
||||
|
||||
/**
|
||||
* @summary 바로 발행 — 고치지 않고 그대로
|
||||
* @summary 바로 발행 — 로그인 세션으로 고치지 않고 그대로(또는 방금 고친 그대로) 승인
|
||||
*/
|
||||
export const useApproveMyPost = <
|
||||
TError = HTTPValidationError,
|
||||
@@ -2739,6 +2824,91 @@ export const useApproveMyPost = <
|
||||
|
||||
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)을 기다리지 않고, 고른 구간을 채운다
|
||||
*/
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,15 +1,19 @@
|
||||
import {useEffect, useMemo, useState} from 'react';
|
||||
import {useNavigate, useSearchParams} from 'react-router';
|
||||
import {Loader2, Pencil, Plus, Save, Send, Sparkles, X} from 'lucide-react';
|
||||
import {Loader2, Pencil, Plus, Save, Send, Sparkles, Trash2, X} from 'lucide-react';
|
||||
import {
|
||||
useApproveMyPost,
|
||||
useDeleteMyPost,
|
||||
useEditMyPost,
|
||||
useGenerateMyPostForDate,
|
||||
useGenerateMyPosts,
|
||||
useGetGenerationHistory,
|
||||
useGetMyPost,
|
||||
useGetPlace,
|
||||
useListMyPosts,
|
||||
useListUpcomingPosts,
|
||||
useSendMyPostsNow,
|
||||
useUpdatePlace,
|
||||
type PostData,
|
||||
} from '@/api';
|
||||
import {AppShell, EmptyState, PageContainer} from '@/components/layout/AppShell';
|
||||
@@ -141,7 +145,10 @@ function publishBadge(post: PostData): {label: string; className: string} | null
|
||||
return null;
|
||||
}
|
||||
|
||||
/** 수정 폼 — 저장하면 그대로 승인된다(메일의 "수정해서 올리기"와 같은 규칙). */
|
||||
/**
|
||||
* 수정 폼 — 저장만 한다. 승인은 오직 이메일 링크로만 일어난다(2026-09-21, 사장님 지시:
|
||||
* "승인되야 올라가도록 해야 한다") — 예전엔 저장이 곧 승인이었지만 그 지름길을 없앴다.
|
||||
*/
|
||||
function PostEditor({placeId, post, onDone}: {placeId: string; post: PostData; onDone: () => void}) {
|
||||
const [body, setBody] = useState(post.body);
|
||||
const editMutation = useEditMyPost();
|
||||
@@ -153,7 +160,7 @@ function PostEditor({placeId, post, onDone}: {placeId: string; post: PostData; o
|
||||
notify.error(res.msg || '저장하지 못했습니다. 요금·시간·전화번호처럼 확인되지 않은 내용은 빼 주세요.');
|
||||
return;
|
||||
}
|
||||
notify.success('저장하고 승인했습니다. 사이트에 반영되기까지 몇 분 걸립니다.');
|
||||
notify.success('저장했습니다. 이메일 승인 링크를 눌러야 사이트에 반영됩니다.');
|
||||
onDone();
|
||||
} catch (error) {
|
||||
notifyApiError(error, '저장하지 못했습니다.');
|
||||
@@ -171,7 +178,7 @@ function PostEditor({placeId, post, onDone}: {placeId: string; post: PostData; o
|
||||
<div className="flex items-center gap-2">
|
||||
<Button size="sm" variant="primary" isLoading={editMutation.isPending} onClick={handleSave}>
|
||||
<Save />
|
||||
저장하고 승인
|
||||
저장
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" onClick={onDone} disabled={editMutation.isPending}>
|
||||
<X />
|
||||
@@ -186,10 +193,11 @@ function PostCard({placeId, post, onChanged}: {placeId: string; post: PostData;
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const status = STATUS_LABEL[post.status] ?? STATUS_LABEL[1];
|
||||
const editable = EDITABLE_STATUSES.has(post.status);
|
||||
const approveMutation = useApproveMyPost();
|
||||
const {text, chip} = post.scheduled_date ? dateLabel(post.scheduled_date) : {text: '', chip: null};
|
||||
const deleteMutation = useDeleteMyPost();
|
||||
const approveMutation = useApproveMyPost();
|
||||
|
||||
const handlePublish = async () => {
|
||||
const handleApprove = async () => {
|
||||
try {
|
||||
const res = await approveMutation.mutateAsync({placeId, postId: post.post_id});
|
||||
if (!res.result?.success) {
|
||||
@@ -203,6 +211,23 @@ function PostCard({placeId, post, onChanged}: {placeId: string; post: PostData;
|
||||
}
|
||||
};
|
||||
|
||||
const handleDelete = async () => {
|
||||
// 이미 게재된 글은 지우면 사이트에서도 빠지기까지 재발행이 걸린다 — 되돌릴 수 없는
|
||||
// 작업이라 한 번 확인한다(SitesPage.tsx 의 발행 내리기와 같은 관례).
|
||||
if (!window.confirm('이 글을 삭제할까요? 게재된 글이면 사이트에서도 곧 사라집니다.')) return;
|
||||
try {
|
||||
const res = await deleteMutation.mutateAsync({placeId, postId: post.post_id});
|
||||
if (!res.result?.success) {
|
||||
notify.error(res.msg || '삭제하지 못했습니다.');
|
||||
return;
|
||||
}
|
||||
notify.success('삭제했습니다.');
|
||||
onChanged();
|
||||
} catch (error) {
|
||||
notifyApiError(error, '삭제하지 못했습니다.');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col rounded-lg border border-border bg-card p-3.5 shadow-lg">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
@@ -228,15 +253,35 @@ function PostCard({placeId, post, onChanged}: {placeId: string; post: PostData;
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{editable && !isEditing && (
|
||||
{!isEditing && (
|
||||
<div className="mt-3 flex items-center gap-1.5 border-t border-border pt-3">
|
||||
<Button size="sm" variant="ghost" className="flex-1" onClick={() => setIsEditing(true)}>
|
||||
<Pencil />
|
||||
수정
|
||||
</Button>
|
||||
<Button size="sm" variant="primary" className="flex-1" isLoading={approveMutation.isPending} onClick={handlePublish}>
|
||||
<Send />
|
||||
바로 발행
|
||||
{editable && (
|
||||
<Button size="sm" variant="ghost" className="flex-1" onClick={() => setIsEditing(true)}>
|
||||
<Pencil />
|
||||
수정
|
||||
</Button>
|
||||
)}
|
||||
{editable && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
className="flex-1"
|
||||
isLoading={approveMutation.isPending}
|
||||
onClick={handleApprove}
|
||||
>
|
||||
<Send />
|
||||
바로 발행
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="flex-1 text-destructive hover:text-destructive"
|
||||
isLoading={deleteMutation.isPending}
|
||||
onClick={handleDelete}
|
||||
>
|
||||
<Trash2 />
|
||||
삭제
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@@ -442,6 +487,78 @@ function GenerationHistoryList({placeId}: {placeId: string}) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 승인 메일을 받을 주소 — 계정 로그인 이메일(users.email)과 분리한 업장별 설정
|
||||
* (2026-09-21, 사장님 요청: "그 이메일은 변경 가능하도록"). 비워서 저장하면 계정
|
||||
* 이메일로 되돌아간다.
|
||||
*/
|
||||
function NotifyEmailSetting({placeId}: {placeId: string}) {
|
||||
const {data: placeRes} = useGetPlace(placeId, {query: {enabled: !!placeId}});
|
||||
const savedEmail = placeRes?.place?.notify_email ?? '';
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const [value, setValue] = useState(savedEmail);
|
||||
const updateMutation = useUpdatePlace();
|
||||
|
||||
useEffect(() => {
|
||||
setValue(savedEmail);
|
||||
}, [savedEmail]);
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
const res = await updateMutation.mutateAsync({placeId, data: {notify_email: value.trim()}});
|
||||
if (!res.result?.success) {
|
||||
notify.error(res.msg || '저장하지 못했습니다. 이메일 형식을 확인해 주세요.');
|
||||
return;
|
||||
}
|
||||
notify.success('알림 이메일을 저장했습니다.');
|
||||
setIsEditing(false);
|
||||
} catch (error) {
|
||||
notifyApiError(error, '저장하지 못했습니다.');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mb-4 flex flex-wrap items-center gap-2 rounded-md border border-border bg-muted/30 px-3 py-2 text-sm">
|
||||
<span className="text-muted-foreground">승인 메일 받을 주소</span>
|
||||
{isEditing ? (
|
||||
<>
|
||||
<input
|
||||
type="email"
|
||||
value={value}
|
||||
onChange={(event) => setValue(event.target.value)}
|
||||
placeholder="비우면 계정 이메일로 받습니다"
|
||||
className="min-w-52 flex-1 rounded-md border border-border bg-card px-2 py-1 text-sm outline-none focus:border-ring focus:ring-1 focus:ring-ring"
|
||||
/>
|
||||
<Button size="sm" variant="primary" isLoading={updateMutation.isPending} onClick={handleSave}>
|
||||
<Save />
|
||||
저장
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
disabled={updateMutation.isPending}
|
||||
onClick={() => {
|
||||
setIsEditing(false);
|
||||
setValue(savedEmail);
|
||||
}}
|
||||
>
|
||||
<X />
|
||||
취소
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<span className="font-medium">{savedEmail || '(계정 이메일 사용)'}</span>
|
||||
<Button size="sm" variant="ghost" onClick={() => setIsEditing(true)}>
|
||||
<Pencil />
|
||||
변경
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 이번 달(또는 고른 달) 생성된 미니 블로그 글. 기획: docs/MINI_BLOG.md
|
||||
*
|
||||
@@ -506,6 +623,7 @@ export function BlogPostsPage() {
|
||||
const generateMutation = useGenerateMyPosts();
|
||||
const generateOneMutation = useGenerateMyPostForDate();
|
||||
const generatingDay = generateOneMutation.isPending ? (generateOneMutation.variables?.params.date ?? null) : null;
|
||||
const sendNowMutation = useSendMyPostsNow();
|
||||
|
||||
const [rangeDialogOpen, setRangeDialogOpen] = useState(false);
|
||||
const [rangeStart, setRangeStart] = useState(todayIso());
|
||||
@@ -546,11 +664,31 @@ export function BlogPostsPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSendNow = async () => {
|
||||
try {
|
||||
const res = await sendNowMutation.mutateAsync({placeId});
|
||||
if (!res.result?.success) {
|
||||
notify.error(res.msg || '발송하지 못했습니다.');
|
||||
return;
|
||||
}
|
||||
notify.success(res.msg ?? '보냈습니다.');
|
||||
refetchAll();
|
||||
} catch (sendNowError) {
|
||||
notifyApiError(sendNowError, '발송하지 못했습니다.');
|
||||
}
|
||||
};
|
||||
|
||||
const generateButton = (
|
||||
<Button size="sm" variant="primary" onClick={() => setRangeDialogOpen(true)}>
|
||||
<Sparkles />
|
||||
지금 생성하기
|
||||
</Button>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Button size="sm" variant="ghost" isLoading={sendNowMutation.isPending} onClick={handleSendNow}>
|
||||
<Send />
|
||||
지금 발송하기
|
||||
</Button>
|
||||
<Button size="sm" variant="primary" onClick={() => setRangeDialogOpen(true)}>
|
||||
<Sparkles />
|
||||
지금 생성하기
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
|
||||
const maxGenerateDate = lastDayOfMonthIso(maxMonth);
|
||||
@@ -595,6 +733,8 @@ export function BlogPostsPage() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
<NotifyEmailSetting placeId={placeId} />
|
||||
|
||||
{tab === 'main' && (
|
||||
<>
|
||||
{upcomingPosts.length > 0 ? (
|
||||
|
||||
Reference in new issue
Block a user