feat: add webhook integration button
This commit is contained in:
@@ -23,7 +23,16 @@ interface IntegrationProps {
|
|||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
handleStart: (data: IntegrationSettings) => void;
|
handleStart: (data: IntegrationSettings) => void;
|
||||||
handleClose: () => void;
|
handleClose: () => void;
|
||||||
preSelectedIntegrationType?: "googleSheets" | "airtable" | null;
|
preSelectedIntegrationType?: "googleSheets" | "airtable" | "webhook" | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebhookConfig {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
headers: { [key: string]: string };
|
||||||
|
events: string[];
|
||||||
|
active: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IntegrationSettings {
|
export interface IntegrationSettings {
|
||||||
@@ -33,8 +42,9 @@ export interface IntegrationSettings {
|
|||||||
airtableBaseName?: string;
|
airtableBaseName?: string;
|
||||||
airtableTableName?: string,
|
airtableTableName?: string,
|
||||||
airtableTableId?: string,
|
airtableTableId?: string,
|
||||||
|
webhooks?: WebhookConfig[];
|
||||||
data: string;
|
data: string;
|
||||||
integrationType: "googleSheets" | "airtable";
|
integrationType: "googleSheets" | "airtable" | "webhook";
|
||||||
}
|
}
|
||||||
|
|
||||||
const getCookie = (name: string): string | null => {
|
const getCookie = (name: string): string | null => {
|
||||||
@@ -64,6 +74,7 @@ export const IntegrationSettingsModal = ({
|
|||||||
airtableBaseName: "",
|
airtableBaseName: "",
|
||||||
airtableTableName: "",
|
airtableTableName: "",
|
||||||
airtableTableId: "",
|
airtableTableId: "",
|
||||||
|
webhooks: [],
|
||||||
data: "",
|
data: "",
|
||||||
integrationType: preSelectedIntegrationType || "googleSheets",
|
integrationType: preSelectedIntegrationType || "googleSheets",
|
||||||
});
|
});
|
||||||
@@ -74,6 +85,18 @@ export const IntegrationSettingsModal = ({
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
|
// Webhook-specific state
|
||||||
|
const [newWebhook, setNewWebhook] = useState<WebhookConfig>({
|
||||||
|
id: "",
|
||||||
|
name: "",
|
||||||
|
url: "",
|
||||||
|
headers: {},
|
||||||
|
events: ["scrape_completed"],
|
||||||
|
active: true,
|
||||||
|
});
|
||||||
|
const [newHeaderKey, setNewHeaderKey] = useState("");
|
||||||
|
const [newHeaderValue, setNewHeaderValue] = useState("");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
recordingId,
|
recordingId,
|
||||||
notify,
|
notify,
|
||||||
@@ -84,7 +107,7 @@ export const IntegrationSettingsModal = ({
|
|||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const [selectedIntegrationType, setSelectedIntegrationType] = useState<
|
const [selectedIntegrationType, setSelectedIntegrationType] = useState<
|
||||||
"googleSheets" | "airtable" | null
|
"googleSheets" | "airtable" | "webhook" | null
|
||||||
>(preSelectedIntegrationType);
|
>(preSelectedIntegrationType);
|
||||||
|
|
||||||
const authenticateWithGoogle = () => {
|
const authenticateWithGoogle = () => {
|
||||||
@@ -410,6 +433,19 @@ export const IntegrationSettingsModal = ({
|
|||||||
<img src="/public/svg/airtable.svg" alt="Airtable" style={{ margin: "6px" }} />
|
<img src="/public/svg/airtable.svg" alt="Airtable" style={{ margin: "6px" }} />
|
||||||
Airtable
|
Airtable
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
onClick={() => {
|
||||||
|
setSelectedIntegrationType("webhook");
|
||||||
|
setSettings({ ...settings, integrationType: "webhook" });
|
||||||
|
navigate(`/robots/${recordingId}/integrate/webhook`);
|
||||||
|
}}
|
||||||
|
style={{ display: "flex", flexDirection: "column", alignItems: "center", background: 'white', color: '#ff00c3' }}
|
||||||
|
>
|
||||||
|
<img src="/public/svg/webhook.svg" alt="Webhook" style={{ margin: "6px" }} />
|
||||||
|
Webhooks
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</GenericModal>
|
</GenericModal>
|
||||||
|
|||||||
Reference in New Issue
Block a user