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

🪟 🐛 Fix out of credits banner #15216

Merged
merged 3 commits into from
Aug 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions airbyte-webapp/src/packages/cloud/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@
"credits.connection": "Connection",
"credits.usage": "Usage",
"credits.noData": "Data is empty",
"credits.addCredits": "add credits",
teallarson marked this conversation as resolved.
Show resolved Hide resolved
"credits.creditsProblem.negative_within_grace_period": "Your workspace is out of credits! Please add more credits to make sure your syncs keep running!",
"credits.creditsProblem.negative_beyond_grace_period": "You’re out of credits! To set up connections and run syncs, <lnk>add credits</lnk>.",
"credits.creditsProblem.negative_max_threshold": "You’re out of credits! To set up connections and run syncs, <lnk>add credits</lnk>.",
"credits.creditsProblem.negative_beyond_grace_period": "You’re out of credits! To set up connections and run syncs, {lnk}.",
"credits.creditsProblem.negative_max_threshold": "You’re out of credits! To set up connections and run syncs, {lnk}.",
"credits.emailVerificationRequired": "You need to verify your email address before you can buy credits.",
"credits.emailVerification.resendConfirmation": "We send you a new verification link.",
"credits.emailVerification.resend": "Send verification link again",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useMemo } from "react";
import { useIntl } from "react-intl";
import { FormattedMessage, useIntl } from "react-intl";
import { Link, Outlet } from "react-router-dom";
import styled from "styled-components";

Expand Down Expand Up @@ -41,26 +41,33 @@ const MainView: React.FC = (props) => {
const { formatMessage } = useIntl();
const workspace = useCurrentWorkspace();
const cloudWorkspace = useGetCloudWorkspace(workspace.workspaceId);
cloudWorkspace.creditStatus = CreditStatus.NEGATIVE_BEYOND_GRACE_PERIOD;

console.log(cloudWorkspace);

const showCreditsBanner =
cloudWorkspace.creditStatus &&
[
CreditStatus.NEGATIVE_BEYOND_GRACE_PERIOD,
CreditStatus.NEGATIVE_MAX_THRESHOLD,
CreditStatus.NEGATIVE_WITHIN_GRACE_PERIOD,
].includes(cloudWorkspace.creditStatus) &&
!cloudWorkspace.trialExpiryTimestamp;
].includes(cloudWorkspace.creditStatus);

const alertToShow = showCreditsBanner ? "credits" : cloudWorkspace.trialExpiryTimestamp ? "trial" : undefined;

const alertMessage = useMemo(() => {
if (alertToShow === "credits") {
return formatMessage(
{ id: `credits.creditsProblem.${cloudWorkspace.creditStatus}` },
{
values: {
lnk: (content: React.ReactNode) => <Link to={CloudRoutes.Credits}>{content}</Link>,
},
}
return (
<FormattedMessage
id={`credits.creditsProblem.${cloudWorkspace.creditStatus}`}
values={{
lnk: (
<Link to={CloudRoutes.Credits}>
<FormattedMessage id="credits.addCredits" />
</Link>
),
}}
/>
);
} else if (alertToShow === "trial") {
const { trialExpiryTimestamp } = cloudWorkspace;
Expand Down