Skip to content

Commit c65e426

Browse files
committed
feat(shopify): enhance PlanView with plan details display and improve onboarding flow
1 parent adc71df commit c65e426

3 files changed

Lines changed: 34 additions & 18 deletions

File tree

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ import {
99
InlineStack,
1010
Text,
1111
Banner,
12+
Badge,
1213
} from "@shopify/polaris";
1314
import { ProgressBar } from "./ProgressBar";
15+
import { TrievePlan } from "trieve-ts-sdk";
1416

1517
export const PlanView = ({
18+
plan,
1619
planItems,
1720
setShowCancelModal,
1821
usagePercentage,
1922
}: {
23+
plan: TrievePlan | null | undefined;
2024
planItems: DescriptionListProps["items"];
2125
setShowCancelModal: (show: boolean) => void;
2226
usagePercentage: number;
@@ -28,10 +32,13 @@ export const PlanView = ({
2832
<BlockStack gap="400">
2933
<Box paddingInline="400" paddingBlockStart="400">
3034
<InlineStack align="space-between">
31-
<Text variant="headingMd" as="h2">
32-
Plan Details
33-
</Text>
34-
<div className="flex gap-2">
35+
<InlineStack gap="400" align="center" blockAlign="center">
36+
<Text variant="headingMd" as="h2">
37+
Plan Details
38+
</Text>
39+
<Badge>{plan?.name}</Badge>
40+
</InlineStack>
41+
<InlineStack gap="200" align="center" blockAlign="center">
3542
<Button
3643
onClick={() => {
3744
submit(
@@ -53,7 +60,7 @@ export const PlanView = ({
5360
>
5461
Cancel
5562
</Button>
56-
</div>
63+
</InlineStack>
5764
</InlineStack>
5865
</Box>
5966

@@ -82,10 +89,10 @@ export const PlanView = ({
8289
</Banner>
8390
</Box>
8491
)}
85-
<div className="w-full">
92+
<BlockStack>
8693
<span className="text-sm font-bold pb-1">Usage</span>
8794
<ProgressBar progress={usagePercentage} />
88-
</div>
95+
</BlockStack>
8996
<DescriptionList items={planItems} />
9097
</Box>
9198
</BlockStack>

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ import { Granularity, StripePlan } from "trieve-ts-sdk";
3737
import { ActionFunctionArgs } from "@remix-run/node";
3838
import { authenticate } from "app/shopify.server";
3939
import { PlanView } from "app/components/PlanView";
40+
41+
const currencyFormatter = new Intl.NumberFormat("en-US", {
42+
style: "currency",
43+
currency: "USD",
44+
});
45+
4046
const load: Loader = async ({ adminApiFetcher, queryClient }) => {
4147
await queryClient.ensureQueryData(lastStepIdQuery(adminApiFetcher));
4248
return;
@@ -81,8 +87,6 @@ export default function Dashboard() {
8187

8288
const { data: organizationUsage } = useQuery(organizationUsageQuery(trieve));
8389

84-
const planType = organization?.plan?.name || "Free";
85-
8690
const statsItems = [
8791
{
8892
term: "Products",
@@ -112,12 +116,7 @@ export default function Dashboard() {
112116
},
113117
];
114118

115-
let planItems = [
116-
{
117-
term: "Plan",
118-
description: planType,
119-
},
120-
];
119+
let planItems = [];
121120

122121
if (organization?.plan?.type === "flat") {
123122
planItems.push({
@@ -253,12 +252,11 @@ export default function Dashboard() {
253252
<Text variant="headingMd" as="h2">
254253
Sync Status
255254
</Text>
256-
<Badge>{planType + " Plan"}</Badge>
257255
</InlineStack>
258256
</Box>
259257

260258
<Box paddingInline="400">
261-
<DescriptionList items={statsItems} />
259+
<DescriptionList gap="tight" items={statsItems} />
262260
</Box>
263261

264262
<Box paddingInline="400" paddingBlockEnd="400">
@@ -276,6 +274,7 @@ export default function Dashboard() {
276274
</BlockStack>
277275
</Card>
278276
<PlanView
277+
plan={organization?.plan}
279278
planItems={planItems}
280279
setShowCancelModal={setShowCancelModal}
281280
usagePercentage={

clients/trieve-shopify-extension/app/utils/onboarding.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
lastStepIdQuery,
1414
ONBOARD_STEP_META_FIELD,
1515
} from "app/queries/onboarding";
16-
import { FC, useCallback, useMemo, useState } from "react";
16+
import { FC, useCallback, useEffect, useMemo, useState } from "react";
1717

1818
export type OnboardingBody = FC<{
1919
goToNextStep: () => void;
@@ -29,6 +29,7 @@ type OnboardingStep = {
2929
nextButtonText?: string;
3030
hideNextButton?: boolean;
3131
hidden?: boolean;
32+
openAction?: () => void;
3233
};
3334

3435
export const onboardingSteps: OnboardingStep[] = [
@@ -45,6 +46,9 @@ export const onboardingSteps: OnboardingStep[] = [
4546
defaultComplete: false,
4647
body: WelcomeOnboarding,
4748
nextButtonText: "Setup Component",
49+
openAction: () => {
50+
fetch("/app/setup");
51+
},
4852
},
4953
{
5054
// Name in a way that changing the step + adding more will not require id rename
@@ -104,6 +108,12 @@ export const useOnboarding = () => {
104108
return onboardingSteps.find((step) => step.id === currentStepId) || null;
105109
}, [currentStepId]);
106110

111+
useEffect(() => {
112+
if (currentStep?.openAction) {
113+
currentStep.openAction();
114+
}
115+
}, [currentStep]);
116+
107117
const goToNextStep = useCallback(() => {
108118
let currentStepIndex = onboardingSteps.findIndex(
109119
(step) => step.id === currentStepId,

0 commit comments

Comments
 (0)