Skip to content

Commit

Permalink
fix: contact sales form
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Jun 17, 2024
1 parent 3f0c801 commit a2633e2
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ export class ContactSalesComponent {
this.loading$.next(true);
this.sendRequest$ = this.flagService.getEdition().pipe(
switchMap((edition) => {
if (edition === ApEdition.CLOUD) {
return this.contactSalesService
.sendRequest(this.contactSalesForm.getRawValue())
.pipe(
tap(() => {
switch (edition) {
case ApEdition.CLOUD:
return this.contactSalesService
.sendRequest(this.contactSalesForm.getRawValue())
.pipe(
tap(() => {
this.snackbar.open(
$localize`Our sales team will be in contact with you soon.`,
Expand All @@ -139,47 +139,50 @@ export class ContactSalesComponent {
duration: 5000,
}
);
});
})
);
case ApEdition.ENTERPRISE:
case ApEdition.COMMUNITY: {
const trialKeyGenerationRequest$ = this.licenseKeysService
.createKey({
email: this.contactSalesForm.getRawValue().email,
})
);
}
const trialKeyGenerationRequest$ = this.licenseKeysService
.createKey({
email: this.contactSalesForm.getRawValue().email,
})
.pipe(
catchError((err: HttpErrorResponse) => {
if (
err.error?.code === ErrorCode.EMAIL_ALREADY_HAS_ACTIVATION_KEY
) {
this.contactSalesForm.controls.email.setErrors({
[ErrorCode.EMAIL_ALREADY_HAS_ACTIVATION_KEY]: true,
});
} else {
.pipe(
catchError((err: HttpErrorResponse) => {
if (
err.error?.code ===
ErrorCode.EMAIL_ALREADY_HAS_ACTIVATION_KEY
) {
this.contactSalesForm.controls.email.setErrors({
[ErrorCode.EMAIL_ALREADY_HAS_ACTIVATION_KEY]: true,
});
} else {
this.snackbar.open(
$localize`Unexpected error please contact support on community.activepieces.com`
);
}
this.loading$.next(false);
throw err;
})
);
return forkJoin({
trialKeyGenerationRequest$,
contactSalesRequest$: this.contactSalesService.sendRequest(
this.contactSalesForm.getRawValue()
),
}).pipe(
tap(() => {
this.snackbar.open(
$localize`Unexpected error please contact support on community.activepieces.com`
$localize`Please check your email for your trial key and further instructions.`,
'',
{
duration: 5000,
}
);
}
this.loading$.next(false);
throw err;
})
);
return forkJoin({
trialKeyGenerationRequest$,
contactSalesRequest$: this.contactSalesService.sendRequest(
this.contactSalesForm.getRawValue()
),
}).pipe(
tap(() => {
this.snackbar.open(
$localize`Please check your email for your trial key and further instructions.`,
'',
{
duration: 5000,
}
})
);
})
);
}
}
}),
tap(() => {
this.closeSlideout();
Expand Down
12 changes: 10 additions & 2 deletions packages/ui/common/src/lib/service/contact-sales.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ export class ContactSalesService {
take(1),
switchMap((flags) => {
return this.http.post<{ status: string; message?: string }>(
`https://cloud.activepieces.com/api/v1/webhooks/c0sK2GhG2ZSZRIq2uoKXU`,
{ ...req, flags }
'https://sales.activepieces.com/submit-inapp-contact-form',
{
name: req.name,
email: req.email,
numberOfEmployees: req.numberOfEmployees,
companyName: req.companyName,
goal: req.goal,
features: [],
flags,
}
);
})
);
Expand Down

0 comments on commit a2633e2

Please sign in to comment.