Add modals
This commit is contained in:
@@ -4,6 +4,8 @@ import { marathonsApi, eventsApi, challengesApi } from '@/api'
|
||||
import type { Marathon, ActiveEvent, Challenge } from '@/types'
|
||||
import { Button, Card, CardContent } from '@/components/ui'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { useToast } from '@/store/toast'
|
||||
import { useConfirm } from '@/store/confirm'
|
||||
import { EventBanner } from '@/components/EventBanner'
|
||||
import { EventControl } from '@/components/EventControl'
|
||||
import { ActivityFeed, type ActivityFeedRef } from '@/components/ActivityFeed'
|
||||
@@ -14,6 +16,8 @@ export function MarathonPage() {
|
||||
const { id } = useParams<{ id: string }>()
|
||||
const navigate = useNavigate()
|
||||
const user = useAuthStore((state) => state.user)
|
||||
const toast = useToast()
|
||||
const confirm = useConfirm()
|
||||
const [marathon, setMarathon] = useState<Marathon | null>(null)
|
||||
const [activeEvent, setActiveEvent] = useState<ActiveEvent | null>(null)
|
||||
const [challenges, setChallenges] = useState<Challenge[]>([])
|
||||
@@ -83,7 +87,16 @@ export function MarathonPage() {
|
||||
}
|
||||
|
||||
const handleDelete = async () => {
|
||||
if (!marathon || !confirm('Вы уверены, что хотите удалить этот марафон? Это действие нельзя отменить.')) return
|
||||
if (!marathon) return
|
||||
|
||||
const confirmed = await confirm({
|
||||
title: 'Удалить марафон?',
|
||||
message: 'Все данные марафона будут удалены безвозвратно.',
|
||||
confirmText: 'Удалить',
|
||||
cancelText: 'Отмена',
|
||||
variant: 'danger',
|
||||
})
|
||||
if (!confirmed) return
|
||||
|
||||
setIsDeleting(true)
|
||||
try {
|
||||
@@ -91,7 +104,7 @@ export function MarathonPage() {
|
||||
navigate('/marathons')
|
||||
} catch (error) {
|
||||
console.error('Failed to delete marathon:', error)
|
||||
alert('Не удалось удалить марафон')
|
||||
toast.error('Не удалось удалить марафон')
|
||||
} finally {
|
||||
setIsDeleting(false)
|
||||
}
|
||||
@@ -106,7 +119,7 @@ export function MarathonPage() {
|
||||
setMarathon(updated)
|
||||
} catch (err: unknown) {
|
||||
const error = err as { response?: { data?: { detail?: string } } }
|
||||
alert(error.response?.data?.detail || 'Не удалось присоединиться')
|
||||
toast.error(error.response?.data?.detail || 'Не удалось присоединиться')
|
||||
} finally {
|
||||
setIsJoining(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user