Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pay Invoice #1866

Merged
merged 76 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
28aeb22
initial changes
FSM1 Dec 16, 2021
b4b1f21
wire up wallet
FSM1 Dec 16, 2021
c339448
Merge remote-tracking branch 'origin/dev' into feat/crypto-payment-1782
FSM1 Jan 6, 2022
cfbabe9
add circular progress bar label
FSM1 Jan 6, 2022
cb8c861
add currency icons
FSM1 Jan 7, 2022
b421d2d
add copy buttons
FSM1 Jan 7, 2022
db103c4
Merge branch 'dev' into feat/crypto-payment-1782
FSM1 Jan 7, 2022
120505a
lingui extract
actions-user Jan 7, 2022
26ff251
lint and padding
FSM1 Jan 7, 2022
1475b27
Apply suggestions from code review
FSM1 Jan 11, 2022
c66bbda
implement fixes
FSM1 Jan 11, 2022
7649eb7
Merge remote-tracking branch 'origin/dev' into feat/crypto-payment-1782
FSM1 Jan 11, 2022
5d2493f
lingui extract
actions-user Jan 11, 2022
a364094
Update packages/files-ui/src/Components/Modules/Settings/Subscription…
FSM1 Jan 11, 2022
c27ead3
fixes from comments
FSM1 Jan 12, 2022
8907d28
remove unnecessary prop
FSM1 Jan 12, 2022
c2f7a7d
temp daily duration for testing - revert before merge
FSM1 Jan 12, 2022
ace49c3
fix dark mode icon colors
FSM1 Jan 12, 2022
c6cd7ca
update api client to latest
FSM1 Jan 14, 2022
1279178
Merge branch 'dev' into feat/crypto-payment-1782
FSM1 Jan 14, 2022
ec4048c
Apply suggestions from code review
FSM1 Jan 14, 2022
1d29c99
revert conflict marker
FSM1 Jan 14, 2022
c0e680f
Merge branch 'feat/crypto-payment-1782' of https://github.com/ChainSa…
FSM1 Jan 14, 2022
a9da33f
remove max-content width
FSM1 Jan 14, 2022
35ad8ef
wip
Tbaut Jan 14, 2022
cad2595
Merge branch 'feat/crypto-payment-1782' of github.com:ChainSafe/ui-mo…
Tbaut Jan 14, 2022
13347fe
Merge branch 'dev' into feat/crypto-payment-1782
Tbaut Jan 14, 2022
24683f4
be able to get back to crypt
Tbaut Jan 14, 2022
9eb2a16
lingui extract
actions-user Jan 14, 2022
74ddf46
fix mobile width issues
FSM1 Jan 14, 2022
348447e
Revert "fix mobile width issues"
FSM1 Jan 17, 2022
46dfe09
ensure that text doesnt overflow
FSM1 Jan 17, 2022
6599357
fix width
FSM1 Jan 17, 2022
1fd561d
Merge branch 'dev' into feat/crypto-payment-1782
Tbaut Jan 17, 2022
0a8246b
lingui extract
actions-user Jan 17, 2022
1ee200b
Merge branch 'feat/crypto-payment-1782' of github.com:ChainSafe/ui-mo…
Tbaut Jan 18, 2022
2b26abe
fix copy and goback
Tbaut Jan 18, 2022
bf39f72
Merge branch 'mnt/tbaut-crypto-1846' of github.com:ChainSafe/ui-monor…
Tbaut Jan 18, 2022
4e45fe7
mobile view
Tbaut Jan 18, 2022
4b01384
cleanup
Tbaut Jan 18, 2022
2a4006c
add notifications for account restricted, unpaid
FSM1 Jan 18, 2022
362a3bd
fix conflicts
Tbaut Jan 18, 2022
c018cb7
update notification text
FSM1 Jan 18, 2022
8a5fc1f
Merge remote-tracking branch 'origin/dev' into feat/billing-notificat…
FSM1 Jan 18, 2022
5ce381f
update translations
FSM1 Jan 18, 2022
4e28de8
pull the new api-client version and remove type casting
Tbaut Jan 18, 2022
8af3afb
fix lint
Tbaut Jan 18, 2022
27001ed
text button in payment details
tanmoyAtb Jan 18, 2022
e5edaa8
add credit card expiring notification
FSM1 Jan 19, 2022
9b6e42f
fix lint
FSM1 Jan 19, 2022
276af26
Merge branch 'dev' into mnt/tbaut-crypto-1846
tanmoyAtb Jan 19, 2022
9f28b08
Merge branch 'dev' into feat/billing-notifications-1819
tanmoyAtb Jan 19, 2022
a9c78d9
Merge branch 'dev' of github.com:ChainSafe/ui-monorepo into mnt/tbaut…
Tbaut Jan 20, 2022
e745845
address small comments
Tbaut Jan 20, 2022
1541ea7
additional button with awaiting payment
Tbaut Jan 20, 2022
60f7ccf
Merge branch 'dev' into mnt/tbaut-crypto-1846
FSM1 Jan 21, 2022
97e0301
lingui extract
actions-user Jan 21, 2022
3db0bd7
Merge branch 'feat/pay-invoice-1829' of https://github.com/ChainSafe/…
FSM1 Jan 21, 2022
4a3196b
refactor and allow payment of invoice
FSM1 Jan 21, 2022
3beb06d
remove unused var
FSM1 Jan 24, 2022
4b18661
Merge remote-tracking branch 'origin/dev' into feat/pay-invoice-1829
FSM1 Jan 24, 2022
66d757e
lingui extract
actions-user Jan 24, 2022
eae221a
wire up pay invoice
FSM1 Jan 24, 2022
51e0b39
lingui extract
actions-user Jan 24, 2022
deb8a84
remove unused dependency
FSM1 Jan 24, 2022
ebedaa4
Merge branch 'feat/pay-invoice-1829' of https://github.com/ChainSafe/…
FSM1 Jan 24, 2022
eb2acfd
Merge branch 'dev' into feat/pay-invoice-1829
FSM1 Jan 24, 2022
9e96f73
Merge branch 'dev' into feat/pay-invoice-1829
tanmoyAtb Jan 25, 2022
24e9868
remove old code
FSM1 Jan 25, 2022
15a6312
Merge branch 'feat/pay-invoice-1829' of https://github.com/ChainSafe/…
FSM1 Jan 25, 2022
ac141d1
lingui extract
actions-user Jan 25, 2022
f5697fa
Apply suggestions from code review
FSM1 Jan 26, 2022
d5e8a1a
remove unused class
FSM1 Jan 26, 2022
c02b3d6
revert to yearly closes #1873
FSM1 Jan 26, 2022
fb20110
Apply suggestions from code review
FSM1 Jan 26, 2022
05494ea
lingui extract
actions-user Jan 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/files-ui/src/Components/Elements/InvoiceLines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ const useStyles = makeStyles(

interface IInvoiceProps {
lineNumber?: number
payInvoice?: () => void
}

const InvoiceLines = ({ lineNumber }: IInvoiceProps) => {
const InvoiceLines = ({ lineNumber, payInvoice }: IInvoiceProps) => {
const classes = useStyles()
const { invoices, downloadInvoice } = useBilling()
const invoicesToShow = useMemo(() => {
Expand Down Expand Up @@ -116,7 +117,7 @@ const InvoiceLines = ({ lineNumber }: IInvoiceProps) => {
</Button>
)}
{(status === "open") && (
<Button onClick={() => console.log("Not implemented")}>
<Button onClick={payInvoice}>
<Trans>Pay invoice</Trans>
</Button>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStyles, makeStyles } from "@chainsafe/common-theme"
import { CSFTheme } from "../../../../../Themes/types"
import CustomModal from "../../../../Elements/CustomModal"
import { t, Trans } from "@lingui/macro"
import AddCard from "./AddCard"
import AddCard from "../Common/AddCard"
import { Typography } from "@chainsafe/common-components"
import { useBilling } from "../../../../../Contexts/BillingContext"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from "react"
import React, { useState } from "react"
import { Typography, Link } from "@chainsafe/common-components"
import { makeStyles, ITheme, createStyles } from "@chainsafe/common-theme"
import { Trans } from "@lingui/macro"
import { ROUTE_LINKS } from "../../../FilesRoutes"
import InvoiceLines from "../../../Elements/InvoiceLines"
import PayInvoiceModal from "./PayInvoice/PayInvoiceModal"
import { useBilling } from "../../../../Contexts/BillingContext"

const useStyles = makeStyles(({ constants }: ITheme) =>
createStyles({
Expand All @@ -20,6 +22,8 @@ const useStyles = makeStyles(({ constants }: ITheme) =>

const BillingHistory = () => {
const classes = useStyles()
const [isPayInvoiceModalVisible, setPayInvoiceModalVisible] = useState(false)
const { isPendingInvoice } = useBilling()

return (
<div className={classes.container}>
Expand All @@ -29,6 +33,9 @@ const BillingHistory = () => {
>
<Trans>Billing history</Trans>
</Typography>
{isPendingInvoice && <Typography>
<Trans>Please complete payment of the following outstanding invoices in order to avoid account suspension</Trans>
</Typography>}
<Typography
variant="body1"
component="p"
Expand All @@ -38,7 +45,15 @@ const BillingHistory = () => {
<Trans>All invoices</Trans>
</Link>
</Typography>
<InvoiceLines lineNumber={3}/>
<InvoiceLines
lineNumber={3}
payInvoice={() => setPayInvoiceModalVisible(true)}
/>
{
isPayInvoiceModalVisible && <PayInvoiceModal
onClose={() => setPayInvoiceModalVisible(false)}
/>
}
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { Modal } from "@chainsafe/common-components"
import SelectPlan from "./SelectPlan"
import PlanDetails from "./PlanDetails"
import PaymentMethodSelector from "./PaymentMethodSelector"
import ConfirmPlan from "./ConfirmPlan"
import ConfirmPlan from "../Common/ConfirmPlan"
import { useBilling } from "../../../../../Contexts/BillingContext"
import { Product, ProductPrice, ProductPriceRecurringInterval } from "@chainsafe/files-api-client"
import PlanSuccess from "./PlanSuccess"
import DowngradeDetails from "./DowngradeDetails"
import { PaymentMethod } from "../../../../../Contexts/BillingContext"
import CryptoPayment from "./CryptoPayment"
import CryptoPayment from "../Common/CryptoPayment"
const useStyles = makeStyles(({ constants, breakpoints }: CSFTheme) =>
createStyles({
root: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { makeStyles, createStyles } from "@chainsafe/common-theme"
import { CSFTheme } from "../../../../../Themes/types"
import { Button, Divider, RadioInput, Typography } from "@chainsafe/common-components"
import { t, Trans } from "@lingui/macro"
import AddCard from "../AddCard/AddCard"
import AddCard from "../Common/AddCard"
import { PaymentMethod, useBilling } from "../../../../../Contexts/BillingContext"
import { ProductPrice } from "@chainsafe/files-api-client"

Expand Down Expand Up @@ -141,8 +141,7 @@ const PaymentMethodSelector = ({ selectedProductPrice, goBack, onSelectPaymentMe
onChange={() => setPaymentMethod("crypto")}
checked={paymentMethod === "crypto"}
labelClassName={classes.radioLabel}
// TODO Revert once testing is finished
disabled={selectedProductPrice.recurring.interval !== "day"}
disabled={selectedProductPrice.recurring.interval !== "year"}
/>
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ interface IPlanDetails {
const PlanDetails = ({ plan, goToSelectPlan, onSelectPlanPrice }: IPlanDetails) => {
const classes = useStyles()
const monthlyPrice = plan.prices.find((price) => price.recurring.interval === "month")
// TODO Revert this to year when testing is complete
const yearlyPrice = plan.prices.find((price) => price.recurring.interval === "day")
const yearlyPrice = plan.prices.find((price) => price.recurring.interval === "year")
const currentPlanStorage = formatBytes(Number(monthlyPrice?.metadata?.storage_size_bytes), 2)

const [billingPeriod, setBillingPeriod] = useState<"monthly" | "yearly">(monthlyPrice ? "monthly" : "yearly")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ interface ISelectPlan {

const SelectPlan = ({ className, onSelectPlan, plans }: ISelectPlan) => {
const classes = useStyles()
const { currentSubscription } = useBilling()
const { currentSubscription, isPendingInvoice } = useBilling()
const { desktop } = useThemeSwitcher()
const [tempSelectedPlan, setTempSelectedPlan] = useState<Product | undefined>()

Expand Down Expand Up @@ -259,7 +259,7 @@ const SelectPlan = ({ className, onSelectPlan, plans }: ISelectPlan) => {
: (
<div
className={clsx(classes.planBox, tempSelectedPlan?.id === plan.id && !isCurrentPlan && "active")}
onClick={() => isUpdateAllowed && !isCurrentPlan && setTempSelectedPlan(plan)}
onClick={() => !isPendingInvoice && isUpdateAllowed && !isCurrentPlan && setTempSelectedPlan(plan)}
key={`plan-${plan.id}`}
>
<div className={classes.priceAndDescription}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ const CryptoPayment = ({ planPrice }: ICryptoPayment) => {
const debouncedSwitchCopiedDestinationAddress = debounce(() => setCopiedDestinationAddress(false), 3000)
const debouncedSwitchCopiedAmount = debounce(() => setCopiedAmount(false), 3000)
const pendingCryptoInvoice = useMemo(() =>
isPendingInvoice && invoices?.find((i) => i.payment_method === "crypto" && i.status === "open")
, [invoices, isPendingInvoice])
invoices?.find((i) => i.payment_method === "crypto" && i.status === "open")
, [invoices])
const currencies = useMemo(() => cryptoPayment?.payment_methods.map(c => c.currency), [cryptoPayment])
const [selectedCurrency, setSelectedCurrency] = useState<string | undefined>(undefined)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useFiles } from "../../../../Contexts/FilesContext"
import { t, Trans } from "@lingui/macro"
import clsx from "clsx"
import { useBilling } from "../../../../Contexts/BillingContext"
import ChangeProductModal from "./ChangePlan/ChangePlanModal"
import ChangePlanModal from "./ChangePlan/ChangePlanModal"

const useStyles = makeStyles(({ breakpoints, constants }: ITheme) =>
createStyles({
Expand Down Expand Up @@ -58,7 +58,7 @@ interface ICurrentProduct {
className?: string
}

const CurrentProduct = ({ className }: ICurrentProduct) => {
const CurrentPlan = ({ className }: ICurrentProduct) => {
const classes = useStyles()
const { storageSummary } = useFiles()
const { currentSubscription, isPendingInvoice } = useBilling()
Expand Down Expand Up @@ -115,7 +115,7 @@ const CurrentProduct = ({ className }: ICurrentProduct) => {
</Button>
</div>
{
isChangeProductModalVisible && (<ChangeProductModal
isChangeProductModalVisible && (<ChangePlanModal
onClose={() => setChangeProductModalVisible(false)}
/>)
}
Expand All @@ -125,4 +125,4 @@ const CurrentProduct = ({ className }: ICurrentProduct) => {
</section>)
}

export default CurrentProduct
export default CurrentPlan
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from "react"
import { makeStyles, createStyles, useThemeSwitcher } from "@chainsafe/common-theme"
import { CSFTheme } from "../../../../../Themes/types"
import { Modal } from "@chainsafe/common-components"
import CryptoPayment from "../Common/CryptoPayment"

const useStyles = makeStyles(({ constants, breakpoints }: CSFTheme) =>
createStyles({
root: {
"&:before": {
backgroundColor: constants.modalDefault.fadeBackground
}
},
inner: {
borderRadius: `${constants.generalUnit / 2}px`,
[breakpoints.up("sm")]: {
minWidth: 480
},
[breakpoints.down("sm")]: {
width: "100%"
}
}
})
)

interface IChangeProductModal {
onClose: () => void
}

const PayInvoiceModal = ({ onClose }: IChangeProductModal) => {
const classes = useStyles()
const { desktop } = useThemeSwitcher()

return (
<Modal
closePosition="right"
active={true}
maxWidth={desktop ? 800 : undefined}
width={desktop ? "max-content" : "100%"}
className={classes.root}
injectedClass={{
inner: classes.inner
}}
testId="pay-invoice"
onClose={onClose}
>
<CryptoPayment />
</Modal>
)
}

export default PayInvoiceModal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Trans } from "@lingui/macro"
import BillingHistory from "./BillingHistory"
import { Elements } from "@stripe/react-stripe-js"
import { loadStripe } from "@stripe/stripe-js"
import CurrentProduct from "./CurrentPlan"
import CurrentPlan from "./CurrentPlan"
import { useBilling } from "../../../../Contexts/BillingContext"

const useStyles = makeStyles(({ breakpoints, constants }: ITheme) =>
Expand Down Expand Up @@ -43,7 +43,7 @@ const PlanView: React.FC = () => {
<Trans>Payment and Subscriptions</Trans>
</Typography>
<Divider />
<CurrentProduct />
<CurrentPlan />
<CurrentCard />
<BillingHistory />
</div>
Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ msgstr ""
msgid "Plan changed successfully"
msgstr ""

msgid "Please complete payment of the following outstanding invoices in order to avoid account suspension"
msgstr ""

msgid "Please enter a file name"
msgstr "Bitte geben Sie einen Dateinamen ein"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/en/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,9 @@ msgstr "Payment method"
msgid "Plan changed successfully"
msgstr "Plan changed successfully"

msgid "Please complete payment of the following outstanding invoices in order to avoid account suspension"
msgstr "Please complete payment of the following outstanding invoices in order to avoid account suspension"

msgid "Please enter a file name"
msgstr "Please enter a file name"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/es/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ msgstr ""
msgid "Plan changed successfully"
msgstr ""

msgid "Please complete payment of the following outstanding invoices in order to avoid account suspension"
msgstr ""

msgid "Please enter a file name"
msgstr "Ingrese un nombre de archivo"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,9 @@ msgstr "Méthode de paiement"
msgid "Plan changed successfully"
msgstr "Formule changée"

msgid "Please complete payment of the following outstanding invoices in order to avoid account suspension"
msgstr ""

msgid "Please enter a file name"
msgstr "Veuillez entrer un nom de fichier"

Expand Down
3 changes: 3 additions & 0 deletions packages/files-ui/src/locales/no/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ msgstr ""
msgid "Plan changed successfully"
msgstr ""

msgid "Please complete payment of the following outstanding invoices in order to avoid account suspension"
msgstr ""

msgid "Please enter a file name"
msgstr "Skriv inn et filnavn"

Expand Down