-
Notifications
You must be signed in to change notification settings - Fork 6
/
AppPlanOverviewCard.tsx
70 lines (65 loc) · 1.99 KB
/
AppPlanOverviewCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Button, Group } from "@pokt-foundation/pocket-blocks"
import { Form, useLocation } from "@remix-run/react"
import styles from "./styles.css"
import { Card, links as CardLinks } from "~/components/shared/Card"
import CardList, {
CardListItem,
links as CardListLinks,
} from "~/components/shared/CardList"
import { useTranslate } from "~/context/TranslateContext"
import { Stripe } from "~/models/stripe/stripe.server"
import { dayjs } from "~/utils/dayjs"
/* c8 ignore start */
export const links = () => {
return [...CardLinks(), ...CardListLinks(), { rel: "stylesheet", href: styles }]
}
/* c8 ignore stop */
interface PlanLatestInvoiceCardProps {
subscription: Stripe.Subscription
usageRecords: Stripe.ApiList<Stripe.UsageRecordSummary>
}
export default function AppPlanLatestInvoiceCard({
subscription,
usageRecords,
}: PlanLatestInvoiceCardProps) {
const { t } = useTranslate()
const location = useLocation()
const listItems: CardListItem[] = [
{
label: t.AppPlanOverviewCard.subscription,
value: subscription.id,
},
{
label: t.AppPlanOverviewCard.status,
value: subscription.status,
},
{
label: t.AppPlanOverviewCard.relays,
value: usageRecords.data[0].total_usage,
},
{
label: t.AppPlanOverviewCard.date,
value: dayjs.unix(Number(subscription.start_date)).toString(),
},
]
return (
<div className="pokt-app-plan-overview">
<Card>
<div className="pokt-card-header">
<h3>{t.AppPlanOverviewCard.title}</h3>
</div>
<div>
<CardList items={listItems} />
<Group mt="xl" position="right">
<Form action="/api/stripe/portal-session" method="post">
<input hidden defaultValue={location.pathname} name="return-path" />
<Button type="submit" variant="outline">
{t.AppPlanOverviewCard.managePlan}
</Button>
</Form>
</Group>
</div>
</Card>
</div>
)
}