Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
suejung-sentry committed Jan 13, 2025
1 parent 747f183 commit 8912835
Show file tree
Hide file tree
Showing 28 changed files with 519 additions and 465 deletions.
10 changes: 10 additions & 0 deletions src/assets/billing/bank.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/pages/PlanPage/PlanPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import config from 'config'

import { SentryRoute } from 'sentry'

import { Theme, useThemeContext } from 'shared/ThemeContext'
import LoadingLogo from 'ui/LoadingLogo'

import { PlanProvider } from './context'
import PlanBreadcrumb from './PlanBreadcrumb'
import { PlanPageDataQueryOpts } from './queries/PlanPageDataQueryOpts'
import Tabs from './Tabs'

import { StripeAppearance } from '../../stripe'

const CancelPlanPage = lazy(() => import('./subRoutes/CancelPlanPage'))
const CurrentOrgPlan = lazy(() => import('./subRoutes/CurrentOrgPlan'))
const InvoicesPage = lazy(() => import('./subRoutes/InvoicesPage'))
Expand All @@ -37,6 +40,8 @@ function PlanPage() {
const { data: ownerData } = useSuspenseQueryV5(
PlanPageDataQueryOpts({ owner, provider })
)
const { theme } = useThemeContext()
const isDarkMode = theme !== Theme.LIGHT

if (config.IS_SELF_HOSTED || !ownerData?.isCurrentUserPartOfOrg) {
return <Redirect to={`/${provider}/${owner}`} />
Expand All @@ -45,7 +50,7 @@ function PlanPage() {
return (
<div className="flex flex-col gap-4">
<Tabs />
<Elements stripe={stripePromise}>
<Elements stripe={stripePromise} options={StripeAppearance(isDarkMode)}>
<PlanProvider>
<PlanBreadcrumb />
<Suspense fallback={<Loader />}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useState } from 'react'
import { useParams } from 'react-router-dom'

import { useAccountDetails } from 'services/account'
import A from 'ui/A'
import Button from 'ui/Button'

import EditPaymentMethods from './EditPaymentMethods'
import EmailAddress from './EmailAddress'
import PaymentMethod from './PaymentMethod'
import Button from 'ui/Button'
import { useState } from 'react'
import A from 'ui/A'
import EditablePaymentMethod from './EditPaymentMethod'
import { ViewPaymentMethod } from './ViewPaymentMethod'

interface URLParams {
provider: string
Expand All @@ -22,15 +22,12 @@ function BillingDetails() {
})
const subscriptionDetail = accountDetails?.subscriptionDetail
const [isEditMode, setEditMode] = useState(false)

const isAdmin = true // TODO
const secondaryPaymentFeatureEnabled = false

if (!subscriptionDetail) {
return null
}

console.log('iseditmode', isEditMode)

return (
<div className="flex flex-col divide-y border">
{/* Billing Details Section */}
Expand All @@ -50,7 +47,6 @@ function BillingDetails() {
hook="button"
onClick={() => setEditMode(true)}
variant="default"
disabled={!isAdmin}
className="flex-none"
>
Edit payment
Expand All @@ -60,36 +56,42 @@ function BillingDetails() {
hook="button"
onClick={() => setEditMode(false)}
variant="default"
disabled={!isAdmin}
className="flex-none"
>
Back
</Button>
)}
</div>
{isEditMode ? (
<EditablePaymentMethod />
<EditPaymentMethods
setEditMode={setEditMode}
provider={provider}
owner={owner}
existingSubscriptionDetail={subscriptionDetail}
/>
) : (
<>
<EmailAddress />
<PaymentMethod
<ViewPaymentMethod
heading="Primary Payment Method"
isPrimary={true}
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
owner={owner}
/>
<PaymentMethod
heading="Secondary Payment Method"
isPrimary={false}
isPrimaryPaymentMethod={true}
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
owner={owner}
/>
{secondaryPaymentFeatureEnabled && (
<ViewPaymentMethod
heading="Secondary Payment Method"
isPrimaryPaymentMethod={false}
isEditMode={isEditMode}
setEditMode={setEditMode}
subscriptionDetail={subscriptionDetail}
provider={provider}
owner={owner}
/>
)}
{subscriptionDetail?.taxIds?.length ? (
<div className="flex flex-col gap-2 p-4">
<h4 className="font-semibold">Tax ID</h4>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { z } from 'zod'

import { AddressSchema } from 'services/account'
import { useUpdateBillingAddress } from 'services/account/useUpdateBillingAddress'
import { Theme, useThemeContext } from 'shared/ThemeContext'
import Button from 'ui/Button'

interface AddressFormProps {
Expand All @@ -23,28 +22,6 @@ function AddressForm({
owner,
}: AddressFormProps) {
const elements = useElements()
const { theme } = useThemeContext()
const isDarkMode = theme === Theme.DARK

// Note: unfortunately seems Stripe doesn't let us reference like `var(--<var name>)` so rgbs are hardcoded in below
elements?.update({
appearance: {
variables: {
fontFamily: 'Poppins, ui-sans-serif, system-ui, sans-serif',
},
rules: {
'.Label': {
fontWeight: '600',
color: isDarkMode ? 'rgb(210,212,215)' : 'rgb(14,27,41)', // Same values as --color-app-text-primary.
},
'.Input': {
backgroundColor: isDarkMode ? 'rgb(22,24,29)' : 'rgb(255,255,255)', // Same values as --color-app-container.
borderColor: isDarkMode ? 'rgb(47,51,60)' : 'rgb(216,220,226)', // Same values as --color-ds-gray-tertiary.
color: isDarkMode ? 'rgb(210,212,215)' : 'rgb(14,27,41)', // Same values as --color-app-text-primary.
},
},
},
})

const {
mutate: updateAddress,
Expand Down
Loading

0 comments on commit 8912835

Please sign in to comment.