-
Notifications
You must be signed in to change notification settings - Fork 92
Add Example to Crm Data Components to Demonstrate CrmCardActions & CrmActionButton
#75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,169 @@ | ||||||
| import React, { useState } from "react"; | ||||||
| import { | ||||||
| Divider, | ||||||
| Text, | ||||||
| Flex, | ||||||
| hubspot, | ||||||
| Form, | ||||||
| Select, | ||||||
| } from "@hubspot/ui-extensions"; | ||||||
| import { | ||||||
| CrmPropertyList, | ||||||
| CrmCardActions, | ||||||
| CrmActionButton, | ||||||
| } from "@hubspot/ui-extensions/crm"; | ||||||
|
|
||||||
| // Define the extension to be run within the Hubspot CRM | ||||||
| hubspot.extend(({ context, runServerlessFunction, actions }) => ( | ||||||
| <Extension | ||||||
| context={context} | ||||||
| runServerless={runServerlessFunction} | ||||||
| sendAlert={actions.addAlert} | ||||||
| /> | ||||||
| )); | ||||||
|
|
||||||
| const scenariosToPropertiesMap: { [key: string]: string[] } = { | ||||||
| contact: [ | ||||||
| "jobtitle", | ||||||
| "industry", | ||||||
| "date_of_birth", | ||||||
| "hs_language", | ||||||
| "favorite_color", | ||||||
| ], | ||||||
| engagement: [ | ||||||
| "hs_sa_first_engagement_date", | ||||||
| "hs_latest_source_data_1", | ||||||
| "engagements_last_meeting_booked", | ||||||
| "hs_email_sends_since_last_engagement", | ||||||
| "hs_time_to_first_engagement", | ||||||
| ], | ||||||
| deals: [ | ||||||
| "hs_buying_role", | ||||||
| "num_associated_deals", | ||||||
| "recent_deal_amount", | ||||||
| "recent_deal_close_date", | ||||||
| ], | ||||||
| nps: [ | ||||||
| "hs_feedback_show_nps_web_survey", | ||||||
| "hs_feedback_last_survey_date", | ||||||
| "hs_feedback_last_nps_rating", | ||||||
| "hs_feedback_last_nps_follow_up", | ||||||
| ], | ||||||
| }; | ||||||
|
|
||||||
| const options: Array<{ label: string; value: string }> = [ | ||||||
| { label: "Contact", value: "contact" }, | ||||||
| { label: "Engagement", value: "engagement" }, | ||||||
| { label: "Deal Summary", value: "deals" }, | ||||||
| { label: "NPS", value: "nps" }, | ||||||
| ]; | ||||||
|
|
||||||
| const Extension = ({ context, runServerless, sendAlert }) => { | ||||||
| const [scenario, setScenario] = useState<any>("engagement"); | ||||||
|
||||||
| const [scenario, setScenario] = useState<any>("engagement"); | |
| const [scenario, setScenario] = useState<string>("engagement"); |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth wrapping this in a useMemo?
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need a Form here?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "type": "crm-card", | ||
| "data": { | ||
| "title": "CRM Data: Crm Actions", | ||
| "uid": "actions_example", | ||
| "location": "crm.record.tab", | ||
| "module": { | ||
| "file": "ActionsExtension.tsx" | ||
| }, | ||
| "objectTypes": [ | ||
| { | ||
| "name": "contacts" | ||
| } | ||
| ] | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably don't need these if they aren't being used in your extension?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like all three props are required for
Extensionper its type. Even though they're not used, we may still want to leave them to prevent TS errors