@scavio/twenty 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,46 @@
1
+ import { RestApiClient } from 'twenty-client-sdk/rest';
2
+ import { defineFrontComponent } from 'twenty-sdk/define';
3
+ import {
4
+ Command,
5
+ enqueueSnackbar,
6
+ useSelectedRecordIds,
7
+ } from 'twenty-sdk/front-component';
8
+
9
+ import {
10
+ FRONT_COMPONENT_UNIVERSAL_IDENTIFIERS,
11
+ START_ENRICHMENT_ROUTE_PATH,
12
+ } from 'src/constants/universal-identifiers';
13
+ import {
14
+ buildStartSnackbar,
15
+ type StartEnrichmentResult,
16
+ } from 'src/scavio/start-snackbar';
17
+
18
+ const execute = async (recordIds: string[]) => {
19
+ try {
20
+ const result = await new RestApiClient().post<StartEnrichmentResult>(
21
+ `/s${START_ENRICHMENT_ROUTE_PATH}`,
22
+ { recordIds },
23
+ );
24
+
25
+ await enqueueSnackbar(buildStartSnackbar(result));
26
+ } catch {
27
+ await enqueueSnackbar({
28
+ message: 'Could not start the Scavio enrichment.',
29
+ variant: 'error',
30
+ });
31
+ }
32
+ };
33
+
34
+ const EnrichWithScavio = () => {
35
+ const recordIds = useSelectedRecordIds();
36
+
37
+ return <Command execute={() => execute(recordIds)} />;
38
+ };
39
+
40
+ export default defineFrontComponent({
41
+ universalIdentifier: FRONT_COMPONENT_UNIVERSAL_IDENTIFIERS.enrichCompanies,
42
+ name: 'enrich-with-scavio',
43
+ description: 'Starts a Scavio enrichment for the selected companies.',
44
+ component: EnrichWithScavio,
45
+ isHeadless: true,
46
+ });