Skip to content

Commit 3e7537d

Browse files
tenubbpapillon
andauthored
minor fixes (#67)
* add unlimited allocation type check; don't filter available plans (for editor) * remove extraneous memo dep --------- Co-authored-by: Benjamin Papillon <[email protected]>
1 parent 3442772 commit 3e7537d

File tree

4 files changed

+106
-106
lines changed

4 files changed

+106
-106
lines changed

react/src/components/elements/included-features/IncludedFeatures.tsx

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -200,53 +200,59 @@ export const IncludedFeatures = forwardRef<
200200
)}
201201
</Flex>
202202

203-
{allocationType === "numeric" && feature?.name && (
204-
<Box $textAlign="right" $paddingLeft="3.5rem">
205-
{props.entitlement.isVisible && (
206-
<Text
207-
as={Box}
208-
$font={
209-
theme.typography[props.entitlement.fontStyle].fontFamily
210-
}
211-
$size={
212-
theme.typography[props.entitlement.fontStyle].fontSize
213-
}
214-
$weight={
215-
theme.typography[props.entitlement.fontStyle].fontWeight
216-
}
217-
$lineHeight={1.5}
218-
$color={
219-
theme.typography[props.entitlement.fontStyle].color
220-
}
221-
>
222-
{typeof allocation === "number"
223-
? `${formatNumber(allocation)} ${pluralize(feature.name, allocation)}`
224-
: `Unlimited ${pluralize(feature.name)}`}
225-
</Text>
226-
)}
203+
{(allocationType === "numeric" ||
204+
allocationType === "unlimited") &&
205+
feature?.name && (
206+
<Box $textAlign="right" $paddingLeft="3.5rem">
207+
{props.entitlement.isVisible && (
208+
<Text
209+
as={Box}
210+
$font={
211+
theme.typography[props.entitlement.fontStyle]
212+
.fontFamily
213+
}
214+
$size={
215+
theme.typography[props.entitlement.fontStyle].fontSize
216+
}
217+
$weight={
218+
theme.typography[props.entitlement.fontStyle]
219+
.fontWeight
220+
}
221+
$lineHeight={1.5}
222+
$color={
223+
theme.typography[props.entitlement.fontStyle].color
224+
}
225+
>
226+
{typeof allocation === "number"
227+
? `${formatNumber(allocation)} ${pluralize(feature.name, allocation)}`
228+
: `Unlimited ${pluralize(feature.name)}`}
229+
</Text>
230+
)}
227231

228-
{props.usage.isVisible && (
229-
<Text
230-
as={Box}
231-
$font={theme.typography[props.usage.fontStyle].fontFamily}
232-
$size={theme.typography[props.usage.fontStyle].fontSize}
233-
$weight={
234-
theme.typography[props.usage.fontStyle].fontWeight
235-
}
236-
$lineHeight={1.5}
237-
$color={theme.typography[props.usage.fontStyle].color}
238-
>
239-
{typeof usage === "number" && (
240-
<>
241-
{typeof allocation === "number"
242-
? `${formatNumber(usage)} of ${formatNumber(allocation)} used`
243-
: `${formatNumber(usage)} used`}
244-
</>
245-
)}
246-
</Text>
247-
)}
248-
</Box>
249-
)}
232+
{props.usage.isVisible && (
233+
<Text
234+
as={Box}
235+
$font={
236+
theme.typography[props.usage.fontStyle].fontFamily
237+
}
238+
$size={theme.typography[props.usage.fontStyle].fontSize}
239+
$weight={
240+
theme.typography[props.usage.fontStyle].fontWeight
241+
}
242+
$lineHeight={1.5}
243+
$color={theme.typography[props.usage.fontStyle].color}
244+
>
245+
{typeof usage === "number" && (
246+
<>
247+
{typeof allocation === "number"
248+
? `${formatNumber(usage)} of ${formatNumber(allocation)} used`
249+
: `${formatNumber(usage)} used`}
250+
</>
251+
)}
252+
</Text>
253+
)}
254+
</Box>
255+
)}
250256
</Flex>,
251257
];
252258
},

react/src/components/elements/metered-features/MeteredFeatures.tsx

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -179,54 +179,58 @@ export const MeteredFeatures = forwardRef<
179179
</Box>
180180
)}
181181

182-
{allocationType === "numeric" && feature?.name && (
183-
<Box $textAlign="right">
184-
{props.allocation.isVisible && (
185-
<Text
186-
as={Box}
187-
$font={
188-
theme.typography[props.allocation.fontStyle]
189-
.fontFamily
190-
}
191-
$size={
192-
theme.typography[props.allocation.fontStyle]
193-
.fontSize
194-
}
195-
$weight={
196-
theme.typography[props.allocation.fontStyle]
197-
.fontWeight
198-
}
199-
$color={
200-
theme.typography[props.allocation.fontStyle].color
201-
}
202-
>
203-
{typeof allocation === "number"
204-
? `${allocation} ${feature.name}`
205-
: `Unlimited ${feature.name}`}
206-
</Text>
207-
)}
182+
{(allocationType === "numeric" ||
183+
allocationType === "unlimited") &&
184+
feature?.name && (
185+
<Box $textAlign="right">
186+
{props.allocation.isVisible && (
187+
<Text
188+
as={Box}
189+
$font={
190+
theme.typography[props.allocation.fontStyle]
191+
.fontFamily
192+
}
193+
$size={
194+
theme.typography[props.allocation.fontStyle]
195+
.fontSize
196+
}
197+
$weight={
198+
theme.typography[props.allocation.fontStyle]
199+
.fontWeight
200+
}
201+
$color={
202+
theme.typography[props.allocation.fontStyle].color
203+
}
204+
>
205+
{typeof allocation === "number"
206+
? `${allocation} ${feature.name}`
207+
: `Unlimited ${feature.name}`}
208+
</Text>
209+
)}
208210

209-
{props.usage.isVisible && (
210-
<Text
211-
as={Box}
212-
$font={
213-
theme.typography[props.usage.fontStyle].fontFamily
214-
}
215-
$size={
216-
theme.typography[props.usage.fontStyle].fontSize
217-
}
218-
$weight={
219-
theme.typography[props.usage.fontStyle].fontWeight
220-
}
221-
$color={theme.typography[props.usage.fontStyle].color}
222-
>
223-
{typeof allocation === "number"
224-
? `${usage} of ${allocation} used`
225-
: `${usage} used`}
226-
</Text>
227-
)}
228-
</Box>
229-
)}
211+
{props.usage.isVisible && (
212+
<Text
213+
as={Box}
214+
$font={
215+
theme.typography[props.usage.fontStyle].fontFamily
216+
}
217+
$size={
218+
theme.typography[props.usage.fontStyle].fontSize
219+
}
220+
$weight={
221+
theme.typography[props.usage.fontStyle].fontWeight
222+
}
223+
$color={
224+
theme.typography[props.usage.fontStyle].color
225+
}
226+
>
227+
{typeof allocation === "number"
228+
? `${usage} of ${allocation} used`
229+
: `${usage} used`}
230+
</Text>
231+
)}
232+
</Box>
233+
)}
230234
</Flex>
231235

232236
{typeof usage === "number" &&

react/src/components/elements/plan-manager/CheckoutDialog.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const FeatureName = ({
4141

4242
if (
4343
entitlement.valueType === "numeric" ||
44+
entitlement.valueType === "unlimited" ||
4445
entitlement.valueType === "trait"
4546
) {
4647
let period;
@@ -126,20 +127,10 @@ export const CheckoutDialog = () => {
126127
return {
127128
paymentMethod: data.subscription?.paymentMethod,
128129
currentPlan: data.company?.plan,
129-
availablePlans: data.activePlans.filter(
130-
(plan) =>
131-
plan.current ||
132-
(plan.yearlyPrice && planPeriod === "year") ||
133-
(plan.monthlyPrice && planPeriod === "month"),
134-
),
130+
availablePlans: data.activePlans,
135131
planPeriodOptions,
136132
};
137-
}, [
138-
data.subscription?.paymentMethod,
139-
data.company,
140-
data.activePlans,
141-
planPeriod,
142-
]);
133+
}, [data.subscription?.paymentMethod, data.company, data.activePlans]);
143134

144135
const savingsPercentage = useMemo(() => {
145136
if (selectedPlan) {

react/src/components/elements/plan-manager/PlanManager.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export const PlanManager = forwardRef<
8888
canChangePlan:
8989
data.activePlans.length > 0 &&
9090
data.stripeEmbed?.publishableKey &&
91-
data.stripeEmbed?.setupIntentClientSecret &&
9291
stripe !== null,
9392
};
9493
}, [data.company, data.activePlans, data.stripeEmbed, stripe]);

0 commit comments

Comments
 (0)