mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-22 10:36:57 +00:00
Merge pull request #22030 from overleaf/em-subscription-change-pay-now-button
Implement the Pay Now button for upgrades to premium from the AI add-on GitOrigin-RevId: 06e00662b877308c64ce5feaa5ce8f80f8f1b552
This commit is contained in:
parent
b0c309e993
commit
558b529caf
1 changed files with 7 additions and 1 deletions
|
@ -10,6 +10,7 @@ import { useLocation } from '@/shared/hooks/use-location'
|
|||
import { debugConsole } from '@/utils/debugging'
|
||||
import { postJSON } from '@/infrastructure/fetch-json'
|
||||
import Notification from '@/shared/components/notification'
|
||||
import { subscriptionUpdateUrl } from '@/features/subscription/data/subscription-url'
|
||||
|
||||
function PreviewSubscriptionChange() {
|
||||
const preview = getMeta('ol-subscriptionChangePreview')
|
||||
|
@ -166,10 +167,15 @@ function PreviewSubscriptionChange() {
|
|||
async function payNow(preview: SubscriptionChangePreview) {
|
||||
if (preview.change.type === 'add-on-purchase') {
|
||||
await postJSON(`/user/subscription/addon/${preview.change.addOn.code}/add`)
|
||||
} else if (preview.change.type === 'premium-subscription') {
|
||||
await postJSON(subscriptionUpdateUrl, {
|
||||
body: { plan_code: preview.change.plan.code },
|
||||
})
|
||||
} else {
|
||||
throw new Error(
|
||||
`Unknown subscription change preview type: ${preview.change.type}`
|
||||
`Unknown subscription change preview type: ${preview.change}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default PreviewSubscriptionChange
|
||||
|
|
Loading…
Add table
Reference in a new issue