구조: admin 을 backend/frontend 로 가른다
admin/ 이 프론트 파일만 널려 있는 폴더였다. :9801 을 띄우는 코드도 solution/backend 안에 얹혀 있어서, 폴더만 봐서는 admin 에 백엔드가 있다는 걸 몰랐다. admin/backend/ main.py · app.py (:9801 진입점. 도메인 코드는 PYTHONPATH 로 solution/backend) admin/frontend/ 운영 화면 패키지 이름도 폴더에 맞췄다: @o2o/front → @o2o/frontend. 이미지 빌드 컨텍스트를 레포 루트로 올렸다 — 진입점(admin/)과 도메인 코드(solution/)가 한 이미지에 들어와야 한다. 루트 .dockerignore 로 프론트·문서·시크릿을 잘라냈다. ★ 실측으로 잡은 것: 패키지명을 바꾸면서 compose 의 `-w @o2o/front` 를 안 고쳐 web 컨테이너가 `No workspaces found` 로 재기동 루프에 빠져 있었다. 주석은 짧게 줄였다. 검증: lint·build 6개 전부 0. 컨테이너 5개 엔드포인트(9800·9801·3000·3002·80) 전부 200. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019uYhHQdssRubirPirrdJJC
This commit is contained in:
1 parent
cabcdeaacc
commit
374a3a4a6e
24 files changed
+110
-111
No files matched your search
@@ -0,0 +1,341 @@
|
||||
import {Link, useParams} from 'react-router';
|
||||
import {useQueryClient} from '@tanstack/react-query';
|
||||
import {Check, ExternalLink, Link2, Loader2, Pencil, Search, ShieldQuestion} from 'lucide-react';
|
||||
import {useState} from 'react';
|
||||
import {FactStatus, isPublishableFact} from '@o2o/shared';
|
||||
import {
|
||||
getListFactsQueryKey,
|
||||
getListLinksQueryKey,
|
||||
useConfirmLink,
|
||||
useGetPlace,
|
||||
useGetSchema,
|
||||
useListFacts,
|
||||
useListLinks,
|
||||
useTransitionFact,
|
||||
} from '@/api';
|
||||
import type {FactData, FieldSpecData} from '@/api';
|
||||
import {EmptyState, PageContainer} from '@/components/layout/AppShell';
|
||||
import {PasteFactsPanel, RecollectPanel} from '@/features/onboarding';
|
||||
import {Badge} from '@/components/ui/badge';
|
||||
import {Button} from '@/components/ui/button';
|
||||
import {Input} from '@/components/ui/input';
|
||||
import {notify, notifyApiError} from '@/lib/notify';
|
||||
import {cn} from '@/lib/utils';
|
||||
|
||||
const FACT_STATUS_LABEL: Record<number, string> = {
|
||||
[FactStatus.UNVERIFIED]: '미검증',
|
||||
[FactStatus.PENDING_OWNER]: '사장님 확인 대기',
|
||||
[FactStatus.VERIFIED]: '확인됨',
|
||||
[FactStatus.CORRECTED]: '사장님이 고침',
|
||||
[FactStatus.REJECTED]: '틀린 값',
|
||||
[FactStatus.EXPIRED]: '만료',
|
||||
};
|
||||
|
||||
export function PlaceDetailPage() {
|
||||
const {placeId = ''} = useParams();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const enabled = Boolean(placeId);
|
||||
|
||||
const placeQuery = useGetPlace(placeId, {query: {enabled}});
|
||||
const schemaQuery = useGetSchema(placeId, {query: {enabled}});
|
||||
const factsQuery = useListFacts(placeId, undefined, {query: {enabled}});
|
||||
const linksQuery = useListLinks(placeId, {confirmed_only: false}, {query: {enabled}});
|
||||
|
||||
const transition = useTransitionFact({
|
||||
mutation: {
|
||||
onSuccess: (res) => {
|
||||
// ★ 백엔드는 거절도 200 + result.success=false 로 준다 — 여기서 안 걸러내면
|
||||
// 저장되지 않은 값이 '확인됨'으로 보인다.
|
||||
if (res.result?.success === false) {
|
||||
notifyApiError({data: res}, '허용되지 않는 상태 전이입니다.');
|
||||
return;
|
||||
}
|
||||
notify.success('반영했습니다');
|
||||
void queryClient.invalidateQueries({queryKey: getListFactsQueryKey(placeId)});
|
||||
},
|
||||
onError: (error) => notifyApiError(error),
|
||||
},
|
||||
});
|
||||
|
||||
const confirmLink = useConfirmLink({
|
||||
mutation: {
|
||||
onSuccess: () => {
|
||||
notify.success('채널 URL을 확정했습니다', '이제 이 URL이 수집 대상이 됩니다.');
|
||||
void queryClient.invalidateQueries({queryKey: getListLinksQueryKey(placeId)});
|
||||
},
|
||||
onError: (error) => notifyApiError(error, '사업장 검증이 끝나야 확정할 수 있습니다.'),
|
||||
},
|
||||
});
|
||||
|
||||
const place = placeQuery.data?.place;
|
||||
const facts = factsQuery.data?.facts ?? [];
|
||||
const specs = schemaQuery.data?.fields ?? [];
|
||||
const links = linksQuery.data?.links ?? [];
|
||||
|
||||
const specByKey = new Map(specs.map((s) => [s.key, s]));
|
||||
const pending = facts.filter((f) => !isPublishableFact(f.status));
|
||||
const publishable = facts.filter((f) => isPublishableFact(f.status));
|
||||
|
||||
if (placeQuery.isLoading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-16 text-muted-foreground">
|
||||
<Loader2 className="size-5 animate-spin" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (!place) {
|
||||
return (
|
||||
<PageContainer title="사업장">
|
||||
<EmptyState
|
||||
title="사업장을 찾지 못했습니다"
|
||||
description="주소가 맞는지, 백엔드가 떠 있는지 확인해 주세요."
|
||||
/>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
title={place.name}
|
||||
description={place.road_address ?? place.address ?? '주소 미확정'}
|
||||
actions={
|
||||
<Link
|
||||
to={`/places/${placeId}/seo`}
|
||||
className="inline-flex h-9 items-center gap-1.5 rounded-md border border-border px-3 text-xs font-medium transition-colors hover:bg-muted"
|
||||
>
|
||||
<Search className="size-3.5" />
|
||||
<span>AI 검색 노출 점검</span>
|
||||
</Link>
|
||||
}
|
||||
>
|
||||
{!place.verified_at && (
|
||||
<div className="mb-4 flex items-start gap-2 rounded-lg border border-warning/40 bg-warning/8 p-3 text-xs">
|
||||
<ShieldQuestion className="mt-0.5 size-4 shrink-0 text-warning" />
|
||||
<div>
|
||||
<p className="font-bold">동일 업소 검증 전입니다</p>
|
||||
<p className="mt-0.5 text-muted-foreground">
|
||||
같은 이름의 다른 업소와 섞이는 것을 막기 위해, 검증을 통과해야 수집·발행이 열립니다.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid gap-5 lg:grid-cols-3">
|
||||
<section className="space-y-3 lg:col-span-2">
|
||||
<header className="flex items-center justify-between">
|
||||
<h2 className="text-sm font-semibold">확인 대기 정보 ({pending.length})</h2>
|
||||
<span className="text-[11px] text-muted-foreground">
|
||||
사이트 노출 가능 {publishable.length} / 전체 {facts.length}
|
||||
</span>
|
||||
</header>
|
||||
|
||||
{factsQuery.isLoading ? (
|
||||
<div className="flex justify-center py-10 text-muted-foreground">
|
||||
<Loader2 className="size-4 animate-spin" />
|
||||
</div>
|
||||
) : pending.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Check}
|
||||
title="확인 대기 항목이 없습니다"
|
||||
description="확인된 정보만 사이트와 구조화 데이터에 나갑니다."
|
||||
/>
|
||||
) : (
|
||||
<ul className="space-y-2">
|
||||
{pending.map((fact) => (
|
||||
<FactRow
|
||||
key={fact.fact_id}
|
||||
fact={fact}
|
||||
spec={specByKey.get(fact.key)}
|
||||
isPending={transition.isPending}
|
||||
onVerify={() =>
|
||||
transition.mutate({
|
||||
placeId,
|
||||
factId: fact.fact_id,
|
||||
data: {status: FactStatus.VERIFIED},
|
||||
})
|
||||
}
|
||||
onCorrect={(value) =>
|
||||
transition.mutate({
|
||||
placeId,
|
||||
factId: fact.fact_id,
|
||||
data: {status: FactStatus.CORRECTED, value},
|
||||
})
|
||||
}
|
||||
onReject={() =>
|
||||
transition.mutate({
|
||||
placeId,
|
||||
factId: fact.fact_id,
|
||||
data: {status: FactStatus.REJECTED},
|
||||
})
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="space-y-5">
|
||||
{/* ★ 재수집은 오른쪽 열 맨 위다. 이 화면에 온 사장님의 두 가지 용건이
|
||||
"확인 대기 값을 처리한다"(왼쪽)와 "값을 다시 가져온다"(여기)라서다. */}
|
||||
<RecollectPanel placeId={placeId} />
|
||||
|
||||
<PasteFactsPanel placeId={placeId} />
|
||||
|
||||
<section className="space-y-3">
|
||||
<h2 className="text-sm font-semibold">채널 URL ({links.length})</h2>
|
||||
<p className="text-[11px] leading-relaxed text-muted-foreground">
|
||||
등록만으로는 수집 대상이 되지 않습니다. <strong>확정</strong>한 URL만 수집합니다.
|
||||
</p>
|
||||
|
||||
{links.length === 0 ? (
|
||||
<EmptyState icon={Link2} title="등록된 채널이 없습니다" />
|
||||
) : (
|
||||
<ul className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
|
||||
{links.map((link) => (
|
||||
<li key={link.link_id} className="flex items-center justify-between gap-2 p-3">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-xs font-medium">{link.title ?? link.url}</p>
|
||||
<a
|
||||
href={link.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="inline-flex items-center gap-0.5 truncate text-[11px] text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<span className="truncate">{link.url}</span>
|
||||
<ExternalLink className="size-3 shrink-0" />
|
||||
</a>
|
||||
</div>
|
||||
{link.confirmed_at ? (
|
||||
<Badge variant="success" className="shrink-0">
|
||||
확정
|
||||
</Badge>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="shrink-0"
|
||||
disabled={!place.verified_at || confirmLink.isPending}
|
||||
onClick={() => confirmLink.mutate({placeId, linkId: link.link_id})}
|
||||
>
|
||||
확정
|
||||
</Button>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
function FactRow({
|
||||
fact,
|
||||
spec,
|
||||
isPending,
|
||||
onVerify,
|
||||
onCorrect,
|
||||
onReject,
|
||||
}: {
|
||||
fact: FactData;
|
||||
spec?: FieldSpecData;
|
||||
isPending: boolean;
|
||||
onVerify: () => void;
|
||||
onCorrect: (value: string) => void;
|
||||
onReject: () => void;
|
||||
}) {
|
||||
const [draft, setDraft] = useState<string | null>(null);
|
||||
|
||||
return (
|
||||
<li
|
||||
className={cn(
|
||||
'rounded-lg border p-3 text-xs',
|
||||
spec?.critical ? 'border-warning/40 bg-warning/8' : 'border-border bg-card',
|
||||
)}
|
||||
>
|
||||
<div className="mb-1.5 flex items-center justify-between gap-2">
|
||||
<span className="font-bold">{spec?.label ?? fact.key}</span>
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
{spec?.critical && (
|
||||
<Badge variant="warning" className="text-[10px]">
|
||||
중요
|
||||
</Badge>
|
||||
)}
|
||||
<Badge variant="outline" className="text-[10px]">
|
||||
{FACT_STATUS_LABEL[fact.status] ?? fact.status}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{draft === null ? (
|
||||
<>
|
||||
<p className="break-words rounded border border-border bg-muted/40 p-2 font-medium">
|
||||
{fact.value ?? <span className="text-muted-foreground">값 없음</span>}
|
||||
{fact.unit ?? ''}
|
||||
</p>
|
||||
{fact.source_url && (
|
||||
<a
|
||||
href={fact.source_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="mt-1 inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground"
|
||||
>
|
||||
<span className="max-w-[220px] truncate">출처: {fact.source_url}</span>
|
||||
<ExternalLink className="size-2.5" />
|
||||
</a>
|
||||
)}
|
||||
<div className="mt-2 flex items-center gap-1.5">
|
||||
<Button size="sm" variant="primary" onClick={onVerify} disabled={isPending}>
|
||||
<Check />
|
||||
<span>맞아요</span>
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
onClick={() => setDraft(fact.value ?? '')}
|
||||
disabled={isPending}
|
||||
>
|
||||
<Pencil />
|
||||
<span>고칠게요</span>
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" onClick={onReject} disabled={isPending}>
|
||||
틀린 값
|
||||
</Button>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
<Input
|
||||
value={draft}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
autoFocus
|
||||
className="text-xs"
|
||||
/>
|
||||
<div className="flex items-center gap-1.5">
|
||||
<Button
|
||||
size="sm"
|
||||
variant="primary"
|
||||
disabled={!draft.trim() || isPending}
|
||||
onClick={() => {
|
||||
onCorrect(draft.trim());
|
||||
setDraft(null);
|
||||
}}
|
||||
>
|
||||
반영하고 확정
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" onClick={() => setDraft(null)}>
|
||||
취소
|
||||
</Button>
|
||||
</div>
|
||||
<p className="text-[10px] text-muted-foreground">
|
||||
고친 값은 잠깁니다 — 이후 자동 수집이 덮어쓰지 않습니다.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user