Skip to content

Commit

Permalink
🐛 fix(subscribe): Discount
Browse files Browse the repository at this point in the history
  • Loading branch information
web-ppanel committed Dec 5, 2024
1 parent 5eec430 commit 35a9f69
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/user/app/(main)/(user)/order/purchase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export default function Purchase({
1 {t('month')}
</Label>
</div>
{subscribe?.discount.map((item) => (
{subscribe?.discount?.map((item) => (
<div key={item.months}>
<RadioGroupItem
value={String(item.months)}
Expand Down
22 changes: 2 additions & 20 deletions apps/user/app/(main)/(user)/order/renewal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ import { useEffect, useState, useTransition } from 'react';
import { SubscribeBilling } from '../subscribe/billing';
import { SubscribeDetail } from '../subscribe/detail';

export default function Renewal({
mark,
subscribe,
}: {
mark: string;
subscribe: Omit<API.Subscribe, 'discount'> & {
discount: string | API.SubscribeDiscount[];
};
}) {
export default function Renewal({ mark, subscribe }: { mark: string; subscribe: API.Subscribe }) {
const t = useTranslations('order');
const { getUserInfo } = useGlobalStore();
const [open, setOpen] = useState<boolean>(false);
Expand Down Expand Up @@ -74,16 +66,6 @@ export default function Renewal({
}
}, [subscribe.id, mark]);

function getDiscount() {
try {
if (typeof subscribe.discount === 'string') {
return JSON.parse(subscribe?.discount) as API.SubscribeDiscount[];
}
return subscribe?.discount;
} catch (error) {
return [];
}
}
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>
Expand Down Expand Up @@ -134,7 +116,7 @@ export default function Renewal({
1 {t('month')}
</Label>
</div>
{getDiscount().map((item) => (
{subscribe?.discount?.map((item) => (
<div key={item.months}>
<RadioGroupItem
value={String(item.months)}
Expand Down

0 comments on commit 35a9f69

Please sign in to comment.