2
0
Эх сурвалжийг харах

Make uniqueness key uuid, use max referrals in fe

Mauricio Araujo 2 жил өмнө
parent
commit
7b0fbe2d80

+ 3 - 16
dashboard/src/main/home/project-settings/BillingPage.tsx

@@ -57,19 +57,6 @@ function BillingPage(): JSX.Element {
 
   const { usage } = useCustomerUsage("day", true);
 
-  const trialEnding = (starting_on: string, ending_before: string): string => {
-    if (ending_before === undefined) {
-      return "";
-    }
-
-    const diff = dayjs(ending_before).diff(dayjs());
-    if (diff <= 0) {
-      return `Started on  ${readableDate(starting_on)}`;
-    }
-
-    return `Free trial ends ${dayjs().to(dayjs(ending_before))}`;
-  };
-
   const processedData = useMemo(() => {
     const before = usage;
     const resultMap = new Map();
@@ -270,8 +257,8 @@ function BillingPage(): JSX.Element {
           </Text>
           <Spacer y={1} />
           {usage?.length &&
-          usage.length > 0 &&
-          usage[0].usage_metrics.length > 0 ? (
+            usage.length > 0 &&
+            usage[0].usage_metrics.length > 0 ? (
             <Flex>
               <BarWrapper>
                 <Bars
@@ -343,7 +330,7 @@ function BillingPage(): JSX.Element {
           <Spacer y={1} />
           <Text color="helper">
             You have referred{" "}
-            {referralDetails ? referralDetails.referral_count : "?"}/10 users.
+            {referralDetails ? referralDetails.referral_count : "?"}/{referralDetails?.max_allowed_referrals} users.
           </Text>
         </Modal>
       )}

+ 7 - 6
dashboard/src/shared/types.tsx

@@ -289,15 +289,15 @@ export type FormElement = {
 export type RepoType = {
   FullName: string;
 } & (
-  | {
+    | {
       Kind: "github";
       GHRepoID: number;
     }
-  | {
+    | {
       Kind: "gitlab";
       GitIntegrationId: number;
     }
-);
+  );
 
 export type FileType = {
   path: string;
@@ -344,6 +344,7 @@ export type ProjectType = {
     user_id: number;
     project_id: number;
   }>;
+  referral_code: string;
 };
 
 export type ChoiceType = {
@@ -379,15 +380,15 @@ export type ActionConfigType = {
   image_repo_uri: string;
   dockerfile_path?: string;
 } & (
-  | {
+    | {
       kind: "gitlab";
       gitlab_integration_id: number;
     }
-  | {
+    | {
       kind: "github";
       git_repo_id: number;
     }
-);
+  );
 
 export type GithubActionConfigType = ActionConfigType & {
   kind: "github";

+ 1 - 4
internal/billing/metronome.go

@@ -272,12 +272,9 @@ func (m MetronomeClient) CreateCreditsGrant(ctx context.Context, customerID uuid
 		return telemetry.Error(ctx, span, err, "failed to get credit type id")
 	}
 
-	// Uniqueness key is used to prevent duplicate grants
-	uniquenessKey := fmt.Sprintf("%s-referral-reward", customerID)
-
 	req := types.CreateCreditsGrantRequest{
 		CustomerID:    customerID,
-		UniquenessKey: uniquenessKey,
+		UniquenessKey: uuid.NewString(),
 		GrantAmount: types.GrantAmountID{
 			Amount:       grantAmount,
 			CreditTypeID: creditTypeID,