Skip to content

Commit

Permalink
🌐 Translate billing in PT & FR
Browse files Browse the repository at this point in the history
Related to #210
  • Loading branch information
baptisteArno committed Mar 31, 2023
1 parent 53eecd4 commit 0620d48
Show file tree
Hide file tree
Showing 27 changed files with 374 additions and 153 deletions.
19 changes: 11 additions & 8 deletions apps/builder/src/components/UnlockPlanAlertInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import {
} from '@chakra-ui/react'
import React from 'react'
import { ChangePlanModal } from '@/features/billing/components/ChangePlanModal'
import { LimitReached } from '@/features/billing/types'
import { useI18n } from '@/locales'

type Props = {
contentLabel: React.ReactNode
buttonLabel?: string
type?: string
} & AlertProps

export const UnlockPlanAlertInfo = ({
contentLabel,
buttonLabel = 'More info',
buttonLabel,
type,
...props
}: {
contentLabel: React.ReactNode
buttonLabel?: string
type?: LimitReached
} & AlertProps) => {
}: Props) => {
const t = useI18n()
const { isOpen, onOpen, onClose } = useDisclosure()
return (
<Alert
Expand All @@ -40,7 +43,7 @@ export const UnlockPlanAlertInfo = ({
flexShrink={0}
ml="2"
>
{buttonLabel}
{buttonLabel ?? t('billing.upgradeAlert.buttonDefaultLabel')}
</Button>
<ChangePlanModal isOpen={isOpen} onClose={onClose} type={type} />
</Alert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const CreateTokenModal = ({
<ModalFooter>
{newTokenValue ? (
<Button onClick={onClose} colorScheme="blue">
{scopedT('doneButtonLabel')}
{scopedT('doneButton.label')}
</Button>
) : (
<Button
Expand All @@ -90,7 +90,7 @@ export const CreateTokenModal = ({
isLoading={isSubmitting}
onClick={createToken}
>
{scopedT('createButtonLabel')}
{scopedT('createButton.label')}
</Button>
)}
</ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import React from 'react'
import { useAnswersCount } from '../hooks/useAnswersCount'
import { StatsCards } from './StatsCards'
import { ChangePlanModal } from '@/features/billing/components/ChangePlanModal'
import { LimitReached } from '@/features/billing/types'
import { Graph } from '@/features/graph/components/Graph'
import { GraphProvider } from '@/features/graph/providers/GraphProvider'
import { GroupsCoordinatesProvider } from '@/features/graph/providers/GroupsCoordinateProvider'
import { useI18n } from '@/locales'

export const AnalyticsGraphContainer = ({ stats }: { stats?: Stats }) => {
const t = useI18n()
const { isOpen, onOpen, onClose } = useDisclosure()
const { typebot, publishedTypebot } = useTypebot()
const { showToast } = useToast()
Expand Down Expand Up @@ -69,7 +70,7 @@ export const AnalyticsGraphContainer = ({ stats }: { stats?: Stats }) => {
<ChangePlanModal
onClose={onClose}
isOpen={isOpen}
type={LimitReached.ANALYTICS}
type={t('billing.limitMessage.analytics')}
/>
<StatsCards stats={stats} pos="absolute" top={10} />
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/auth/components/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const SignInForm = ({
}
isDisabled={isMagicLinkSent}
>
{scopedT('emailSubmitButtonLabel')}
{scopedT('emailSubmitButton.label')}
</Button>
</HStack>
</>
Expand Down
12 changes: 6 additions & 6 deletions apps/builder/src/features/auth/components/SocialLoginButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('githubButtonLabel')}
{scopedT('githubButton.label')}
</Button>
)}
{providers?.google && (
Expand All @@ -79,7 +79,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('googleButtonLabel')}
{scopedT('googleButton.label')}
</Button>
)}
{providers?.facebook && (
Expand All @@ -93,7 +93,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('facebookButtonLabel')}
{scopedT('facebookButton.label')}
</Button>
)}
{providers?.gitlab && (
Expand All @@ -107,7 +107,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('gitlabButtonLabel', {
{scopedT('gitlabButton.label', {
gitlabProviderName: providers.gitlab.name,
})}
</Button>
Expand All @@ -123,7 +123,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('azureButtonLabel', {
{scopedT('azureButton.label', {
azureProviderName: providers['azure-ad'].name,
})}
</Button>
Expand All @@ -137,7 +137,7 @@ export const SocialLoginButtons = ({ providers }: Props) => {
}
variant="outline"
>
{scopedT('customButtonLabel', {
{scopedT('customButton.label', {
customProviderName: providers['custom-oauth'].name,
})}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion apps/builder/src/features/billing/billing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ test('plan changes should work', async ({ page }) => {
// Go to customer portal
await Promise.all([
page.waitForNavigation(),
page.click('text="Billing Portal"'),
page.click('text="Billing portal"'),
])
await expect(page.locator('text="Add payment method"')).toBeVisible()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useToast } from '@/hooks/useToast'
import { trpc } from '@/lib/trpc'
import { useScopedI18n } from '@/locales'
import { Button, Link } from '@chakra-ui/react'

type Props = {
workspaceId: string
}

export const BillingPortalButton = ({ workspaceId }: Props) => {
const scopedT = useScopedI18n('billing')
const { showToast } = useToast()
const { data } = trpc.billing.getBillingPortalUrl.useQuery(
{
Expand All @@ -22,7 +24,7 @@ export const BillingPortalButton = ({ workspaceId }: Props) => {
)
return (
<Button as={Link} href={data?.billingPortalUrl} isLoading={!data}>
Billing Portal
{scopedT('billingPortalButton.label')}
</Button>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ import { TextLink } from '@/components/TextLink'
import { ChangePlanForm } from './ChangePlanForm'
import { UsageProgressBars } from './UsageProgressBars'
import { CurrentSubscriptionSummary } from './CurrentSubscriptionSummary'
import { useScopedI18n } from '@/locales'

export const BillingSettingsLayout = () => {
const scopedT = useScopedI18n('billing')
const { workspace, refreshWorkspace } = useWorkspace()

if (!workspace) return null
Expand All @@ -24,10 +26,9 @@ export const BillingSettingsLayout = () => {
<HStack maxW="500px">
<StripeClimateLogo />
<Text fontSize="xs" color="gray.500">
Typebot is contributing 1% of your subscription to remove CO₂ from
the atmosphere.{' '}
{scopedT('contribution.preLink')}{' '}
<TextLink href="https://climate.stripe.com/5VCRAq" isExternal>
More info.
{scopedT('contribution.link')}
</TextLink>
</Text>
</HStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import { ParentModalProvider } from '@/features/graph/providers/ParentModalProvi
import { useUser } from '@/features/account/hooks/useUser'
import { StarterPlanPricingCard } from './StarterPlanPricingCard'
import { ProPlanPricingCard } from './ProPlanPricingCard'
import { useScopedI18n } from '@/locales'

type Props = {
workspace: Pick<Workspace, 'id' | 'stripeId' | 'plan'>
onUpgradeSuccess: () => void
}

export const ChangePlanForm = ({ workspace, onUpgradeSuccess }: Props) => {
const scopedT = useScopedI18n('billing')
const { user } = useUser()
const { showToast } = useToast()
const [preCheckoutPlan, setPreCheckoutPlan] =
Expand All @@ -38,7 +40,7 @@ export const ChangePlanForm = ({ workspace, onUpgradeSuccess }: Props) => {
onUpgradeSuccess()
showToast({
status: 'success',
description: `Workspace ${plan} plan successfully updated 🎉`,
description: scopedT('updateSuccessToast.description', { plan }),
})
},
})
Expand Down Expand Up @@ -123,9 +125,9 @@ export const ChangePlanForm = ({ workspace, onUpgradeSuccess }: Props) => {
/>
</HStack>
<Text color="gray.500">
Need custom limits? Specific features?{' '}
{scopedT('customLimit.preLink')}{' '}
<TextLink href={'https://typebot.io/enterprise-lead-form'} isExternal>
Let&apos;s chat!
{scopedT('customLimit.link')}
</TextLink>
</Text>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AlertInfo } from '@/components/AlertInfo'
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
import { useI18n, useScopedI18n } from '@/locales'
import {
Modal,
ModalBody,
Expand All @@ -10,11 +11,10 @@ import {
Button,
HStack,
} from '@chakra-ui/react'
import { LimitReached } from '../types'
import { ChangePlanForm } from './ChangePlanForm'

type ChangePlanModalProps = {
type?: LimitReached
type?: string
isOpen: boolean
onClose: () => void
}
Expand All @@ -24,6 +24,7 @@ export const ChangePlanModal = ({
isOpen,
type,
}: ChangePlanModalProps) => {
const t = useI18n()
const { workspace, refreshWorkspace } = useWorkspace()
return (
<Modal isOpen={isOpen} onClose={onClose} size="2xl">
Expand All @@ -32,7 +33,7 @@ export const ChangePlanModal = ({
<ModalBody as={Stack} spacing="6" pt="10">
{type && (
<AlertInfo>
You need to upgrade your plan in order to {type}
{t('billing.upgradeLimitLabel', { type: type })}
</AlertInfo>
)}
{workspace && (
Expand All @@ -46,7 +47,7 @@ export const ChangePlanModal = ({
<ModalFooter>
<HStack>
<Button colorScheme="gray" onClick={onClose}>
Cancel
{t('cancel')}
</Button>
</HStack>
</ModalFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PlanTag } from './PlanTag'
import { BillingPortalButton } from './BillingPortalButton'
import { trpc } from '@/lib/trpc'
import { Workspace } from '@typebot.io/schemas'
import { useScopedI18n } from '@/locales'

type Props = {
workspace: Pick<Workspace, 'id' | 'plan' | 'stripeId'>
Expand All @@ -16,6 +17,7 @@ export const CurrentSubscriptionSummary = ({
workspace,
onCancelSuccess,
}: Props) => {
const scopedT = useScopedI18n('billing.currentSubscription')
const { showToast } = useToast()

const { mutate: cancelSubscription, isLoading: isCancelling } =
Expand All @@ -34,9 +36,9 @@ export const CurrentSubscriptionSummary = ({

return (
<Stack spacing="4">
<Heading fontSize="3xl">Subscription</Heading>
<Heading fontSize="3xl">{scopedT('heading')}</Heading>
<HStack data-testid="current-subscription">
<Text>Current workspace subscription: </Text>
<Text>{scopedT('subheading')} </Text>
{isCancelling ? (
<Spinner color="gray.500" size="xs" />
) : (
Expand All @@ -52,7 +54,7 @@ export const CurrentSubscriptionSummary = ({
cancelSubscription({ workspaceId: workspace.id })
}
>
Cancel my subscription
{scopedT('cancelLink')}
</Link>
)}
</>
Expand All @@ -62,10 +64,7 @@ export const CurrentSubscriptionSummary = ({
{isSubscribed && !isCancelling && (
<>
<Stack spacing="4">
<Text fontSize="sm">
Need to change payment method or billing information? Head over to
your billing portal:
</Text>
<Text fontSize="sm">{scopedT('billingPortalDescription')}</Text>
<BillingPortalButton workspaceId={workspace.id} />
</Stack>
</>
Expand Down
10 changes: 6 additions & 4 deletions apps/builder/src/features/billing/components/InvoicesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import Link from 'next/link'
import React from 'react'
import { trpc } from '@/lib/trpc'
import { useToast } from '@/hooks/useToast'
import { useScopedI18n } from '@/locales'

type Props = {
workspaceId: string
}

export const InvoicesList = ({ workspaceId }: Props) => {
const scopedT = useScopedI18n('billing.invoices')
const { showToast } = useToast()
const { data, status } = trpc.billing.listInvoices.useQuery(
{
Expand All @@ -38,18 +40,18 @@ export const InvoicesList = ({ workspaceId }: Props) => {

return (
<Stack spacing={6}>
<Heading fontSize="3xl">Invoices</Heading>
<Heading fontSize="3xl">{scopedT('heading')}</Heading>
{data?.invoices.length === 0 && status !== 'loading' ? (
<Text>No invoices found for this workspace.</Text>
<Text>{scopedT('empty')}</Text>
) : (
<TableContainer>
<Table>
<Thead>
<Tr>
<Th w="0" />
<Th>#</Th>
<Th>Paid at</Th>
<Th>Subtotal</Th>
<Th>{scopedT('paidAt')}</Th>
<Th>{scopedT('subtotal')}</Th>
<Th w="0" />
</Tr>
</Thead>
Expand Down
1 change: 1 addition & 0 deletions apps/builder/src/features/billing/components/PlanTag.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useI18n, useScopedI18n } from '@/locales'
import { Tag, TagProps, ThemeTypings } from '@chakra-ui/react'
import { Plan } from '@typebot.io/prisma'

Expand Down
Loading

0 comments on commit 0620d48

Please sign in to comment.