mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 17:43:47 +00:00
Refactor ConnectionModal and TopUpModal: reintroduce app selector logic in ConnectionModal, implement body scroll locking in TopUpModal, and adjust modal styling for improved responsiveness and user experience.
This commit is contained in:
@@ -267,6 +267,19 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) {
|
|||||||
return available
|
return available
|
||||||
}, [appConfig, detectedPlatform])
|
}, [appConfig, detectedPlatform])
|
||||||
|
|
||||||
|
// Get all apps for selector (must be before any conditional returns)
|
||||||
|
const allAppsForSelector = useMemo(() => {
|
||||||
|
if (!appConfig?.platforms) return []
|
||||||
|
const result: { platform: string; apps: AppInfo[] }[] = []
|
||||||
|
for (const platform of availablePlatforms) {
|
||||||
|
const apps = appConfig.platforms[platform]
|
||||||
|
if (apps?.length) {
|
||||||
|
result.push({ platform, apps })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}, [appConfig, availablePlatforms])
|
||||||
|
|
||||||
const copySubscriptionLink = async () => {
|
const copySubscriptionLink = async () => {
|
||||||
if (!appConfig?.subscriptionUrl) return
|
if (!appConfig?.subscriptionUrl) return
|
||||||
try {
|
try {
|
||||||
@@ -371,19 +384,6 @@ export default function ConnectionModal({ onClose }: ConnectionModalProps) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all apps for selector
|
|
||||||
const allAppsForSelector = useMemo(() => {
|
|
||||||
if (!appConfig?.platforms) return []
|
|
||||||
const result: { platform: string; apps: AppInfo[] }[] = []
|
|
||||||
for (const platform of availablePlatforms) {
|
|
||||||
const apps = appConfig.platforms[platform]
|
|
||||||
if (apps?.length) {
|
|
||||||
result.push({ platform, apps })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}, [appConfig, availablePlatforms])
|
|
||||||
|
|
||||||
// App selector view
|
// App selector view
|
||||||
if (showAppSelector || !selectedApp) {
|
if (showAppSelector || !selectedApp) {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useState, useRef } from 'react'
|
import { useState, useRef, useEffect } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { useMutation } from '@tanstack/react-query'
|
import { useMutation } from '@tanstack/react-query'
|
||||||
import { balanceApi } from '../api/balance'
|
import { balanceApi } from '../api/balance'
|
||||||
@@ -55,6 +55,15 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top
|
|||||||
)
|
)
|
||||||
const popupRef = useRef<Window | null>(null)
|
const popupRef = useRef<Window | null>(null)
|
||||||
|
|
||||||
|
// Scroll lock when modal is open
|
||||||
|
useEffect(() => {
|
||||||
|
const originalOverflow = document.body.style.overflow
|
||||||
|
document.body.style.overflow = 'hidden'
|
||||||
|
return () => {
|
||||||
|
document.body.style.overflow = originalOverflow
|
||||||
|
}
|
||||||
|
}, [])
|
||||||
|
|
||||||
const hasOptions = method.options && method.options.length > 0
|
const hasOptions = method.options && method.options.length > 0
|
||||||
const minRubles = method.min_amount_kopeks / 100
|
const minRubles = method.min_amount_kopeks / 100
|
||||||
const maxRubles = method.max_amount_kopeks / 100
|
const maxRubles = method.max_amount_kopeks / 100
|
||||||
@@ -134,15 +143,17 @@ export default function TopUpModal({ method, onClose, initialAmountRubles }: Top
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="fixed inset-0 bg-black/70 z-[60] flex items-center justify-center p-4"
|
className="fixed inset-0 bg-black/70 z-[60] flex items-start sm:items-center justify-center p-4 overflow-y-auto"
|
||||||
style={{
|
style={{
|
||||||
paddingTop: 'calc(1rem + env(safe-area-inset-top, 0px))',
|
paddingTop: 'calc(2rem + env(safe-area-inset-top, 0px))',
|
||||||
paddingBottom: 'calc(1rem + env(safe-area-inset-bottom, 0px))',
|
paddingBottom: 'calc(6rem + env(safe-area-inset-bottom, 0px))',
|
||||||
}}
|
}}
|
||||||
|
onClick={onClose}
|
||||||
>
|
>
|
||||||
<div className="absolute inset-0" onClick={onClose} />
|
<div
|
||||||
|
className="relative w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 shadow-2xl overflow-hidden animate-scale-in"
|
||||||
<div className="relative w-full max-w-sm bg-dark-900 rounded-2xl border border-dark-700/50 shadow-2xl overflow-hidden animate-scale-in">
|
onClick={(e) => e.stopPropagation()}
|
||||||
|
>
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<div className="flex items-center justify-between px-4 py-3 bg-dark-800/50">
|
<div className="flex items-center justify-between px-4 py-3 bg-dark-800/50">
|
||||||
<span className="font-semibold text-dark-100">{methodName}</span>
|
<span className="font-semibold text-dark-100">{methodName}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user