구조: 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,15 @@
|
||||
import {StrictMode} from 'react';
|
||||
import {createRoot} from 'react-dom/client';
|
||||
import {RouterProvider} from 'react-router';
|
||||
import {Providers} from './provider';
|
||||
import {router} from './router';
|
||||
// 스타일은 사장님 앱과 같은 것을 쓴다 — 같은 회사 화면이라 두 벌로 갈릴 이유가 없다.
|
||||
import '@/index.css';
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<Providers>
|
||||
<RouterProvider router={router} />
|
||||
</Providers>
|
||||
</StrictMode>,
|
||||
);
|
||||
@@ -0,0 +1,57 @@
|
||||
import {QueryClientProvider} from '@tanstack/react-query';
|
||||
import {useEffect, type ReactNode} from 'react';
|
||||
import {Toaster} from 'sonner';
|
||||
import {getAccessToken, me} from '@/api';
|
||||
import {queryClient} from '@/lib/query-client';
|
||||
import {toAuthUser, useAuthStore} from '@/stores/auth';
|
||||
|
||||
/**
|
||||
* 저장된 액세스 토큰으로 세션을 복구한다.
|
||||
*
|
||||
* ★ 사장님 앱과 결정적으로 다른 점: **여기서는 실패가 곧 차단이다.**
|
||||
* 빌더는 로그인 없이도 돌아야 해서 인증 실패를 삼키지만(solution/frontend/app/provider.tsx),
|
||||
* 내부 운영 화면은 전부 RequireAuth 뒤에 있다. 두 정책을 한 앱에 두면 실수가 늘
|
||||
* 느슨한 쪽으로 나기 때문에 앱을 갈랐다.
|
||||
*/
|
||||
function useRestoreSession() {
|
||||
const setUser = useAuthStore((s) => s.setUser);
|
||||
const finishRestore = useAuthStore((s) => s.finishRestore);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
if (!getAccessToken()) {
|
||||
finishRestore();
|
||||
return;
|
||||
}
|
||||
void me()
|
||||
.then((res) => {
|
||||
if (!alive || res.result?.success === false) return;
|
||||
// RemoveNoneResponse 라 신원 필드가 통째로 빠져 올 수 있다 — 반쪽짜리 사용자를 세우지 않는다.
|
||||
if (!res.user_id || !res.id) return;
|
||||
setUser(toAuthUser(res));
|
||||
})
|
||||
.catch(() => {
|
||||
/* 토큰이 죽었으면 비로그인 상태로 떨어뜨린다. RequireAuth 가 로그인으로 보낸다. */
|
||||
})
|
||||
.finally(() => {
|
||||
if (alive) finishRestore();
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [setUser, finishRestore]);
|
||||
}
|
||||
|
||||
function SessionGate({children}: {children: ReactNode}) {
|
||||
useRestoreSession();
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export function Providers({children}: {children: ReactNode}) {
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<SessionGate>{children}</SessionGate>
|
||||
<Toaster richColors position="top-center" expand visibleToasts={9} />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import {Building2, CalendarDays} from 'lucide-react';
|
||||
import {createBrowserRouter, Navigate, Outlet} from 'react-router';
|
||||
import {AppShell, type NavItem} from '@/components/layout/AppShell';
|
||||
import {RequireAuth} from '@/components/layout/RequireAuth';
|
||||
import {LocalContentPage} from '@admin/pages/LocalContentPage';
|
||||
import {LoginPage} from '@/pages/LoginPage';
|
||||
import {NotFoundPage} from '@/pages/NotFoundPage';
|
||||
import {PlaceDetailPage} from '@admin/pages/PlaceDetailPage';
|
||||
import {PlaceListPage} from '@admin/pages/PlaceListPage';
|
||||
import {SeoAuditPage} from '@admin/pages/SeoAuditPage';
|
||||
|
||||
/**
|
||||
* ★ 내부 메뉴는 여기 있다. AppShell(사장님 앱 소유)에 두면 이 경로 이름들이
|
||||
* 사장님 번들에 문자열로 남는다 — 앱을 가른 이유가 사라진다.
|
||||
*/
|
||||
const ADMIN_NAV: NavItem[] = [
|
||||
{to: '/places', match: '/places', label: '사업장', icon: Building2},
|
||||
{to: '/local-content', match: '/local-content', label: '지역 콘텐츠', icon: CalendarDays},
|
||||
];
|
||||
|
||||
/**
|
||||
* 내부 운영 화면. **전부 RequireAuth 뒤에 둔다** — 예외를 하나 두는 순간
|
||||
* 그 예외가 기본값이 된다. 사장님 앱과 앱을 가른 이유가 이 규칙을 지키기 위해서다.
|
||||
*/
|
||||
export const router = createBrowserRouter([
|
||||
{path: '/login', element: <LoginPage />},
|
||||
|
||||
{path: '/', element: <Navigate to="/places" replace />},
|
||||
|
||||
{
|
||||
element: (
|
||||
<RequireAuth>
|
||||
<AppShell nav={ADMIN_NAV}>
|
||||
<Outlet />
|
||||
</AppShell>
|
||||
</RequireAuth>
|
||||
),
|
||||
children: [
|
||||
{path: '/places', element: <PlaceListPage />},
|
||||
{path: '/places/:placeId', element: <PlaceDetailPage />},
|
||||
{path: '/places/:placeId/seo', element: <SeoAuditPage />},
|
||||
{path: '/local-content', element: <LocalContentPage />},
|
||||
],
|
||||
},
|
||||
|
||||
{path: '*', element: <NotFoundPage />},
|
||||
]);
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* 사장님 앱 오리진. 빌더는 다른 오리진이라(:3000 vs :3002) react-router Link 로 두면
|
||||
* admin 안에서 404 다. 절대 URL + 새 탭으로 연다.
|
||||
*/
|
||||
const ORIGIN = import.meta.env.VITE_SOLUTION_URL ?? 'http://localhost:3000';
|
||||
|
||||
export function builderUrl(params?: {placeId?: string; isNew?: boolean}): string {
|
||||
if (params?.placeId) return `${ORIGIN}/builder?placeId=${encodeURIComponent(params.placeId)}`;
|
||||
return `${ORIGIN}/builder?new=1`;
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
import {useEffect, useMemo, useState} from 'react';
|
||||
import {CalendarDays, Check, Download, ExternalLink, MapPin, Search} from 'lucide-react';
|
||||
import {PageContainer} from '@/components/layout/AppShell';
|
||||
import {Badge} from '@/components/ui/badge';
|
||||
import {Button} from '@/components/ui/button';
|
||||
import {Card, CardContent} from '@/components/ui/card';
|
||||
import {Input} from '@/components/ui/input';
|
||||
import {customFetch} from '@/api/mutator/custom-fetch';
|
||||
import {toast} from 'sonner';
|
||||
|
||||
type Status = 1 | 2 | 3;
|
||||
|
||||
type LocalContent = {
|
||||
id: string;
|
||||
title: string;
|
||||
region: string;
|
||||
period: string;
|
||||
source: string;
|
||||
status: Status;
|
||||
selected: boolean;
|
||||
displayStart?: string;
|
||||
displayEnd?: string;
|
||||
imageUrl?: string;
|
||||
};
|
||||
|
||||
const STATUS_LABEL: Record<Status, string> = {1: '검수 대기', 2: '발행됨', 3: '종료됨'};
|
||||
|
||||
type ApiContent = {
|
||||
local_content_id: string;
|
||||
region_code: string;
|
||||
external_id?: string;
|
||||
title?: string;
|
||||
body: Record<string, unknown>;
|
||||
status: Status;
|
||||
source: number;
|
||||
display_start_at?: string;
|
||||
display_end_at?: string;
|
||||
};
|
||||
|
||||
function formatDate(value: unknown) {
|
||||
const text = String(value ?? '');
|
||||
return /^\d{8}$/.test(text) ? `${text.slice(0, 4)}. ${Number(text.slice(4, 6))}. ${Number(text.slice(6, 8))}` : text;
|
||||
}
|
||||
|
||||
function toContent(item: ApiContent): LocalContent {
|
||||
const start = formatDate(item.body.eventstartdate);
|
||||
const end = formatDate(item.body.eventenddate);
|
||||
return {
|
||||
id: item.local_content_id,
|
||||
title: item.title || '제목 없음',
|
||||
region: String(item.body.addr1 || item.region_code),
|
||||
period: [start, end].filter(Boolean).join(' ~ ') || '기간 미정',
|
||||
source: `공공데이터포털 전국문화축제표준데이터 · ${item.external_id ?? '-'}`,
|
||||
status: item.status,
|
||||
selected: false,
|
||||
displayStart: item.display_start_at,
|
||||
displayEnd: item.display_end_at,
|
||||
imageUrl: String(item.body.image_url || item.body.firstimage || ''),
|
||||
};
|
||||
}
|
||||
|
||||
export function LocalContentPage() {
|
||||
const [contents, setContents] = useState<LocalContent[]>([]);
|
||||
const [query, setQuery] = useState('');
|
||||
const [syncing, setSyncing] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const filtered = useMemo(() => contents.filter((item) => `${item.title} ${item.region}`.includes(query.trim())), [contents, query]);
|
||||
const selectedCount = contents.filter((item) => item.selected).length;
|
||||
const allFilteredSelected = filtered.length > 0 && filtered.every((item) => item.selected);
|
||||
|
||||
const toggle = (id: string) => setContents((items) => items.map((item) => item.id === id ? {...item, selected: !item.selected} : item));
|
||||
const toggleAll = () => {
|
||||
const visibleIds = new Set(filtered.map((item) => item.id));
|
||||
setContents((items) => items.map((item) => visibleIds.has(item.id) ? {...item, selected: !allFilteredSelected} : item));
|
||||
};
|
||||
const load = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await customFetch<{contents?: ApiContent[]}>({url: '/v1/admin/local-content', method: 'GET'});
|
||||
setContents((res.contents ?? []).map(toContent));
|
||||
} catch {
|
||||
toast.error('지역 콘텐츠를 불러오지 못했습니다. 개발자 계정인지 확인해주세요.');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
useEffect(() => { void load(); }, []);
|
||||
|
||||
const publishSelected = async () => {
|
||||
const ids = contents.filter((item) => item.selected).map((item) => item.id);
|
||||
try {
|
||||
await customFetch({url: '/v1/admin/local-content/publish', method: 'POST', data: {content_ids: ids}});
|
||||
toast.success(`${ids.length}건을 발행했습니다.`);
|
||||
await load();
|
||||
} catch { toast.error('발행하지 못했습니다.'); }
|
||||
};
|
||||
const sync = async () => {
|
||||
const regionCode = window.prompt('내부 지역 코드(예: gunsan)를 입력하세요.', 'gunsan')?.trim();
|
||||
if (!regionCode) return;
|
||||
setSyncing(true);
|
||||
try {
|
||||
const res = await customFetch<{result?: {success?: boolean}; msg?: string; collected?: number; skipped?: number}>({
|
||||
url: '/v1/admin/local-content/sync-festivals', method: 'POST', data: {region_code: regionCode},
|
||||
});
|
||||
if (res.result?.success === false) throw new Error(res.msg);
|
||||
toast.success(`${res.collected ?? 0}건 수집 · ${res.skipped ?? 0}건 중복 제외`);
|
||||
await load();
|
||||
} catch (error) {
|
||||
toast.error(error instanceof Error ? error.message : '공공데이터 수집에 실패했습니다.');
|
||||
} finally { setSyncing(false); }
|
||||
};
|
||||
|
||||
const edit = async (item: LocalContent) => {
|
||||
const title = window.prompt('노출 제목을 입력하세요.', item.title)?.trim();
|
||||
if (!title) return;
|
||||
const start = window.prompt('노출 시작 시각(예: 2026-09-01T09:00, 비우면 미설정)', item.displayStart?.slice(0, 16) ?? '')?.trim();
|
||||
const end = window.prompt('노출 종료 시각(예: 2026-09-07T22:00, 비우면 미설정)', item.displayEnd?.slice(0, 16) ?? '')?.trim();
|
||||
try {
|
||||
await customFetch({
|
||||
url: `/v1/admin/local-content/${item.id}`,
|
||||
method: 'PATCH',
|
||||
data: {title, display_start_at: start ? new Date(start).toISOString() : null, display_end_at: end ? new Date(end).toISOString() : null},
|
||||
});
|
||||
toast.success('콘텐츠와 노출 일정을 저장했습니다.');
|
||||
await load();
|
||||
} catch { toast.error('콘텐츠를 수정하지 못했습니다.'); }
|
||||
};
|
||||
|
||||
const endContent = async (item: LocalContent) => {
|
||||
if (!window.confirm(`'${item.title}' 발행을 종료할까요?`)) return;
|
||||
try {
|
||||
await customFetch({url: `/v1/admin/local-content/${item.id}/end`, method: 'POST'});
|
||||
toast.success('발행을 종료했습니다.');
|
||||
await load();
|
||||
} catch { toast.error('발행을 종료하지 못했습니다.'); }
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
title="지역 콘텐츠"
|
||||
description="공공데이터에서 지역 축제를 가져와 검수한 뒤 사장님에게 발행합니다."
|
||||
actions={<Button onClick={sync} disabled={syncing}><Download className="size-4" />{syncing ? '수집 중…' : '공공데이터 수집'}</Button>}
|
||||
>
|
||||
<div className="mb-4 grid gap-3 sm:grid-cols-3">
|
||||
<Summary label="전체 콘텐츠" value={contents.length} />
|
||||
<Summary label="검수 대기" value={contents.filter((item) => item.status === 1).length} />
|
||||
<Summary label="발행 중" value={contents.filter((item) => item.status === 2).length} />
|
||||
</div>
|
||||
|
||||
<div className="mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div className="flex w-full items-center gap-3 sm:max-w-lg">
|
||||
<label className="flex shrink-0 cursor-pointer items-center gap-2 text-xs font-medium">
|
||||
<input type="checkbox" checked={allFilteredSelected} onChange={toggleAll} disabled={!filtered.length} className="size-4 accent-primary" />
|
||||
전체 선택
|
||||
</label>
|
||||
<div className="relative min-w-0 flex-1">
|
||||
<Search className="absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground" />
|
||||
<Input value={query} onChange={(event) => setQuery(event.target.value)} placeholder="축제명 또는 지역 검색" className="pl-9" />
|
||||
</div>
|
||||
</div>
|
||||
<Button onClick={publishSelected} disabled={!selectedCount} variant="primary">
|
||||
<Check className="size-4" /> 선택 {selectedCount}건 발행
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
{loading && <p className="py-10 text-center text-xs text-muted-foreground">콘텐츠를 불러오는 중…</p>}
|
||||
{!loading && !filtered.length && <p className="rounded-xl border border-dashed py-12 text-center text-xs text-muted-foreground">수집된 지역 콘텐츠가 없습니다.</p>}
|
||||
{filtered.map((item) => (
|
||||
<Card key={item.id} className={item.selected ? 'border-primary' : ''}>
|
||||
<CardContent className="flex flex-col gap-3 p-4 sm:flex-row sm:items-center">
|
||||
<input type="checkbox" checked={item.selected} onChange={() => toggle(item.id)} className="size-4 accent-primary" aria-label={`${item.title} 선택`} />
|
||||
{item.imageUrl && <img src={item.imageUrl} alt="" className="h-20 w-28 rounded-lg object-cover" />}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="mb-1 flex flex-wrap items-center gap-2">
|
||||
<h2 className="text-sm font-semibold">{item.title}</h2>
|
||||
<Badge variant={item.status === 2 ? 'success' : 'warning'}>{STATUS_LABEL[item.status]}</Badge>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground">
|
||||
<span className="flex items-center gap-1"><MapPin className="size-3.5" />{item.region}</span>
|
||||
<span className="flex items-center gap-1"><CalendarDays className="size-3.5" />{item.period}</span>
|
||||
</div>
|
||||
<p className="mt-1.5 text-[11px] text-muted-foreground">출처: {item.source} · 외부 ID {item.id}</p>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm" onClick={() => void edit(item)}><ExternalLink className="size-3.5" /> 수정·스케줄</Button>
|
||||
{item.status === 2 && <Button variant="destructive" size="sm" onClick={() => void endContent(item)}>발행 종료</Button>}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
function Summary({label, value}: {label: string; value: number}) {
|
||||
return <Card><CardContent className="p-4"><p className="text-xs text-muted-foreground">{label}</p><p className="mt-1 text-2xl font-semibold">{value}</p></CardContent></Card>;
|
||||
}
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
import {useState} from 'react';
|
||||
import {Link} from 'react-router';
|
||||
import {keepPreviousData} from '@tanstack/react-query';
|
||||
import {
|
||||
Building2,
|
||||
Loader2,
|
||||
Pencil,
|
||||
Plus,
|
||||
ShieldCheck,
|
||||
ShieldQuestion,
|
||||
SlidersHorizontal,
|
||||
Trash2,
|
||||
} from 'lucide-react';
|
||||
import {PlaceCategory, PlaceStatus} from '@o2o/shared';
|
||||
import {deletePlace, useListPlaces} from '@/api';
|
||||
import {EmptyState, PageContainer} from '@/components/layout/AppShell';
|
||||
import {builderUrl} from '@admin/lib/solutionUrl';
|
||||
import {Badge} from '@/components/ui/badge';
|
||||
import {Button} from '@/components/ui/button';
|
||||
import {Input} from '@/components/ui/input';
|
||||
import {notify, notifyApiError} from '@/lib/notify';
|
||||
|
||||
const CATEGORY_LABEL: Record<number, string> = {
|
||||
[PlaceCategory.LODGING]: '숙박',
|
||||
[PlaceCategory.CAFE]: '카페',
|
||||
[PlaceCategory.RESTAURANT]: '음식점',
|
||||
[PlaceCategory.TOUR_ACTIVITY]: '관광체험',
|
||||
};
|
||||
|
||||
const STATUS_LABEL: Record<number, string> = {
|
||||
[PlaceStatus.DRAFT]: '등록됨',
|
||||
[PlaceStatus.COLLECTING]: '수집 중',
|
||||
[PlaceStatus.REVIEW]: '발행 전',
|
||||
[PlaceStatus.PUBLISHED]: '발행됨',
|
||||
[PlaceStatus.SUSPENDED]: '중지',
|
||||
};
|
||||
|
||||
/**
|
||||
* 사업장 목록 — 이 제품의 허브다.
|
||||
*
|
||||
* 흐름은 하나뿐이다:
|
||||
* 빌더(위저드)로 만든다 → **여기 생긴다** → 여기서 에디터로 들어가 고친다 → 재발행하면 HTML 이 다시 구워진다.
|
||||
*
|
||||
* ★ 그래서 줄을 누르면 사업장 상세가 아니라 **에디터**로 간다. 목록에 온 사장님의
|
||||
* 용건은 열에 아홉 "내 사이트 고치기"다. fact 를 하나씩 확인하는 상세 화면은
|
||||
* [정보 확인] 으로 따로 둔다 — 발행 게이트에 걸렸을 때 가는 곳이다.
|
||||
*/
|
||||
export function PlaceListPage() {
|
||||
const [search, setSearch] = useState('');
|
||||
const [deletingId, setDeletingId] = useState<string | null>(null);
|
||||
|
||||
const {data, isLoading, isError, error, refetch} = useListPlaces(
|
||||
{search: search || undefined, size: 50},
|
||||
// 검색어를 칠 때마다 목록이 빈 화면으로 깜빡이지 않게 직전 렌더값을 유지한다(캐시가 아니다).
|
||||
{query: {placeholderData: keepPreviousData}},
|
||||
);
|
||||
|
||||
const places = data?.places ?? [];
|
||||
|
||||
const handleDelete = async (placeId: string, name: string) => {
|
||||
if (!window.confirm(`'${name}' 사업장을 삭제할까요?`)) return;
|
||||
setDeletingId(placeId);
|
||||
try {
|
||||
const res = await deletePlace(placeId);
|
||||
if (!res.result?.success) {
|
||||
notifyApiError({data: res}, '사업장을 삭제하지 못했습니다.');
|
||||
return;
|
||||
}
|
||||
notify.success('사업장을 삭제했습니다.');
|
||||
await refetch();
|
||||
} catch (deleteError) {
|
||||
notifyApiError(deleteError, '사업장을 삭제하지 못했습니다.');
|
||||
} finally {
|
||||
setDeletingId(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
title="사업장"
|
||||
description="빌더로 만든 사이트가 여기 쌓입니다. 줄을 누르면 에디터에서 바로 고칠 수 있어요."
|
||||
actions={
|
||||
<>
|
||||
<Input
|
||||
value={search}
|
||||
onChange={(e) => setSearch(e.target.value)}
|
||||
placeholder="상호명 · 주소 검색"
|
||||
className="w-56"
|
||||
/>
|
||||
{/* 새로 만드는 길은 위저드다 — `?new=1` 이 지난번 편집 상태를 비우고 1단계부터 연다. */}
|
||||
<a
|
||||
href={builderUrl({isNew: true})}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex h-9 shrink-0 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Plus className="size-3.5" />
|
||||
<span>새 사이트 만들기</span>
|
||||
</a>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center py-16 text-muted-foreground">
|
||||
<Loader2 className="size-5 animate-spin" />
|
||||
</div>
|
||||
) : isError ? (
|
||||
<EmptyState
|
||||
icon={Building2}
|
||||
title="사업장을 불러오지 못했습니다"
|
||||
description={
|
||||
(error as Error)?.message ??
|
||||
'백엔드(기본 http://localhost:9800)가 떠 있는지 확인해 주세요.'
|
||||
}
|
||||
/>
|
||||
) : places.length === 0 ? (
|
||||
<EmptyState
|
||||
icon={Building2}
|
||||
title="아직 만든 사이트가 없습니다"
|
||||
description="상호명 하나만 있으면 시작할 수 있습니다. 주소·좌표는 동일 업소 검증이 채웁니다."
|
||||
action={
|
||||
<a
|
||||
href={builderUrl({isNew: true})}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex h-9 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Plus className="size-3.5" />
|
||||
<span>새 사이트 만들기</span>
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<ul className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">
|
||||
{places.map((place) => (
|
||||
<li key={place.place_id} className="flex items-center">
|
||||
{/* 줄 전체가 에디터로 가는 링크다 — 목록에 온 용건이 편집이라서다. */}
|
||||
<a
|
||||
href={builderUrl({placeId: place.place_id})}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="flex min-w-0 flex-1 items-center justify-between gap-4 px-4 py-3 transition-colors hover:bg-muted/50"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-semibold">{place.name}</p>
|
||||
<p className="truncate text-xs text-muted-foreground">
|
||||
{place.road_address ?? place.address ?? '주소 미확정'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<Badge variant="outline">{CATEGORY_LABEL[place.category] ?? '기타'}</Badge>
|
||||
<Badge
|
||||
variant={place.status === PlaceStatus.PUBLISHED ? 'success' : 'default'}
|
||||
>
|
||||
{STATUS_LABEL[place.status] ?? '알 수 없음'}
|
||||
</Badge>
|
||||
{/* ★ verified_at 이 NULL 이면 수집·발행 진입 금지. 목록에서 바로 보이게 둔다. */}
|
||||
{place.verified_at ? (
|
||||
<span title="동일 업소 검증 완료" className="text-success">
|
||||
<ShieldCheck className="size-4" />
|
||||
</span>
|
||||
) : (
|
||||
<span title="동일 업소 검증 전 — 수집이 열리지 않습니다" className="text-warning">
|
||||
<ShieldQuestion className="size-4" />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
<div className="flex shrink-0 items-center gap-1 pr-3">
|
||||
<a
|
||||
href={builderUrl({placeId: place.place_id})}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-2.5 text-xs font-semibold text-primary-foreground transition-opacity hover:opacity-90"
|
||||
>
|
||||
<Pencil className="size-3.5" />
|
||||
<span className="hidden sm:inline">사이트 편집</span>
|
||||
</a>
|
||||
{/* 발행 게이트에 걸렸을 때 가는 곳 — 수집된 값을 확인·수정한다. */}
|
||||
<Link
|
||||
to={`/places/${place.place_id}`}
|
||||
title="수집 정보 확인 · 채널 관리"
|
||||
className="inline-flex size-8 items-center justify-center rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
||||
>
|
||||
<SlidersHorizontal className="size-3.5" />
|
||||
</Link>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="text-muted-foreground hover:text-destructive"
|
||||
aria-label={`${place.name} 삭제`}
|
||||
title="사업장 삭제"
|
||||
isLoading={deletingId === place.place_id}
|
||||
disabled={deletingId !== null}
|
||||
onClick={() => handleDelete(place.place_id, place.name)}
|
||||
>
|
||||
<Trash2 />
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import {useQuery} from '@tanstack/react-query';
|
||||
import {useParams} from 'react-router';
|
||||
import {AlertTriangle, Check, Loader2, Minus, RefreshCw, SearchCheck} from 'lucide-react';
|
||||
import {useGetPlace} from '@/api';
|
||||
import {PageContainer} from '@/components/layout/AppShell';
|
||||
import {Badge} from '@/components/ui/badge';
|
||||
import {Button} from '@/components/ui/button';
|
||||
import {Card, CardContent, CardHeader, CardTitle} from '@/components/ui/card';
|
||||
import {callSiteApi, type ResultEnvelope} from '@/features/publish/siteApi';
|
||||
import {cn} from '@/lib/utils';
|
||||
|
||||
type CheckState = 'pass' | 'warn' | 'fail';
|
||||
interface AuditCheck { id: string; group: string; label: string; points: number; earned: number; status: CheckState; detail: string; recommendation?: string; }
|
||||
interface AuditReport extends ResultEnvelope {
|
||||
seo_score: number; aeo_score: number; overall_score: number; checks: AuditCheck[];
|
||||
summary: {facts?: number; faqs?: number; images_with_alt?: number; built?: boolean; domain?: string};
|
||||
visibility: {checks?: number; own_site_cited?: number}; disclaimer: string;
|
||||
}
|
||||
|
||||
const grade = (score: number) => score >= 90 ? '매우 좋음' : score >= 75 ? '좋음' : score >= 60 ? '보완 필요' : '개선 필요';
|
||||
|
||||
export function SeoAuditPage() {
|
||||
const {placeId = ''} = useParams();
|
||||
const placeQuery = useGetPlace(placeId, {query: {enabled: Boolean(placeId)}});
|
||||
const auditQuery = useQuery({
|
||||
queryKey: ['site-audit', placeId],
|
||||
queryFn: () => callSiteApi<AuditReport>(`/v1/place/${placeId}/site/audit`),
|
||||
enabled: Boolean(placeId),
|
||||
});
|
||||
const report = auditQuery.data;
|
||||
const place = placeQuery.data?.place;
|
||||
|
||||
if (placeQuery.isLoading || auditQuery.isLoading) return <div className="flex items-center justify-center py-16 text-muted-foreground"><Loader2 className="size-5 animate-spin" /></div>;
|
||||
if (!report || report.result?.success === false) return <PageContainer title="SEO·AEO 진단"><div className="rounded-xl border border-destructive/30 bg-destructive/5 p-5 text-sm">진단 결과를 불러오지 못했습니다. 잠시 후 다시 시도해 주세요.</div></PageContainer>;
|
||||
|
||||
const improvements = report.checks.filter((item) => item.status !== 'pass' && item.recommendation).sort((a, b) => (b.points - b.earned) - (a.points - a.earned));
|
||||
const seoChecks = report.checks.filter((item) => ['기술 SEO', '콘텐츠 SEO', '신뢰·품질'].includes(item.group));
|
||||
const aeoChecks = report.checks.filter((item) => !seoChecks.includes(item));
|
||||
|
||||
return (
|
||||
<PageContainer title="SEO·AEO 진단" description={place ? `${place.name}의 현재 저장 정보와 최신 발행본 기준` : undefined} actions={<Button variant="outline" onClick={() => void auditQuery.refetch()} disabled={auditQuery.isFetching}><RefreshCw className={cn('size-3.5', auditQuery.isFetching && 'animate-spin')} /> 다시 진단</Button>}>
|
||||
<div className="grid gap-3 sm:grid-cols-3">
|
||||
<ScoreCard label="종합 준비도" score={report.overall_score} primary />
|
||||
<ScoreCard label="SEO 준비도" score={report.seo_score} />
|
||||
<ScoreCard label="AEO 준비도" score={report.aeo_score} />
|
||||
</div>
|
||||
<div className="mt-5 grid gap-5 lg:grid-cols-[1fr_320px]">
|
||||
<div className="space-y-5"><CheckSection title="SEO 세부 진단" checks={seoChecks} /><CheckSection title="AEO 세부 진단" checks={aeoChecks} /></div>
|
||||
<aside className="space-y-4">
|
||||
<Card><CardHeader><CardTitle className="text-sm">우선 개선할 항목</CardTitle></CardHeader><CardContent>
|
||||
{improvements.length === 0 ? <div className="flex items-center gap-2 text-xs text-success"><Check className="size-4" /> 준비도 항목을 모두 충족했습니다.</div> : <ol className="space-y-3">{improvements.slice(0, 5).map((item, index) => <li key={item.id} className="flex gap-2.5 text-xs"><span className="flex size-5 shrink-0 items-center justify-center rounded-full bg-primary/10 text-[10px] font-bold text-primary">{index + 1}</span><div><p className="font-semibold">{item.label}</p><p className="mt-0.5 leading-relaxed text-muted-foreground">{item.recommendation}</p></div></li>)}</ol>}
|
||||
</CardContent></Card>
|
||||
<Card><CardHeader><CardTitle className="text-sm">현재 콘텐츠</CardTitle></CardHeader><CardContent className="grid grid-cols-2 gap-3 text-xs"><Metric label="확인된 정보" value={`${report.summary.facts ?? 0}건`} /><Metric label="FAQ" value={`${report.summary.faqs ?? 0}건`} /><Metric label="설명 있는 사진" value={`${report.summary.images_with_alt ?? 0}장`} /><Metric label="정적 빌드" value={report.summary.built ? '완료' : '전'} /></CardContent></Card>
|
||||
<Card><CardHeader><CardTitle className="flex items-center gap-1.5 text-sm"><SearchCheck className="size-4" /> 실제 AI 인용</CardTitle></CardHeader><CardContent className="text-xs leading-relaxed text-muted-foreground">최근 점검 {report.visibility.checks ?? 0}회 중 우리 사이트 인용 {report.visibility.own_site_cited ?? 0}회{(report.visibility.checks ?? 0) === 0 && <p className="mt-2">아직 AI 검색 질의 점검 이력이 없습니다. 이 수치는 준비도와 별도로 운영 중 쌓입니다.</p>}</CardContent></Card>
|
||||
<p className="px-1 text-[10px] leading-relaxed text-muted-foreground">{report.disclaimer}</p>
|
||||
</aside>
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
|
||||
function ScoreCard({label, score, primary = false}: {label: string; score: number; primary?: boolean}) {
|
||||
return <div className={cn('rounded-xl border p-4', primary ? 'border-primary/30 bg-primary/5' : 'border-border bg-card')}><div className="flex items-end justify-between"><p className="text-xs font-semibold text-muted-foreground">{label}</p><Badge variant={score >= 75 ? 'success' : 'warning'}>{grade(score)}</Badge></div><p className="mt-2 font-mono text-3xl font-bold tracking-tight">{score}<span className="text-sm font-medium text-muted-foreground">/100</span></p><div className="mt-3 h-1.5 overflow-hidden rounded-full bg-muted"><div className={cn('h-full rounded-full', score >= 75 ? 'bg-success' : score >= 50 ? 'bg-warning' : 'bg-destructive')} style={{width: `${score}%`}} /></div></div>;
|
||||
}
|
||||
|
||||
function CheckSection({title, checks}: {title: string; checks: AuditCheck[]}) {
|
||||
return <section><h2 className="mb-2 text-sm font-semibold">{title}</h2><ul className="divide-y divide-border overflow-hidden rounded-xl border border-border bg-card">{checks.map((item) => <li key={item.id} className="flex items-start gap-3 p-3.5 text-xs"><StatusIcon status={item.status} /><div className="min-w-0 flex-1"><div className="flex items-center justify-between gap-3"><p className="font-bold">{item.label}</p><span className="shrink-0 font-mono text-[11px] text-muted-foreground">{item.earned}/{item.points}</span></div><p className="mt-0.5 leading-relaxed text-muted-foreground">{item.detail}</p>{item.status !== 'pass' && item.recommendation && <p className="mt-1 font-medium text-foreground">→ {item.recommendation}</p>}</div></li>)}</ul></section>;
|
||||
}
|
||||
|
||||
function StatusIcon({status}: {status: CheckState}) {
|
||||
return <span className={cn('mt-0.5 flex size-5 shrink-0 items-center justify-center rounded-full', status === 'pass' ? 'bg-success/15 text-success' : status === 'warn' ? 'bg-warning/15 text-warning' : 'bg-destructive/15 text-destructive')}>{status === 'pass' ? <Check className="size-3" strokeWidth={3} /> : status === 'warn' ? <AlertTriangle className="size-3" /> : <Minus className="size-3" strokeWidth={3} />}</span>;
|
||||
}
|
||||
|
||||
function Metric({label, value}: {label: string; value: string}) { return <div className="rounded-lg bg-muted/50 p-2.5"><p className="text-[10px] text-muted-foreground">{label}</p><p className="mt-0.5 font-semibold">{value}</p></div>; }
|
||||
Reference in new issue
Block a user