change user membership without payment
This commit is contained in:
@@ -18,8 +18,24 @@ const PricingCard: React.FC<PricingCardProps> = ({
|
||||
const handlePlanChange = async () => {
|
||||
try {
|
||||
setIsLoading(true)
|
||||
console.log('Changing plan to:', plan)
|
||||
// const response = await changePlan(plan) -- тут обработка данных запроса на смену плана
|
||||
|
||||
const requestData = {
|
||||
plan: plan,
|
||||
}
|
||||
|
||||
const response = await fetch('/api/account/membership', {
|
||||
method: 'PATCH',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(requestData),
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json()
|
||||
console.error('PricingCard - Server error:', error)
|
||||
throw new Error(error.error || 'Ошибка при создании маршрута')
|
||||
}
|
||||
|
||||
// обновляем данные в сторе
|
||||
if (user) {
|
||||
|
||||
@@ -15,7 +15,7 @@ const AdminPayments = () => {
|
||||
useEffect(() => {
|
||||
const fetchPlans = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/account/get-plans')
|
||||
const response = await fetch('/api/account/membership')
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch plans')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user