subscription dialog

This commit is contained in:
Samuel Newman
2024-11-18 19:07:07 +00:00
committed by Eric Bailey
parent 9be5761885
commit 0f15abc246
6 changed files with 331 additions and 93 deletions
@@ -1,23 +1,21 @@
import {useMutation} from '@tanstack/react-query'
import {IS_DEV} from '#/env'
import {api} from '#/state/purchases/subscriptions/api'
import {IS_DEV} from '#/env'
export function useCreateCheckout() {
return useMutation({
async mutationFn(props: {
price: string,
did: string,
email: string,
}) {
async mutationFn(props: {price: string; did: string; email: string}) {
const {data, error} = await api<{
checkoutUrl: string
}>('/checkout/create', {
method: 'POST',
json: {
...props,
redirectUrl: IS_DEV ? `http://localhost:19006/subscriptions` : `https://bsky.app/subscriptions`,
}
redirectUrl: IS_DEV
? `http://localhost:19006/subscriptions`
: `https://bsky.app/subscriptions`,
},
}).json()
if (error) {