Skip to content

Commit b8c8e84

Browse files
Added the Yellow Theme in Widget (#1042)
2 parents 0931b7d + fbec306 commit b8c8e84

File tree

18 files changed

+126
-236
lines changed

18 files changed

+126
-236
lines changed

apps/api/src/app/shared/services/bubble-io.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ interface IThingsResponse {
1717
export class BubbleIoService extends BubbleBaseService {
1818
async getDatatypeData(data: Omit<BubbleDestinationEntity, '_id' | '_templateId'>) {
1919
try {
20-
const url = this.createBubbleIoUrl(data);
21-
const response = await axios.get<IThingsResponse>(url, {
20+
const response = await axios.get<IThingsResponse>(data.bubbleAppUrl, {
2221
headers: {
2322
Authorization: `Bearer ${data.apiPrivateKey}`,
2423
},

apps/api/src/app/shared/services/lead.service.ts

Lines changed: 14 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -16,123 +16,24 @@ interface ILeadInformation {
1616
@Injectable()
1717
export class LeadService {
1818
private log = process.env.NODE_ENV === 'local';
19-
private maAccessTokenDate: Date;
20-
private maAccessToken: string;
21-
private crmAccessTokenDate: Date;
22-
private crmAccessToken: string;
23-
24-
private async getMaAccessToken(): Promise<string> {
25-
if (
26-
this.maAccessToken &&
27-
this.maAccessTokenDate &&
28-
new Date().getTime() - this.maAccessTokenDate.getTime() < 3500000
29-
) {
30-
if (this.log) console.log('Using cached ma access token');
31-
32-
// 3500000 = 58 minutes
33-
return this.maAccessToken;
34-
}
35-
if (process.env.LEAD_REFRESH_TOKEN && process.env.LEAD_CLIENT_ID && process.env.LEAD_CLIENT_SECRET) {
36-
// eslint-disable-next-line max-len
37-
const url = `https://accounts.zoho.com/oauth/v2/token?client_id=${process.env.LEAD_CLIENT_ID}&grant_type=refresh_token&client_secret=${process.env.LEAD_CLIENT_SECRET}&refresh_token=${process.env.LEAD_REFRESH_TOKEN}`;
38-
if (this.log) console.log('Lead URL', url);
39-
40-
const response = await axios.post(url);
41-
this.maAccessTokenDate = new Date();
42-
this.maAccessToken = response.data.access_token;
43-
if (this.log) console.log('New access token generated', this.maAccessToken);
44-
45-
return response.data.access_token;
46-
}
47-
48-
return undefined;
49-
}
50-
private async getCRMAccessToken(): Promise<string> {
51-
if (
52-
this.crmAccessToken &&
53-
this.crmAccessTokenDate &&
54-
new Date().getTime() - this.crmAccessTokenDate.getTime() < 3500000
55-
) {
56-
if (this.log) console.log('Using cached crm access token');
57-
58-
// 3500000 = 58 minutes
59-
return this.maAccessToken;
60-
}
61-
if (process.env.CRM_REFRESH_TOKEN && process.env.CRM_CLIENT_ID && process.env.CRM_CLIENT_SECRET) {
62-
// eslint-disable-next-line max-len
63-
const url = `https://accounts.zoho.com/oauth/v2/token?client_id=${process.env.CRM_CLIENT_ID}&grant_type=refresh_token&client_secret=${process.env.CRM_CLIENT_SECRET}&refresh_token=${process.env.CRM_REFRESH_TOKEN}`;
64-
if (this.log) console.log('CRM URL', url);
65-
66-
const response = await axios.post(url);
67-
this.crmAccessTokenDate = new Date();
68-
this.crmAccessToken = response.data.access_token;
69-
if (this.log) console.log('New crm token generated', this.crmAccessToken);
70-
71-
return response.data.access_token;
72-
}
73-
74-
return undefined;
75-
}
76-
77-
public async createLead(data: ILeadInformation): Promise<any> {
78-
const maAccessToken = await this.getMaAccessToken();
79-
if (maAccessToken) {
80-
const leadData = JSON.stringify({
81-
'First Name': data['First Name'],
82-
'Last Name': data['Last Name'],
83-
'Lead Email': data['Lead Email'],
84-
});
85-
// Add Lead to marketing automation
86-
// eslint-disable-next-line max-len
87-
const maUrl = `https://marketingautomation.zoho.com/api/v1/json/listsubscribe?listkey=${process.env.LEAD_LIST_KEY}&leadinfo=${leadData}&topic_id=${process.env.LEAD_TOPIC_ID}`;
88-
if (this.log) console.log(maUrl);
89-
90-
try {
91-
const maResponse = await axios.post(
92-
maUrl,
93-
{},
94-
{
95-
headers: {
96-
Authorization: `Zoho-oauthtoken ${maAccessToken}`,
97-
},
98-
}
99-
);
100-
if (this.log) console.log('Lead created', maResponse.data);
101-
} catch (error) {
102-
captureException(error);
103-
}
104-
}
105-
const crmAccessToken = await this.getCRMAccessToken();
106-
if (crmAccessToken) {
107-
// Add Lead to Zoho CRM
108-
const crmUrl = `https://www.zohoapis.com/crm/v6/Leads`;
109-
if (this.log) console.log(crmUrl);
11019

20+
public async createLead(data: ILeadInformation): Promise<void> {
21+
if (process.env.LEAD_MAKE_WEBHOOK_URL) {
11122
try {
112-
const crmResponse = await axios.post(
113-
crmUrl,
114-
{
115-
data: [
116-
{
117-
Last_Name: data['Last Name'],
118-
First_Name: data['First Name'],
119-
Email: data['Lead Email'],
120-
Lead_Source: data['Lead Source'],
121-
Signup_Method: data['Signup Method'],
122-
Mentioned_Role: data['Mentioned Role'],
123-
Company_Size: [data['Company Size']],
124-
},
125-
],
126-
},
127-
{
128-
headers: {
129-
Authorization: `Zoho-oauthtoken ${crmAccessToken}`,
130-
},
131-
}
132-
);
133-
if (this.log) console.log('CRM LEad created', crmResponse.data);
23+
await axios.post(process.env.LEAD_MAKE_WEBHOOK_URL, {
24+
firstName: data['First Name'],
25+
lastName: data['Last Name'],
26+
email: data['Lead Email'],
27+
signupMethod: data['Signup Method'],
28+
mentionedRole: data['Mentioned Role'],
29+
leadSource: data['Lead Source'],
30+
companySize: data['Company Size'],
31+
createdAt: new Date(),
32+
});
33+
if (this.log) console.log('Lead data sent to Make.com webhook');
13434
} catch (error) {
13535
captureException(error);
36+
console.error('Error sending data to Make.com webhook:', error);
13637
}
13738
}
13839
}

apps/api/src/app/template/commands/update-destination.command.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
} from 'class-validator';
1313
import { Type } from 'class-transformer';
1414
import { BaseCommand } from '@shared/commands/base.command';
15-
import { BubbleDestinationEnvironmentEnum, DestinationsEnum } from '@impler/shared';
15+
import { DestinationsEnum } from '@impler/shared';
1616

1717
export class WebhookDestinationObject {
1818
@IsUrl()
@@ -42,7 +42,7 @@ export class BubbleIoDestinationObject {
4242
@IsString()
4343
@IsDefined()
4444
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
45-
appName: string;
45+
bubbleAppUrl: string;
4646

4747
@IsString()
4848
@IsDefined()
@@ -54,15 +54,19 @@ export class BubbleIoDestinationObject {
5454
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
5555
datatype: string;
5656

57-
@IsEnum(BubbleDestinationEnvironmentEnum)
58-
@IsDefined()
59-
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
60-
environment: BubbleDestinationEnvironmentEnum;
57+
/*
58+
* @IsEnum(BubbleDestinationEnvironmentEnum)
59+
* @IsDefined()
60+
* @ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
61+
* environment: BubbleDestinationEnvironmentEnum;
62+
*/
6163

62-
@IsString()
63-
@IsOptional()
64-
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
65-
customDomainName?: string;
64+
/*
65+
* @IsString()
66+
* @IsOptional()
67+
* @ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
68+
* customDomainName?: string;
69+
*/
6670
}
6771

6872
export class UpdateDestinationCommand extends BaseCommand {

apps/api/src/app/template/dtos/destination-response.dto.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ export class DestinationResponseDto {
1010
retryCount?: number;
1111
};
1212
bubbleio?: {
13-
appName: string;
13+
bubbleAppUrl: string;
1414
apiPrivateKey: string;
1515
datatype: string;
16-
environment: string;
17-
customDomainName?: string;
1816
};
1917
}

apps/api/src/app/template/dtos/update-destination-request.dto.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
IsNotEmptyObject,
1111
ValidateNested,
1212
} from 'class-validator';
13-
import { BubbleDestinationEnvironmentEnum, DestinationsEnum } from '@impler/shared';
13+
import { DestinationsEnum } from '@impler/shared';
1414
import { Type } from 'class-transformer';
1515

1616
class WebhookDestinationObject {
@@ -41,7 +41,7 @@ class BubbleIoDestinationObject {
4141
@IsString()
4242
@IsDefined()
4343
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
44-
appName: string;
44+
bubbleAppUrl: string;
4545

4646
@IsString()
4747
@IsDefined()
@@ -53,15 +53,19 @@ class BubbleIoDestinationObject {
5353
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
5454
datatype: string;
5555

56-
@IsEnum(BubbleDestinationEnvironmentEnum)
57-
@IsDefined()
58-
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
59-
environment: BubbleDestinationEnvironmentEnum;
56+
/*
57+
* @IsEnum(BubbleDestinationEnvironmentEnum)
58+
* @IsDefined()
59+
* @ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
60+
* environment: BubbleDestinationEnvironmentEnum;
61+
*/
6062

61-
@IsString()
62-
@IsOptional()
63-
@ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
64-
customDomainName?: string;
63+
/*
64+
* @IsString()
65+
* @IsOptional()
66+
* @ValidateIf((obj) => obj.destination === DestinationsEnum.BUBBLEIO)
67+
* customDomainName?: string;
68+
*/
6569
}
6670

6771
export class UpdateDestinationDto {

apps/queue-manager/src/consumers/send-bubble-data.consumer.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
7676

7777
await this.makeResponseEntry(
7878
response,
79-
{ datatype: cachedData.datatype, environment: cachedData.environment, url: cachedData.bubbleUrl },
79+
{ bubbleAppUrl: cachedData.bubbleUrl, datatype: cachedData.datatype },
8080
cachedData.name,
8181
cachedData.email
8282
);
@@ -142,7 +142,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
142142
const templateData = await this.templateRepository.findById(uploadata._templateId, 'name');
143143

144144
const bubbleDestination = await this.bubbleDestinationRepository.findOne({ _templateId: uploadata._templateId });
145-
const bubbleUrl = this.bubbleBaseService.createBubbleIoUrl(bubbleDestination, 'bulk');
145+
const bubbleUrl = bubbleDestination.bubbleAppUrl;
146146

147147
const defaultValueObj = {};
148148
const customSchema = JSON.parse(uploadata.customSchema) as ITemplateSchemaItem;
@@ -168,7 +168,6 @@ export class SendBubbleDataConsumer extends BaseConsumer {
168168
email: userEmail,
169169
datatype: bubbleDestination.datatype,
170170
name: templateData.name,
171-
environment: bubbleDestination.environment,
172171
_templateId: uploadata._templateId,
173172
recordFormat: uploadata.customRecordFormat,
174173
defaultValues: JSON.stringify(defaultValueObj),
@@ -179,7 +178,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
179178

180179
private async makeResponseEntry(
181180
data: Partial<WebhookLogEntity>,
182-
bubbleData: { datatype: string; environment: string; url: string },
181+
bubbleData: { datatype: string; bubbleAppUrl: string },
183182
importName: string,
184183
userEmail: string
185184
) {
@@ -191,8 +190,7 @@ export class SendBubbleDataConsumer extends BaseConsumer {
191190
importName,
192191
time: data.callDate.toString(),
193192
datatype: bubbleData.datatype,
194-
environment: bubbleData.environment,
195-
url: bubbleData.url,
193+
bubbleAppUrl: bubbleData.bubbleAppUrl,
196194
importId: data._uploadId,
197195
},
198196
});

apps/web/components/imports/destination/Destination.tsx

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { Stack, TextInput as Input, Group, Select } from '@mantine/core';
44

55
import { Button } from '@ui/button';
66
import { NumberInput } from '@ui/number-input';
7-
import { DoaminInput } from '@ui/domain-input';
87
import { DOCUMENTATION_REFERENCE_LINKS, REGULAR_EXPRESSIONS } from '@config';
9-
import { NativeSelect } from '@ui/native-select';
108
import { useDestination } from '@hooks/useDestination';
119
import { DestinationItem } from './DestinationItem';
1210

@@ -16,7 +14,6 @@ interface DestinationProps {
1614

1715
export function Destination({ template }: DestinationProps) {
1816
const {
19-
watch,
2017
errors,
2118
control,
2219
onSubmit,
@@ -45,7 +42,6 @@ export function Destination({ template }: DestinationProps) {
4542
}
4643
}
4744
};
48-
const bubbleDestinationEnvironment = watch('bubbleIo.environment');
4945

5046
return (
5147
<Stack>
@@ -148,48 +144,13 @@ export function Destination({ template }: DestinationProps) {
148144
>
149145
<form onSubmit={onSubmit}>
150146
<Stack spacing="xs">
151-
<Controller
152-
name="bubbleIo.appName"
153-
control={control}
154-
render={({ field }) => (
155-
<DoaminInput
156-
value={field.value}
157-
label="Bubble App Name"
158-
onChange={field.onChange}
159-
rightSection=".bubbleapps.io"
160-
placeholder="Bubble Application Name"
161-
error={errors.bubbleIo?.appName?.message}
162-
/>
163-
)}
164-
/>
165-
166-
<Controller
167-
control={control}
168-
name="bubbleIo.environment"
169-
render={({ field }) => (
170-
<NativeSelect
171-
register={{
172-
value: field.value,
173-
onChange: field.onChange,
174-
}}
175-
required
176-
label="Environment"
177-
data={['development', 'production']}
178-
error={errors.bubbleIo?.environment?.message}
179-
/>
180-
)}
147+
<Input
148+
required
149+
label="Bubble App URL"
150+
placeholder="Bubble App URL"
151+
{...register('bubbleIo.bubbleAppUrl')}
152+
error={errors?.bubbleIo?.bubbleAppUrl?.message}
181153
/>
182-
{bubbleDestinationEnvironment === 'production' && (
183-
<Input
184-
label="Custom Domain Name"
185-
placeholder="Custom Domain Name"
186-
{...register('bubbleIo.customDomainName', {
187-
pattern: /^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$/,
188-
})}
189-
description="Required, if application is hosted on custom domain. Ex. myapp.io"
190-
error={errors?.bubbleIo?.customDomainName ? 'Please enter valid domain name' : undefined}
191-
/>
192-
)}
193154
<Input
194155
required
195156
label="API Private Key"

apps/web/config/constants.config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ export const HOW_HEARD_ABOUT_US = [
436436
{ value: 'Colleague', label: 'Colleague' },
437437
{ value: 'Linkdin', label: 'Linkdin' },
438438
{ value: 'Invitation', label: 'Invitation' },
439+
{ value: 'AI (ChatGPT, Perplexity, Claude ...)', label: 'AI (ChatGPT, Perplexity, Claude ...)' },
439440
];
440441

441442
export const PLACEHOLDERS = {
@@ -445,7 +446,7 @@ export const PLACEHOLDERS = {
445446
fullName: 'John Doe',
446447
companySize: 'Only me',
447448
role: 'Engineer, Manager, Founder...',
448-
source: 'Google Search, Recommendation...',
449+
source: 'Google Search, AI (ChatGPT, Perplexity, Claude ...), Recommendation...',
449450
about: 'Google Search',
450451
importName: 'Products, Employees, Assets...',
451452
};

0 commit comments

Comments
 (0)