Files
exAichatbot_agent/chatbotApp-chatbot2.0-agent/web/src/components/ActionButtonList.tsx
T
Macbook 4b86b2a660 Agent 2.0 exdev 서버 배포 스택
- server-dev start/stop/deploy 및 Gitea push 자동 배포
- local-dev 로컬 개발 환경

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-21 22:57:30 +09:00

44 lines
1.3 KiB
TypeScript

import type { WebActionButton } from "@/lib/types";
interface ActionButtonListProps {
buttons?: WebActionButton[];
}
function resolveHref(button: WebActionButton): string | undefined {
if (button.action === "phone") {
const number = button.phoneNumber?.replace(/[^0-9+]/g, "");
return number ? `tel:${number}` : button.url;
}
return button.url || button.webUrl || button.pcUrl || button.mobileUrl || button.androidUrl || button.iosUrl;
}
function isExternalHref(href: string): boolean {
return /^https?:\/\//i.test(href);
}
export function ActionButtonList({ buttons }: ActionButtonListProps) {
const resolvedButtons = (buttons ?? [])
.map((button) => ({ button, href: resolveHref(button) }))
.filter((item): item is { button: WebActionButton; href: string } => Boolean(item.href));
if (resolvedButtons.length === 0) {
return null;
}
return (
<div className="action-buttons">
{resolvedButtons.map(({ button, href }, index) => (
<a
key={`${button.action ?? "link"}-${button.label}-${href}-${index}`}
className="action-button"
href={href}
target={isExternalHref(href) ? "_blank" : undefined}
rel={isExternalHref(href) ? "noopener noreferrer" : undefined}
>
{button.label || "바로가기"}
</a>
))}
</div>
);
}