Skip to content

Commit 5ed15fb

Browse files
densumeshskeptrunedev
authored andcommitted
feature: add banner for usage limit
1 parent aa97732 commit 5ed15fb

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

clients/trieve-shopify-extension/app/components/PlanView.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useSubmit } from "@remix-run/react";
2-
import { BlockStack, Box, Button, Card, DescriptionList, DescriptionListProps, InlineStack, Text } from "@shopify/polaris";
2+
import { BlockStack, Box, Button, Card, DescriptionList, DescriptionListProps, InlineStack, Text, Banner } from "@shopify/polaris";
33
import { ProgressBar } from "./ProgressBar";
44

55
export const PlanView = ({
@@ -45,7 +45,32 @@ export const PlanView = ({
4545
</Box>
4646

4747
<Box paddingInline="400" paddingBlockEnd="400">
48-
<ProgressBar progress={usagePercentage} />
48+
{usagePercentage >= 80 && usagePercentage < 90 && (
49+
<Box paddingBlockEnd="400">
50+
<Banner
51+
title={`You are at ${usagePercentage}% of your usage limit.`}
52+
tone="warning"
53+
>
54+
<p>Consider upgrading your plan to avoid potential disruptions.</p>
55+
</Banner>
56+
</Box>
57+
)}
58+
{usagePercentage >= 90 && (
59+
<Box paddingBlockEnd="400">
60+
<Banner
61+
title={`You have reached ${usagePercentage}% of your usage limit.`}
62+
tone="critical"
63+
>
64+
<p>Upgrade your plan immediately to avoid service disruption.</p>
65+
</Banner>
66+
</Box>
67+
)}
68+
<div className="w-full">
69+
<span className="text-sm font-bold pb-1">
70+
Usage
71+
</span>
72+
<ProgressBar progress={usagePercentage} />
73+
</div>
4974
<DescriptionList items={planItems} />
5075
</Box>
5176
</BlockStack>

clients/trieve-shopify-extension/app/components/ProgressBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const ProgressBar: React.FC<ProgressBarProps> = ({ progress }) => {
1010

1111
return (
1212
<Box paddingBlockEnd="200">
13-
<div className="w-full bg-gray-200 rounded overflow-hidden h-2 mb-1">
13+
<div className="w-full bg-gray-200 rounded overflow-hidden h-2 mb-1 mt-1">
1414
<div
1515
className="bg-[#800080e6] h-full transition-width duration-300 ease-in-out"
1616
style={{ width: `${progressPercentage}%` }}

clients/trieve-shopify-extension/app/routes/app._dashboard._index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { TotalUniqueVisitors } from "app/components/analytics/component/TotalUni
3636
import { TopPages } from "app/components/analytics/component/TopPages";
3737
import { useState } from "react";
3838
import { defaultSearchAnalyticsFilter } from "app/queries/analytics/search";
39-
import { Granularity } from "trieve-ts-sdk";
39+
import { Granularity, StripePlan } from "trieve-ts-sdk";
4040
import { ActionFunctionArgs } from "@remix-run/node";
4141
import { authenticate } from "app/shopify.server";
4242
import { PlanView } from "app/components/PlanView";
@@ -131,8 +131,8 @@ export default function Dashboard() {
131131
if (organization?.plan?.type === "flat") {
132132
planItems.push(
133133
{
134-
term: "Messages Sent",
135-
description: organizationUsage?.current_months_message_count?.toLocaleString() || "N/A",
134+
term: "Message Usage",
135+
description: `${organizationUsage?.current_months_message_count?.toLocaleString() ?? 0} / ${(organization?.plan as StripePlan)?.message_count.toLocaleString()}`,
136136
},
137137
);
138138
}
@@ -253,7 +253,7 @@ export default function Dashboard() {
253253
<Box paddingInline="400" paddingBlockStart="400">
254254
<InlineStack align="space-between">
255255
<Text variant="headingMd" as="h2">
256-
Usage Overview
256+
Sync Status
257257
</Text>
258258
<Badge>{planType + " Plan"}</Badge>
259259
</InlineStack>
@@ -280,7 +280,7 @@ export default function Dashboard() {
280280
<PlanView
281281
planItems={planItems}
282282
setShowCancelModal={setShowCancelModal}
283-
usagePercentage={(organizationUsage?.current_months_message_count ?? 0) / organization?.plan?.component_loads}
283+
usagePercentage={((organizationUsage?.current_months_message_count ?? 0) / (organization?.plan as StripePlan)?.message_count) * 100}
284284
/>
285285
</BlockStack>
286286
</Layout.Section>

clients/trieve-shopify-extension/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9353,9 +9353,9 @@ trieve-search-component@0.4.55:
93539353
trieve-ts-sdk "0.0.73"
93549354

93559355
trieve-ts-sdk@*:
9356-
version "0.0.82"
9357-
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.82.tgz#32dcd5cfe37706bd4cff952f415f2d3b15e1f198"
9358-
integrity sha512-d3qvhYd+KjsImB313xt8rbbJ0ZaaIMKmxhzZaFeXy6uPRvjWPUWKIDYKG4E/a0wvsEkW++zfmP+UlYBB2W+e6w==
9356+
version "0.0.83"
9357+
resolved "https://registry.yarnpkg.com/trieve-ts-sdk/-/trieve-ts-sdk-0.0.83.tgz#a9bd0bbd71e09f3f9017844d91894fde95c5edb9"
9358+
integrity sha512-EPDy342dDTNVmzzALMtk9JExCn5yt1oyp9moiS4VLyN52hFaKY4MxoSsEp9/Bp7PRNXS2Z8u1H+PTn+joovhbw==
93599359

93609360
trieve-ts-sdk@0.0.73:
93619361
version "0.0.73"

clients/ts-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"files": [
1818
"dist"
1919
],
20-
"version": "0.0.81",
20+
"version": "0.0.83",
2121
"license": "MIT",
2222
"scripts": {
2323
"lint": "eslint 'src/**/*.ts'",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
"devDependencies": {
2929
"turbo": "^2.0.4"
3030
},
31-
"packageManager": "yarn@1.22.22"
31+
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
3232
}

0 commit comments

Comments
 (0)