Skip to content
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

🪟 🧪 Add Purchase credits CTA on trial expiry banner. #22207

Merged
merged 2 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airbyte-webapp/src/packages/cloud/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
"password.validation": "Your password is too weak",
"password.invalid": "Invalid password",

"trial.alertMessage": "You are using a trial of Airbyte. Your trial ends in <b>{value, plural, one {# day} other {# days}}</b>.",
"trial.alertMessage": "You are using a trial of Airbyte. Your trial ends in <b>{remainingDays, plural, one {# day} other {# days}}</b>.",

"verifyEmail.notification": "You successfully verified your email. Thank you.",

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import classNames from "classnames";
import React, { useMemo } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { FormattedMessage } from "react-intl";
import { Link, Outlet } from "react-router-dom";

import { LoadingPage } from "components";
Expand All @@ -22,7 +22,6 @@ import { InsufficientPermissionsErrorBoundary } from "./InsufficientPermissionsE
import styles from "./MainView.module.scss";

const MainView: React.FC<React.PropsWithChildren<unknown>> = (props) => {
const { formatMessage } = useIntl();
useIntercom();
const workspace = useCurrentWorkspace();
const cloudWorkspace = useGetCloudWorkspace(workspace.workspaceId);
Expand All @@ -38,6 +37,7 @@ const MainView: React.FC<React.PropsWithChildren<unknown>> = (props) => {
const alertToShow = showCreditsBanner ? "credits" : cloudWorkspace.trialExpiryTimestamp ? "trial" : undefined;
// exp-speedy-connection
const { isExperimentVariant } = useExperimentSpeedyConnection();

const { hasCorporateEmail } = useAuthService();
const isTrial = Boolean(cloudWorkspace.trialExpiryTimestamp);
const showExperimentBanner = isExperimentVariant && isTrial && hasCorporateEmail();
Expand All @@ -62,10 +62,18 @@ const MainView: React.FC<React.PropsWithChildren<unknown>> = (props) => {
// calculate days (rounding up if decimal)
const trialRemainingDays = Math.ceil(trialRemainingMilliseconds / (1000 * 60 * 60 * 24));

return formatMessage({ id: "trial.alertMessage" }, { value: trialRemainingDays });
return (
<FormattedMessage
id="trial.alertMessage"
values={{
remainingDays: trialRemainingDays,
lnk: (cta: React.ReactNode) => <Link to={CloudRoutes.Credits}>{cta}</Link>,
}}
/>
);
}
return null;
}, [alertToShow, cloudWorkspace, formatMessage]);
}, [alertToShow, cloudWorkspace]);

return (
<div className={styles.mainContainer}>
Expand Down