2026-05-23 14:23:51 -07:00
|
|
|
import React from 'react';
|
|
|
|
|
import { useSitesmith } from '../../hooks/useSitesmith';
|
|
|
|
|
import { useEditorConfig } from '../../state/EditorConfigContext';
|
|
|
|
|
|
|
|
|
|
interface Props { onClick: () => void; }
|
|
|
|
|
|
|
|
|
|
export const SitesmithButton: React.FC<Props> = ({ onClick }) => {
|
|
|
|
|
const cfg = useEditorConfig();
|
|
|
|
|
const siteId = cfg.whpConfig?.siteId ?? 0;
|
|
|
|
|
const { summary } = useSitesmith(siteId);
|
|
|
|
|
const locked = summary?.status === 'DISABLED';
|
|
|
|
|
const capped = summary?.status === 'CAP_REACHED';
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
className="topbar-btn sitesmith-btn"
|
|
|
|
|
title={locked ? 'Sitesmith — paid addon (click to learn more)' : 'Sitesmith AI Builder'}
|
|
|
|
|
style={{
|
|
|
|
|
background: locked ? '#1f1f24' : 'linear-gradient(135deg, #6366f1, #8b5cf6)',
|
|
|
|
|
color: '#fff', border: 'none', padding: '6px 12px', borderRadius: 6, cursor: 'pointer', fontWeight: 500,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-07-12 20:14:29 -07:00
|
|
|
<i className="fa fa-magic" aria-hidden style={{ marginRight: 6 }} /> Sitesmith
|
|
|
|
|
{locked && <i className="fa fa-lock" aria-hidden style={{ marginLeft: 6, fontSize: 12 }} />}
|
2026-05-23 14:23:51 -07:00
|
|
|
{capped && !locked && <span aria-hidden style={{ marginLeft: 6, fontSize: 11, opacity: 0.85 }}>(cap)</span>}
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
};
|